import GameModel from "../ts/core/GameModel"; import FGHUD from "../ts/gear_2.3.4/fgui/FGHUD"; import SKDataUtil from "../ts/gear_2.3.4/util/SKDataUtil"; import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil"; let GameRes = require('../game/GameRes'); cc.Class({ extends: cc.Component, properties: { nameLab: cc.Label, aimLab: cc.Label, roleInfo: cc.Node, bangInfo: cc.Node, roleNode: cc.Node, listItem: cc.Node, listContent: cc.Node, weight: cc.Label, bidnode: cc.Node, SafeNotice: cc.Prefab, }, onLoad() { this.bangdata = {}; this.roledata = {}; this.currentSelected = -1; this.onShowRoleInfo = false; this.roleInfo.active = false; this.preitem = null; this.ismaster = false; }, loadBangInfo(data) { console.log(data) FGHUD.hideLoading(); this.currentSelected = -1; this.roleInfo.active = false; this.bangdata = data; this.nameLab.string = data.info.name; this.aimLab.string = data.info.aim; GameModel.player.bangid = data.info.bangid; this.ismaster = (GameModel.player.roleid == data.info.masterid); this.weight.node.active = this.ismaster; this.bidnode.active = this.ismaster; if (this.ismaster) { this.weight.string = '幫派權重:' + data.info.weight; } this.unscheduleAllCallbacks(); this.listContent.destroyAllChildren(); this.itemNodes = []; let maxLength = data.rolelist.length; // this.listContent.height = maxLength * this.listItem.height; // if (this.listContent.height < this.listContent.parent.height) { // this.listContent.height = this.listContent.parent.height; // } let itemheight = 0; let time = 0; for (let index = 0; index < maxLength; index++) { this.scheduleOnce(() => { let item = cc.instantiate(this.listItem); if (item) { item.parent = this.listContent; item.active = true; item.x = 0; item.y = -index * item.height; if (index % 2 == 0) { item.getChildByName('bg2').active = true; } if (itemheight == 0) { itemheight = item.height; this.listContent.height = maxLength * itemheight; if (this.listContent.height < this.listContent.parent.height) { this.listContent.height = this.listContent.parent.height; } } let jobarr = ['幫主', '幫眾']; let sexarr = ['男', '女']; let racearr = ['人', '仙', '魔', '鬼', '龍']; let onlinearr = ['離線', '在線']; item.getChildByName('Name').getComponent(cc.Label).string = data.rolelist[index].name; item.getChildByName('Level').getComponent(cc.Label).string = data.rolelist[index].level; item.getChildByName('Position').getComponent(cc.Label).string = data.rolelist[index].roleid == data.info.masterid ? jobarr[0] : jobarr[1]; item.getChildByName('Race').getComponent(cc.Label).string = sexarr[data.rolelist[index].sex - 1] + racearr[data.rolelist[index].race - 1]; item.getChildByName('OffLine').getComponent(cc.Label).string = onlinearr[data.rolelist[index].online]; item.bangtag = index; this.itemNodes.push(item); } }, time) time += 0.015 } if (!this.onShowRoleInfo) { this.bangInfo.active = true; } if (this.ismaster) { this.titleStr = '解散'; this.bangInfo.getChildByName('requestListBtn').active = true; this.node.getChildByName('ButtomBtn').getChildByName('ExitBang').active = false; this.node.getChildByName('ButtomBtn').getChildByName('DisbandBang').active = true; } else { this.titleStr = '離開'; } }, onLeaveBtnClicked(e, d) { //--zfy增加提示 GameModel.notice.addMsg(1, '是否' + this.titleStr + this.nameLab.string + '幫派', () => { if (GameModel.player.safe_lock == 1) { let safe_notice = cc.instantiate(this.SafeNotice); safe_notice.parent = cc.find('Canvas'); safe_notice.getComponent('SafeNotice').setCallback(() => { GameModel.send('c2s_leavebang', { roleid: GameModel.player.roleid, bangid: GameModel.player.bangid }); cc.find('Canvas').getComponent('GameLogic').mapLogic.changeMap('1011'); }); } else { GameModel.send('c2s_leavebang', { roleid: GameModel.player.roleid, bangid: GameModel.player.bangid }); cc.find('Canvas').getComponent('GameLogic').mapLogic.changeMap('1011'); } }, () => { }); }, onKickOutBtnClicked(e, d) { if (this.roledata.roleid == null) { return; } GameModel.notice.addMsg(1, '是否將[' + this.roledata.name + ']踢出', () => { FGHUD.showLoading(); GameModel.send('c2s_leavebang', { roleid: this.roledata.roleid, bangid: GameModel.player.bangid }); }, () => { }); }, onChangeShow(e, d) { if (d == 0) { this.onShowRoleInfo = false; this.bangInfo.active = true; this.roleInfo.active = false; } else { this.onShowRoleInfo = true; this.bangInfo.active = false; this.roleInfo.active = false; if (this.currentSelected != -1) { this.roleInfo.active = true; } } }, showRoleInfo() { this.roleNode.getComponent('UIRole').setInfo(this.roledata, true); if (this.ismaster && this.roledata.roleid != GameModel.player.roleid) { this.roleInfo.getChildByName('kickoutBtn').active = true; } else { this.roleInfo.getChildByName('kickoutBtn').active = false; } if (this.onShowRoleInfo) { this.roleInfo.active = true; } }, itemClicked(e, d) { let item = e.target; if (!item || this.currentSelected == item.bangtag) { return; } let node; if (SKUIUtil.isValid(this.preitem)) { node = this.preitem.getChildByName("bg3"); if (node) { node.active = false; } else { cc.warn(`$警告:幫派信息點擊條目bg3不存在`); } } this.preitem = item; if (SKUIUtil.isValid(this.preitem)) { node = this.preitem.getChildByName("bg3"); if (node) { node.active = false; } else { cc.warn(`$警告:幫派信息點擊條目bg3不存在`); } } this.currentSelected = item.bangtag; this.roledata = this.bangdata.rolelist[this.currentSelected]; this.showRoleInfo(); }, clear() { this.roleNode.getComponent('UIRole').clear(); this.unscheduleAllCallbacks(); }, });