import GameModel from "../ts/core/GameModel"; import GameUtil from "../ts/core/GameUtil"; import MsgAlert from "../ts/game/msg/MsgAlert"; cc.Class({ extends: cc.Component, properties: { nameLab: cc.Label, headIcon: cc.Sprite, idLabel: cc.Label, leaveBtn: cc.Node, kickBtn: cc.Node, transferBtn: cc.Node, beLeader: cc.Node, tempLeave: cc.Node }, onLoad() { }, setInfo(info) { this.objInfo = info; this.leaveBtn.active = false; this.kickBtn.active = false; this.transferBtn.active = false; this.beLeader.active = false; if (GameModel.player.onlyid == info.onlyid) { this.leaveBtn.active = true; if (!GameModel.player.isleader) { this.tempLeave.active = true; this.tempLeave.y = this.transferBtn.y; if (this.objInfo.pause == 1) { this.tempLeave.getChildByName("tip").getComponent(cc.Label).string = "回歸隊伍" } else { this.tempLeave.getChildByName("tip").getComponent(cc.Label).string = "暫離隊伍" } } } else if (GameModel.player.teamid > 0 && GameModel.player.isleader) { this.kickBtn.active = true; this.transferBtn.active = true; if (this.objInfo.pause == 1) { this.tempLeave.active = true; this.tempLeave.getChildByName("tip").getComponent(cc.Label).string = "召回隊伍" } } else if (this.objInfo.isleader) { this.beLeader.active = true; } // else{ // this.node.destroy(); // return; // } this.headIcon.spriteFrame = GameModel.getRoleHead(info.resid); this.nameLab.node.color = GameUtil.getReliveColor(info.relive); this.nameLab.string = info.name; this.idLabel.string = `編號:${info.roleid}`; }, leaveTeam(e, d) { GameModel.send('c2s_leave_team', { roleid: this.objInfo.roleid, teamid: this.objInfo.teamid }); this.closeSelf(); }, transferTeamLeaderRequst(e, d) { GameModel.send('c2s_transfer_team_requst', { toid: this.objInfo.roleid, type: 1 }); this.closeSelf(); }, beLeaderRequst() { GameModel.send('c2s_transfer_team_requst', { toid: this.objInfo.roleid, type: 0 }); this.closeSelf(); }, closeSelf(e, d) { this.node.destroy(); }, tempLeaveFunc() { if (this.objInfo.pause == 0) { if (GameModel.player.isleader) { MsgAlert.addMsg("隊長不可暫離隊伍"); return; } GameModel.send('c2s_pause_team', { roleid: this.objInfo.roleid }); GameModel.player.tempLeave = true } else { if (this.objInfo.roleid == GameModel.player.roleid) { GameModel.send('c2s_recall_confirm', { roleid: this.objInfo.roleid }); } else { GameModel.send('c2s_recall_team', { roleid: this.objInfo.roleid }); } GameModel.player.tempLeave = false } this.closeSelf(); } });