import AudioUtil from "../core/AudioUtil"; import GameModel from "../core/GameModel"; import MsgAlert from "../game/msg/MsgAlert"; import FGAlert from "../gear_2.3.4/fgui/FGAlert"; import FGUtil from "../gear_2.3.4/fgui/FGUtil"; import SKUIUtil from "../gear_2.3.4/util/SKUIUtil"; import VIPUtil from "../game/role/VIPUtil"; import GameUtil from "../core/GameUtil"; import SKDataUtil from "../gear_2.3.4/util/SKDataUtil"; import WingUtil from "../wing/WingUtil"; import WeaponUtil from "../weapon/WeaponUtil"; import CPubFunction = require('../../game/PubFunction'); import CMainPlayerInfo = require('../../game/MainPlayerInfo'); import { EAttrTypeL1 } from "../core/EEnum"; import ItemUtil from "../core/ItemUtil"; import SkillUtil from "../game/skill/core/SkillUtil"; const { ccclass, property } = cc._decorator; export default class TeamPanel extends cc.Component { /** * 隊伍單例實例 */ public static Instance : TeamPanel = null; /** * 是否已加入隊伍 */ hasTeam : Boolean = false; /** * 隊伍ID */ teamId : number = 0; /** * 是否為隊長 */ isLeader : Boolean = false; /** * 自定義目標名稱 */ targetCustomName : string = "無目標"; /** * 招募種族限制列表 */ raceLimit : any = []; /** * 招募面板中標籤名稱 */ recruitLabelList : any = ["來男鬼", "來手動", "女人", "女魔", "來輸出", "男人", "男魔"]; /** * 組隊大廳任務目標子節點 */ taskTargetItemList : any = []; /** * 匹配隊伍限制 */ matchTeamLimit : any = { level: { "startZhuan": "0轉", "endZhuan": "3轉", "startLevel": "0級", "endLevel": "180級" }, target: {}, beLeader: false }; /** * 匹配任務限制 */ matchTaskLimit : any = [ [ { name: "無目標", type: 1 }, { name: "鍾旭抓鬼", type: 2, all: 0 }, { name: "遊蕩妖魔", type: 2, all: 0 }, { name: "三界妖王", type: 2, all: 0 }, { name: "地煞星", type: 0, start: 1, end: 17, unit: "星", setStart: 1, setEnd: 17 }, { name: "種情花", type: 2, all: 0 }, { name: "劇情任務", type: 1 } ], [ { name: "大雁塔", type: 0, start: 1, end: 8, unit: "層", setStart: 1, setEnd: 8 }, { name: "尋芳", type: 0, start: 1, end: 16, unit: "關", setStart: 1, setEnd: 16 } ], [ { name: "幫派強盜", type: 1 } ] ]; /** * 目標起始範圍節點列表 */ targetStartRangeList : any = []; /** * 目標起始範圍節點列表 */ targetEndRangeList : any = []; /** * 申請列表 */ requestList : any = []; /** * 當前查看的隊伍列表類型 */ teamListType : string = "無目標"; /** * 是否在匹配中 */ isMatching : Boolean = false; /** * 隊伍面板 */ teamPanel : fgui.GComponent = null; /** * 隊伍面板中目标名称 */ teamTargetText : fgui.GTextField = null; /** * 隊伍面板中招募信息 */ teamRecruitText : fgui.GTextField = null; /** * 申請列表面板 */ requestListPanel : fgui.GComponent = null; /** * 隊伍面板中目标面板 */ teamTargetPanel : fgui.GComponent = null; /** * 隊伍面板中目标面板中的自定义目标名称 */ customTargetNameText : fgui.GTextField = null; /** * 改變目標名稱面板 */ changeTargetNamePanel : fgui.GComponent = null; /** * 套裝技能和寵物信息面板 */ suitSkillAndPetPanel : fgui.GComponent = null; /** * 夥伴替換列表面板 */ remainPartnerPanel : fgui.GComponent = null; /** * 招募面板 */ recruitPanel : fgui.GComponent = null; /* * 招募面板中目標名稱 */ recruitPanelTeamTargetText : fgui.GTextField = null; /** * 種族面板 */ racePanel : fgui.GComponent = null; /** * 編輯標籤面板 */ editLabelPanel : fgui.GComponent = null; /** * 組隊大廳面板 */ matchHallPanel : fgui.GComponent = null; /** * 自動匹配面板 */ autoMatchPanel : fgui.GComponent = null; /** * 隊伍匹配面板 */ teamMatchPanel : fgui.GComponent = null; /** * 選擇等級面板 */ selectLevelPanel : fgui.GComponent = null; /** * 選擇目標範圍面板 */ targetRangePanel : fgui.GComponent = null; /** * 確認彈框 */ alertPanel : fgui.GComponent = null; /** * 隊伍設置面板 */ teamSettingPanel : fgui.GComponent = null; /** * 自動歸隊 */ autoRecall : boolean = false; popList : any = []; vecPartnerCard : any = []; prefabObject : any = {}; onLoad() { if (TeamPanel.Instance === null) { TeamPanel.Instance = this; this.loadPrefab(); } else { this.destroy(); return; } } /** * 加載預製體 */ loadPrefab() { // 加載所需的預製體 var prefabList = [ { url: "Prefabs/PartnerUI", name: "PartnerUI" }, { url: "Prefabs/goPartnerCard_1", name: "goPartnerCard_1" }, { url: "Prefabs/goPartnerCard_2", name: "goPartnerCard_2" }, { url: "Prefabs/goTeamBtnAdd", name: "goTeamBtnAdd" } ] this.prefabObject = {} for (let item of prefabList) { cc.loader.loadRes(item.url, cc.Prefab, (err, prefab) => { if (err) console.warn(err); else { this.prefabObject[item.name] = prefab; } }) } } /** * 打開隊伍面板 * @param refresh 是否為只刷新 * @returns */ public openTeamMainPanel(refresh : Boolean = false) : void { if (!this.teamPanel || (this.teamPanel && !this.teamPanel.node && !SKUIUtil.isValid(this.teamPanel.node))) { // 創建隊伍面板並添加 this.teamPanel = FGUtil.create("main_ui", "team_main_panel"); FGUtil.root().addChild(this.teamPanel); this.teamPanel.node.addChild(new cc.Node("team_member_node")); this.teamPanel.node.addChild(new cc.Node("my_partner_node")); this.stopCocosNodeButton(this.teamPanel); this.teamPanel.makeFullScreen(); } // 設置是否有隊伍、是否為隊長;關閉速度顯示 B this.isLeader = GameModel.player.isleader; this.teamId = GameModel.player.teamid; this.hasTeam = this.teamId > 0; //FGUtil.getComponent(this.teamPanel, "alert/n38").visible = false; FGUtil.getControl(this.teamPanel, "alert/isLeader").selectedIndex = this.isLeader ? 1 : 0; FGUtil.getControl(this.teamPanel, "alert/hasTeam").selectedIndex = this.hasTeam ? 1 : 0; FGUtil.getControl(this.teamPanel, "alert/showSpeed").selectedIndex = 0; var memberList = GameModel.player.teamInfo.objlist; for (let i in memberList) { if (SKDataUtil.hasProperty(memberList[i], "onlyid")) { if (memberList[i].accountid == GameModel.player.roleid) { FGUtil.getControl(this.teamPanel, "alert/temp_leave").selectedIndex = memberList[i].pause == 1 ? 1 : 0 break; } } } if (this.hasTeam) FGUtil.getComponent(this.teamPanel, "alert/setTarget").width = this.isLeader ? 438 : 538; if (this.requestList && this.requestList.length > 0) { FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/applyNumber").visible = true; FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/applyNumber").text = this.requestList.length; } // 隊伍面板中目標名稱 this.teamTargetText = FGUtil.getTextField(this.teamPanel, "alert/setTarget/targetName"); this.teamTargetText.text = GameModel.player.teamInfo.type ? GameModel.player.teamInfo.type : "無目標"; // 隊伍面板中招募信息 this.teamRecruitText = FGUtil.getTextField(this.teamPanel, "alert/hasTeamBtnGroup/recruitBar/recruit_info"); if (!GameModel.player.teamInfo.content || GameModel.player.teamInfo.content == "") this.teamRecruitText.text = "點擊編輯招募信息"; else this.teamRecruitText.text = GameModel.player.teamInfo.content; if (GameModel.player.teamInfo.teamcnt > 1) { FGUtil.getTextField(this.teamPanel, "alert/setTarget/number").text = `(${GameModel.player.teamInfo.teamcnt}/5)` } else { FGUtil.getComponent(this.teamPanel, "alert/setTarget/number").text = ""; } // 刷新到此為止 if (refresh) { this.showTeamMember(); return; } // 設置目標組件點擊事件 var setTeamTargetCom = FGUtil.getComponent(this.teamPanel, "alert/setTarget"); setTeamTargetCom.onClick(() => { this.openTeamTargetPanel({}); }, this) // 設置遮罩和關閉按鈕點擊事件 var mask = FGUtil.getComponent(this.teamPanel, "mask"); var close = FGUtil.getButton(this.teamPanel, "alert/closeBtn"); this.pushCloseEvent(mask, this.teamPanel); this.pushCloseEvent(close, this.teamPanel); // 創建隊伍按鈕 var createTeamBtn = FGUtil.getButton(this.teamPanel, "alert/create_team_btn"); createTeamBtn.onClick(() => { this.createTeam() }, this); // 離開隊伍按鈕 var levaeTeamBtn = FGUtil.getButton(this.teamPanel, "alert/hasTeamBtnGroup/leave_team_btn"); var leaderLevaeTeamBtn = FGUtil.getButton(this.teamPanel, "alert/hasTeamBtnGroup/leader_leave_team_btn"); levaeTeamBtn.onClick(this.leaveTeam, this); leaderLevaeTeamBtn.onClick(this.leaveTeam, this); // 暫離隊伍 FGUtil.getButton(this.teamPanel, "alert/hasTeamBtnGroup/temp_leave_team_btn").onClick(this.pauseTeam, this); // 队伍设置 FGUtil.getButton(this.teamPanel, "alert/hasTeamBtnGroup/set").onClick(this.setTeamOption, this); // 我的伙伴按鈕 var myPartnerBtn = FGUtil.getButton(this.teamPanel, "alert/partner_btn"); myPartnerBtn.onClick(() => { this.createPrefab(this.teamPanel.node, { x: 0, y: 0 }, "PartnerUI", "PartnerUI"); }, this) // 組隊大廳按鈕 var matchHallBtn = FGUtil.getButton(this.teamPanel, "alert/match_hall_btn"); matchHallBtn.onClick(() => { this.openMatchHallPanel() }, this) // 招募信息按鈕和條 var recruitBar = FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/recruitBar"); var recruitBtn = FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/teamTalkBtn"); recruitBar.onClick(() => { this.openRecruitPanel() }, this); recruitBtn.onClick(() => { this.openRecruitPanel() }, this); // 顯示速度按鈕 var showSpdBtn = FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/speedBtn"); var hideSpdBtn = FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/speedBackBtn"); showSpdBtn.onClick(() => { try { var pNode = this.teamPanel.node.getChildByName("team_member_node"); for (let temp of pNode.children) { if (temp.name == "goPartnerCard_1") { temp.getChildByName("normal").active = false; temp.getChildByName("info").active = true; } } FGUtil.getControl(this.teamPanel, "alert/showSpeed").selectedIndex = 1; } catch (err) { console.log(err) } }, this); hideSpdBtn.onClick(() => { try { var pNode = this.teamPanel.node.getChildByName("team_member_node"); for (let temp of pNode.children) { if (temp.name == "goPartnerCard_1") { temp.getChildByName("normal").active = true; temp.getChildByName("info").active = false; } } FGUtil.getControl(this.teamPanel, "alert/showSpeed").selectedIndex = 0; } catch (err) { console.log(err) } }, this); // 顯示申請列表 var requestListBtn = FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/teamApplyBtn"); requestListBtn.onClick(() => { this.openRequestList(); }, this); // 播放音效 AudioUtil.playOpenAudio(); GameModel.send('c2s_team_requeslist', {}); GameModel.send('c2s_ask_partner_list', { nRoleID: GameModel.player.roleid }); } /** * 打開隊伍申請列表 */ openRequestList() { if (GameModel.player.mapid == 4004 || GameModel.player.mapid == 1213) { MsgAlert.addMsg("本地圖不可進行此操作") return } if (this.teamPanel && this.teamPanel.node) { FGUtil.getComponent(this.teamPanel, "alert/hasTeamBtnGroup/applyNumber").visible = false; } if (!this.requestList || this.requestList.length <= 0) return; if (!this.requestListPanel || (this.requestListPanel && !this.requestListPanel.node && !SKUIUtil.isValid(this.requestListPanel.node))) { // 創建隊伍面板並添加 this.requestListPanel = FGUtil.create("main_ui", "apply_list_panel"); FGUtil.root().addChild(this.requestListPanel); this.stopCocosNodeButton(this.requestListPanel); this.requestListPanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.requestListPanel, "mask"); this.pushCloseEvent(mask, this.requestListPanel); var list = FGUtil.getList(this.requestListPanel, "alert/list"); list.removeChildrenToPool(); for (let i in this.requestList) { let item = list.addItemFromPool().asCom; FGUtil.getTextField(item, "player_name").text = this.requestList[i].name; FGUtil.getTextField(item, "level").text = this.getReliveText(this.requestList[i].relive, this.requestList[i].level); FGUtil.getLoader(item, "race").url = "ui://main_ui/icon_race1"; FGUtil.getLoader(item, "ava").texture = GameModel.getRoleHead(this.requestList[i].resid) let btn = FGUtil.getButton(item, "n8"); btn.data = this.requestList[i].roleid btn.clearClick() btn.onClick(() => { if (GameModel.player.mapid == 4004 || GameModel.player.mapid == 1213) { MsgAlert.addMsg("本地圖不可進行此操作") return } let roleid = btn.data GameModel.send('c2s_operteam', { operation: 1, roleid: roleid, teamid: GameModel.player.teamid }); this.requestList.splice(i, 1) list.removeChildToPool(item) if (list.numChildren == 0) { FGUtil.dispose(this.requestListPanel); this.recoveryCocosNodeButton(); } }, this) let btn1 = FGUtil.getButton(item, "n9"); btn1.data = this.requestList[i].roleid btn1.clearClick() btn1.onClick(() => { let roleid = btn1.data GameModel.send('c2s_operteam', { operation: 0, roleid: roleid, teamid: GameModel.player.teamid }); this.requestList.splice(i, 1) list.removeChildToPool(item) if (list.numChildren == 0) { FGUtil.dispose(this.requestListPanel); this.recoveryCocosNodeButton(); } }, this) } } /** * 創建隊伍 */ private createTeam() { if (this.hasTeam) return; // 沒有隊伍時創建隊伍 if (GameModel.player.prisonTime > 0) { MsgAlert.addMsg('傳說罪孽深重的人是創建不了隊伍的!'); return; } if (GameModel.player.teamid > 0) { return; } GameModel.send('c2s_create_team', { roleid: GameModel.player.roleid, type: this.teamTargetText.text }); } /** * 離開隊伍 */ private leaveTeam() { if (!this.hasTeam) return; if (GameModel.player.mapid == 4004 || GameModel.player.mapid == 1213) { MsgAlert.addMsg("本地圖不可進行此操作") return } this.showAlert("離開隊伍?", () => { }, () => { GameModel.send('c2s_leave_team', { roleid: GameModel.player.roleid, teamid: GameModel.player.teamid }); }) } /** * 暫離隊伍 */ pauseTeam() { var isLeave = FGUtil.getControl(this.teamPanel, "alert/temp_leave"); if (isLeave.selectedIndex == 0) { if (GameModel.player.isleader) { MsgAlert.addMsg("隊長不可暫離隊伍"); return; } GameModel.send('c2s_pause_team', { roleid: GameModel.player.roleid }); isLeave.selectedIndex = 1; GameModel.player.tempLeave = true } else { GameModel.send('c2s_recall_confirm', { roleid: GameModel.player.roleid }); isLeave.selectedIndex = 0; GameModel.player.tempLeave = false } } setTeamOption() { if (!SKUIUtil.isFGUIValid(this.teamSettingPanel)) { this.teamSettingPanel = FGUtil.create("main_ui", "set_team_panel"); FGUtil.root().addChild(this.teamSettingPanel); this.stopCocosNodeButton(this.teamSettingPanel); this.teamSettingPanel.makeFullScreen(); FGUtil.getControl(this.teamSettingPanel, "alert/n2/selected").selectedIndex = this.autoRecall ? 1 : 0; FGUtil.getButton(this.teamSettingPanel, "alert/n2").onClick(() => { this.autoRecall = !this.autoRecall; FGUtil.getControl(this.teamSettingPanel, "alert/n2/selected").selectedIndex = this.autoRecall ? 1 : 0; GameModel.send(`c2s_ischeck_${this.autoRecall ? 'on' : 'off'}`, { roleid: GameModel.player.roleid }) }, this) var mask = FGUtil.getComponent(this.teamSettingPanel, "mask") this.pushCloseEvent(mask, this.teamSettingPanel) } } /** * 顯示隊伍成員 */ showTeamMember() { SKUIUtil.destroyList(this.vecPartnerCard); if (!this.vecPartnerCard) this.vecPartnerCard = []; let goContent = this.teamPanel.node.getChildByName("team_member_node"); goContent.destroyAllChildren(); var offset = (this.teamPanel.node.width - 1024) / 2 let stStart = { nX: 190 + offset, nY: -305 }; // 沒有隊伍 if (GameModel.player.teamid == 0) { //----------- 主角 ------------- let goCard = this.CreateCard(GameModel.player); cc.find('normal/picPtFlag', goCard).active = false; this.vecPartnerCard.push(goCard); //------------ 夥伴 ------------ let index = 0; for (let item of CMainPlayerInfo.vecChuZhan) { if (item <= 0) { continue; } let stInfo = CMainPlayerInfo.GetPartner(item); let goCard = this.CreateCard(stInfo); goCard.on("click", () => { this.openRemainPartnerPanel(goCard.x) }, this); this.vecPartnerCard.push(goCard); index++; } // 有未出戰且當前隊伍人數不足5人 if (this.vecPartnerCard.length < 5 && CMainPlayerInfo.vecPartnerInfo.length - index > 0) { let goBtnAdd = this.createPrefab(goContent, { x: stStart.nX + this.vecPartnerCard.length * 150, y: -305 }, "goTeamBtnAdd", "goTeamBtnAdd"); goBtnAdd.on("click", () => { this.openRemainPartnerPanel(goBtnAdd.x) }, this); this.vecPartnerCard.push(goBtnAdd); } } else { // 有隊伍 if (GameModel.player.teamInfo == null || GameModel.player.teamInfo.objlist == null) { return; } let partnerPos = 0, leader = 0; for (const obj of GameModel.player.teamInfo.objlist) { if (obj.pause == 1) continue; let goCard = this.CreateCard(obj); if (obj.livingtype == 1) { if (leader == 0) { cc.find('normal/picPtFlag', goCard).active = true; leader = 1; } } else { goCard.on("click", () => { this.openRemainPartnerPanel(goCard.x) }, this); partnerPos++; } this.vecPartnerCard.push(goCard); } // 隊伍不足5人,且有未出戰夥伴 if (this.vecPartnerCard.length < 5 && this.isLeader && CMainPlayerInfo.vecPartnerInfo.length - partnerPos > 0) { let goBtnAdd = this.createPrefab(goContent, { x: stStart.nX + this.vecPartnerCard.length * 150, y: -305 }, "goTeamBtnAdd", "goTeamBtnAdd"); goBtnAdd.on("click", () => { this.openRemainPartnerPanel(goBtnAdd.x) }, this); this.vecPartnerCard.push(goBtnAdd); } } } /** * 創建隊伍面板角色卡片 * @param roleInfo 角色信息 * @returns */ CreateCard(roleInfo) { var offset = (this.teamPanel.node.width - 1024) / 2 let stStart = { nX: 190 + offset, nY: -305 }; let goPanel = this.teamPanel.node.getChildByName("team_member_node"); let prefab = roleInfo.livingtype == 1 ? "goPartnerCard_1" : "goPartnerCard_2"; let strPrefab = roleInfo.livingtype == 1 ? 'goPartnerCard_1' : 'goPartnerCard_2'; let base_url = roleInfo.livingtype == 1 ? 'normal/' : ''; let gap = 0; if (this.vecPartnerCard) { gap = this.vecPartnerCard.length; } else { cc.warn(`$警告:夥伴列表為空!`); } let goCard = this.createPrefab(goPanel, { x: stStart.nX + gap * 150, y: -305 }, prefab, strPrefab); let role = goCard if (roleInfo.livingtype == 1) { role = cc.find("normal", goCard) } let roleNode = cc.find(base_url + 'role', goCard); let maskNode = cc.find(base_url + 'role/mask', goCard); let effNode = cc.find('eff', roleNode); CPubFunction.SetAnimation(roleNode, roleInfo.resid, 'stand_1'); if (maskNode && (roleInfo.color1 != 0 || roleInfo.color2 != 0)) { CPubFunction.SetMaskAnimation(maskNode, roleInfo.resid, 'stand_1'); maskNode.active = true this.showColorMask(maskNode, this.hxcolorTransfrom(roleInfo.color1), this.hxcolorTransfrom(roleInfo.color2)) } else { if (maskNode) maskNode.active = false } this.playeffect(effNode, roleInfo) let stData = GameModel.conf_res_anchor[roleInfo.resid]; if (stData) { roleNode.anchorY = stData.anchorY; if (maskNode) maskNode.anchorY = stData.anchorY; } let nameRT = cc.find('labName', goCard).getComponent(cc.RichText); let title = `${roleInfo.name}`; let vipLevel = VIPUtil.getVipLevel(roleInfo.chargesum); if (vipLevel > 0) { title = `${title}`; } nameRT.string = title; let level_lb = cc.find('labLevel', goCard).getComponent(cc.Label); GameUtil.setReliveLabel(level_lb, 0, roleInfo.relive, roleInfo.level); SKUIUtil.setSpriteFrame(cc.find('picRace', goCard), 'Common/ui_common', CPubFunction.GetRaceFileName(roleInfo.race)); let weaponNode = cc.find("weapon", roleNode); if (roleInfo.account || roleInfo.accountid) { roleNode.active = true; //if (this.isDoubleWeapon(roleInfo.resid, roleInfo.weapon)) { let weaponNode1 = cc.find("weapon1", roleNode.parent); weaponNode1.active = true CPubFunction.addWeaponAnimation(roleInfo.weapon, weaponNode, roleNode, this, roleInfo.resid, "stand", 1, true); //CPubFunction.addWeaponAnimation(roleInfo.weapon, weaponNode1, roleNode, this, roleInfo.resid, "stand", 1, "_r", true); //} else { //CPubFunction.addWeaponAnimation(roleInfo.weapon, weaponNode, roleNode, this, roleInfo.resid, "stand", 1, "", true); //} let wingId = roleInfo.wingId; if (wingId >= 8000) { wingId = SKDataUtil.findByDict(GameModel.game_conf.wing, "resid", roleInfo.wingId, "id", 0); } WingUtil.playAni(role, roleInfo.roleid, 1, "stand", 0, wingId); } else { roleNode.active = false; weaponNode.active = false; } // 非夥伴卡片 if (strPrefab == "goPartnerCard_1") { if (this.hasTeam) { let infoNode = cc.find('info', goCard); // 套裝 cc.find("suitLabel", infoNode).getComponent(cc.Label).string = roleInfo.schemename; // 人物速度 cc.find("roleSpd", infoNode).getComponent(cc.Label).string = roleInfo.spd; // 默認技能 let skillIcon = cc.find("skillIcon", infoNode); skillIcon.getComponent(cc.Sprite).spriteFrame = SkillUtil.getSkillIcon(roleInfo.lastSkill); if (roleInfo.curPet != "") { // 寵物速度 cc.find("petSpd", infoNode).getComponent(cc.Label).string = roleInfo.curPet.spd; // 寵物頭像 cc.find("normal/petIcon", goCard).getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIcon(roleInfo.curPet.resid); cc.find("normal/petIcon", goCard).on("click", () => { this.openSuitSkillAndPetInfoPanel(goCard.x, roleInfo) }, this) } else { // 沒有寵物,隱藏節點 cc.find("petSpd", infoNode).active = false; cc.find("spdLabel2", infoNode).active = false; cc.find("normal/petIcon", goCard).active = false; cc.find("normal/petBorder", goCard).active = false; } } else { cc.find("normal/petIcon", goCard).active = false; cc.find("normal/petBorder", goCard).active = false; } } return goCard; } playeffect(effNode, roleInfo) { var effectid = roleInfo.effectid; if (roleInfo.isMy) effectid = roleInfo.bodyEffectId; if (effNode) { if (effectid == 0) { effNode.active = false; return } var name = `${effectid}`; let anim = effNode.getComponent(cc.Animation); if (!anim) { return; } let clips = anim.getClips(); for (let clip of clips) { if (clip.name == name) { effNode.active = true; effNode.getComponent(cc.Animation).play(name); return; } } effNode.active = false; let url = `body_eff/${name}`; cc.loader.loadRes(url, cc.SpriteAtlas, (error, atlas) => { if (error) { cc.warn(`$警告:加載角色動畫資源失敗${url}`); return; } let curFrames = atlas.getSpriteFrames(); let curClip = cc.AnimationClip.createWithSpriteFrames(curFrames, 10); curClip.name = name; curClip.wrapMode = cc.WrapMode.Loop; try { if (!SKUIUtil.isValid(effNode)) return if (!effNode.getComponent(cc.Animation)) return let nodeAni = effNode.getComponent(cc.Animation); if (nodeAni) { nodeAni.addClip(curClip); nodeAni.play(name); } effNode.active = true; this.scheduleOnce(() => { if (SKUIUtil.isValid(effNode)) { effNode.scaleX = 450 / effNode.width; effNode.scaleY = 450 / effNode.height; } }, 0); } catch (err) { console.warn(err) } }); } } hxcolorTransfrom(color) { // let num = parseInt(color, 16); let num = color; let r = Math.floor(num / 256 / 256); let g = Math.floor(num / 256 % 256); let b = Math.floor(num % 256); return new cc.Color(r, g, b); } showColorMask(maskNode, color1, color2) { if (!maskNode || maskNode.active == false) return if (!maskNode || maskNode.active == false) return let logic = maskNode.getComponent('role_color'); if (color1.r != 0 || color1.g != 0 || color1.b != 0) { let t = Math.floor(color1.r) * 1000000 + Math.floor(color1.g) * 1000 + Math.floor(color1.b); logic.dH1 = t; } else { logic.dH1 = 0; } if (color2.r != 0 || color2.g != 0 || color2.b != 0) { let t = Math.floor(color2.r) * 1000000 + Math.floor(color2.g) * 1000 + Math.floor(color2.b); logic.dH2 = t; } else { logic.dH2 = 0; } } isDoubleWeapon(resid, weaponInfo = null) { var arr = [1111]; if (weaponInfo) if (SKDataUtil.jsonBy(weaponInfo).level == 5) return false for (let i in arr) { if (resid == arr[i]) return true } return false } /** * 打開套裝技能和寵物信息面板 */ openSuitSkillAndPetInfoPanel(x, info : any = {}) { if (!this.suitSkillAndPetPanel || (this.suitSkillAndPetPanel && !this.suitSkillAndPetPanel.node && !SKUIUtil.isValid(this.suitSkillAndPetPanel.node))) { this.suitSkillAndPetPanel = FGUtil.create("main_ui", "team_pet_panel"); FGUtil.root().addChild(this.suitSkillAndPetPanel); this.stopCocosNodeButton(this.suitSkillAndPetPanel); FGUtil.getComponent(this.suitSkillAndPetPanel, "alert").x = x + 50; this.suitSkillAndPetPanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.suitSkillAndPetPanel, "mask"); this.pushCloseEvent(mask, this.suitSkillAndPetPanel); if (info.curPet) { FGUtil.getLoader(this.suitSkillAndPetPanel, "alert/ava").texture = ItemUtil.getItemIcon(info.curPet.resid) FGUtil.getTextField(this.suitSkillAndPetPanel, "alert/name").text = info.curPet.name; FGUtil.getTextField(this.suitSkillAndPetPanel, "alert/level").text = this.getReliveText(info.curPet.relive, info.curPet.level) } } /** * 打開未出戰夥伴面板 * @param posX 觸發事件的伙伴卡片的位置 */ openRemainPartnerPanel(posX) { // 檢測是否有未出戰夥伴 var fightPanterCount = 0; for (var temp of CMainPlayerInfo.vecChuZhan) { if (temp <= 0) { continue; } fightPanterCount++; } if (CMainPlayerInfo.vecPartnerInfo.length - fightPanterCount <= 0) return; if (!this.remainPartnerPanel || (this.remainPartnerPanel && !this.remainPartnerPanel.node && !SKUIUtil.isValid(this.remainPartnerPanel.node))) { this.remainPartnerPanel = FGUtil.create("main_ui", "partner_panel"); FGUtil.root().addChild(this.remainPartnerPanel); this.stopCocosNodeButton(this.remainPartnerPanel); this.remainPartnerPanel.makeFullScreen(); } var offset = (this.teamPanel.node.width - 1024) / 2 let id = (posX - (190 + offset)) / 150; if (GameModel.player.teamInfo && GameModel.player.teamInfo.teamid && GameModel.player.teamInfo.teamid != 0) { let wj = 0;//玩家 for (let i in GameModel.player.teamInfo.objlist) { if (GameModel.player.teamInfo.objlist[i].livingtype == 1) wj++; } id -= wj; } else { id -= 1; } FGUtil.getComponent(this.remainPartnerPanel, "alert").x = posX - 30; var mask = FGUtil.getComponent(this.remainPartnerPanel, "mask"); this.pushCloseEvent(mask, this.remainPartnerPanel); let list = FGUtil.getList(this.remainPartnerPanel, "alert/list"); let count = 0; for (let index in CMainPlayerInfo.vecPartnerInfo) { if (CMainPlayerInfo.GetParterChuZhanPos(CMainPlayerInfo.vecPartnerInfo[index].id) != -1) { continue; } let item = list.addItemFromPool().asCom; // 頭像 cc.loader.loadRes("Common/huoban", cc.SpriteAtlas, function (err, atlas) { var frame = atlas.getSpriteFrame('huoban_' + CMainPlayerInfo.vecPartnerInfo[index].resid); FGUtil.getLoader(item, "ava").texture = frame; }); // 種族 FGUtil.getLoader(item, "race").url = "ui://main_ui/icon_race" + CMainPlayerInfo.vecPartnerInfo[index].race; FGUtil.getTextField(item, "name").text = CMainPlayerInfo.vecPartnerInfo[index].name; FGUtil.getTextField(item, "level").text = this.getReliveText(CMainPlayerInfo.vecPartnerInfo[index].relive, CMainPlayerInfo.vecPartnerInfo[index].level); FGUtil.getTextField(item, "level").color = this.getReliveColor(CMainPlayerInfo.vecPartnerInfo[index].relive, 0); this.pushCloseEvent(item, this.remainPartnerPanel, () => { CMainPlayerInfo.vecChuZhan[id] = CMainPlayerInfo.vecPartnerInfo[index].id; GameModel.send('c2s_change_partner_state', { nPartnerID: CMainPlayerInfo.vecPartnerInfo[index].id, nPos: id }); }) count++; // SKUIUtil.setSpriteFrame(cc.find('HeadPic/Icon', goPartner), 'Common/huoban', ); } let h = Math.min(200, count * 60); list.height = h; } // 設置0轉0級文本 getReliveText(relive : number, level : number) { let prefix = ""; if (relive > 3) { prefix = "飛升"; } else { prefix = `${relive}轉`; } let result = `${prefix}${level}級`; return result; } //type=0 人物和夥伴顏色,type=1召喚獸顏色 getReliveColor(relive : number, type = 0) : cc.Color { if (relive == 0) { if (type == 0) return SKUIUtil.colorOfString("#10df08"); if (type == 1) return SKUIUtil.colorOfString("#ef6518"); } else if (relive == 1) { if (type == 0) return SKUIUtil.colorOfString("#ff7d00"); if (type == 1) return SKUIUtil.colorOfString("#e792de"); } else if (relive == 2) { if (type == 0) return SKUIUtil.colorOfString("#7bfbff"); if (type == 1) return SKUIUtil.colorOfString("#a569f7"); } else if (relive == 3) { if (type == 0) return SKUIUtil.colorOfString("#de0421"); if (type == 1) return SKUIUtil.colorOfString("#292cef"); } else if (relive == 4) { if (type == 0) return SKUIUtil.colorOfString("#F05EE0"); if (type == 1) return SKUIUtil.colorOfString("#F05EE0"); } return cc.Color.BLACK; } /** * 打開隊伍面板中目标面板 */ public openTeamTargetPanel(targetList : {}, refresh : Boolean = false) { if (GameModel.player.mapid == 4004 || GameModel.player.mapid == 1213) { MsgAlert.addMsg("本地圖不可進行此操作") return } if (!this.teamTargetPanel || (this.teamTargetPanel && !this.teamTargetPanel.node && !SKUIUtil.isValid(this.teamTargetPanel.node))) { this.teamTargetPanel = FGUtil.create("main_ui", "team_target_panel"); FGUtil.root().addChild(this.teamTargetPanel); this.stopCocosNodeButton(this.teamTargetPanel); this.teamTargetPanel.makeFullScreen(); } // 清除所有目標按鈕 let listCom = FGUtil.getList(this.teamTargetPanel, "alert/taskList") listCom.removeChildrenToPool(); let customItem = listCom.addItemFromPool().asCom; customItem.getController("isCustom").selectedIndex = 1; // 玩家自定義目標名字 this.customTargetNameText = FGUtil.getTextField(customItem, "custom_group/custom_title"); this.customTargetNameText.text = this.targetCustomName; this.pushCloseEvent(customItem, this.teamTargetPanel, () => { listCom.removeChildrenToPool() if (this.recruitPanel && this.recruitPanel.node) { // 如果是發布招募面板 this.recruitPanelTeamTargetText.text = this.targetCustomName; } else if (this.teamTargetText.text != this.targetCustomName) { this.teamTargetText.text = this.targetCustomName; GameModel.send("c2s_issue_recruit", { roleid: GameModel.player.roleid, teamid: GameModel.player.teamid, datum: JSON.stringify({ type: "無目標", content: GameModel.player.teamInfo.content }) }) // GameModel.send("c2s_game_chat", { // scale: 1, // msg: `[${this.teamTargetText.text}@${GameModel.player.teamid}@9](${GameModel.player.teamInfo.teamcnt}/5)${GameModel.player.teamInfo.content}[join@${GameModel.player.teamid}@10]` // }) } }) // 自定義目標按鈕上的修改按鈕 FGUtil.getButton(customItem, "custom_group/modify_btn").onClick((eve) => { eve.stopPropagation();//防點擊穿透 this.openChangeTargetNameComponent(); }, this) var allTargetObj = JSON.parse(JSON.stringify(GameModel.game_conf.daily)); let allTargetList = []; for (let i in allTargetObj) { if (targetList[(parseInt(i) - 1).toString()]) allTargetObj[i].total -= targetList[(parseInt(i) - 1).toString()]; if (allTargetObj[i].total > 0) allTargetList.push(allTargetObj[i]) } // 未完成任務統計 FGUtil.getTextField(this.teamTargetPanel, "alert/taskNum").text = `未完成的任務(${allTargetList.length.toString()})`; for (let i = 0; i < allTargetList.length; i++) { let item = listCom.addItemFromPool().asCom; // 任務目標item初始化 FGUtil.getTextField(item, "title").text = allTargetList[i].name; this.pushCloseEvent(item, this.teamTargetPanel, () => { var str = FGUtil.getTextField(item, "custom_group/custom_title").text; listCom.removeChildrenToPool(); if (this.recruitPanel && this.recruitPanel.node) { this.recruitPanelTeamTargetText.text = str == "" ? FGUtil.getTextField(item, "title").text : str; //FGUtil.getControl(this.recruitPanel, "alert/target_race/need_screen_race").selectedIndex = i > 2 ? 1 : 0; } else { this.teamTargetText.text = str == "" ? FGUtil.getTextField(item, "title").text : str; GameModel.send("c2s_issue_recruit", { roleid: GameModel.player.roleid, teamid: GameModel.player.teamid, datum: JSON.stringify({ type: this.teamTargetText.text, content: GameModel.player.teamInfo.content }) }) // GameModel.send("c2s_game_chat", { // scale: 1, // msg: `[${this.teamTargetText.text}@${GameModel.player.teamid}@9](${GameModel.player.teamInfo.teamcnt}/5)${GameModel.player.teamInfo.content}[join@${GameModel.player.teamid}@10]` // }) } }) } if (refresh) return; // 遮罩關閉 this.pushCloseEvent(FGUtil.getComponent(this.teamTargetPanel, "mask"), this.teamTargetPanel, () => { listCom.removeChildrenToPool() }); GameModel.send('c2s_ask_daily_info', { roleid: GameModel.player.roleid, teamid: GameModel.player.teamid }); } /** * 打開修改自定義目標名字面板 */ openChangeTargetNameComponent() { if (!this.changeTargetNamePanel || (this.changeTargetNamePanel && !this.changeTargetNamePanel.node && !SKUIUtil.isValid(this.changeTargetNamePanel.node))) { this.changeTargetNamePanel = FGUtil.create("main_ui", "change_target_name_panel"); FGUtil.root().addChild(this.changeTargetNamePanel); this.stopCocosNodeButton(this.changeTargetNamePanel); this.changeTargetNamePanel.makeFullScreen(); } //輸入或清除按鈕 let input_clear_btn = FGUtil.getButton(this.changeTargetNamePanel, "alert/input_clear"); input_clear_btn.onClick(() => { if (customName.text.length == 0) { customName.requestFocus(); } else { customName.text = ""; input_clear_btn.getController("showClear").selectedIndex = 0; } }, this) //輸入框 var customName = FGUtil.getTextInput(this.changeTargetNamePanel, "alert/input"); customName.promptText = `[color=#CDA587]${this.targetCustomName}[/color]`; customName.on("text-changed", () => { if (customName.text.length > 0) { input_clear_btn.getController("showClear").selectedIndex = 1; } else { input_clear_btn.getController("showClear").selectedIndex = 0; } }, this) // 遮罩、取消和關閉按鈕 var mask = FGUtil.getComponent(this.changeTargetNamePanel, "mask"); var closeBtn = FGUtil.getButton(this.changeTargetNamePanel, "alert/close_btn"); var cancelBtn = FGUtil.getButton(this.changeTargetNamePanel, "alert/cancel_btn"); this.pushCloseEvent(mask, this.changeTargetNamePanel); this.pushCloseEvent(closeBtn, this.changeTargetNamePanel); this.pushCloseEvent(cancelBtn, this.changeTargetNamePanel); //確認按鈕 var sureBtn = FGUtil.getButton(this.changeTargetNamePanel, "alert/sure_btn"); this.pushCloseEvent(sureBtn, this.changeTargetNamePanel, () => { this.targetCustomName = customName.text.length > 0 ? customName.text : "無目標"; // this.teamTargetText.text = this.targetCustomName; this.customTargetNameText.text = this.targetCustomName; }); } /** * 打開招募面板 */ public openRecruitPanel() { if (GameModel.player.mapid == 4004 || GameModel.player.mapid == 1213) { MsgAlert.addMsg("本地圖不可進行此操作") return } if (!this.recruitPanel || (this.recruitPanel && !this.recruitPanel.node && !SKUIUtil.isValid(this.recruitPanel.node))) { this.recruitPanel = FGUtil.create("main_ui", "team_recruit_panel"); FGUtil.root().addChild(this.recruitPanel); this.stopCocosNodeButton(this.recruitPanel); this.recruitPanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.recruitPanel, "mask"); var close = FGUtil.getButton(this.recruitPanel, "alert/close_btn"); this.pushCloseEvent(mask, this.recruitPanel); this.pushCloseEvent(close, this.recruitPanel); var targetBtn = FGUtil.getButton(this.recruitPanel, "alert/target_race/target_btn"); var raceBtn = FGUtil.getButton(this.recruitPanel, "alert/target_race/race_btn"); targetBtn.onClick(() => { this.openTeamTargetPanel({}); var alert = FGUtil.getComponent(this.teamTargetPanel, "alert"); alert.x = 250; alert.y = 175; }, this); raceBtn.onClick(() => { this.openRacePanel(); }, this); // 隊伍目標 this.recruitPanelTeamTargetText = FGUtil.getTextField(this.recruitPanel, "alert/target_race/target_btn/title"); this.recruitPanelTeamTargetText.text = GameModel.player.teamInfo.type; if (GameModel.player.teamInfo.teamcnt > 1) { FGUtil.getTextField(this.recruitPanel, "alert/target_race/target_btn/number").text = `(${GameModel.player.teamInfo.teamcnt}/5)` } else { FGUtil.getComponent(this.recruitPanel, "alert/target_race/target_btn/number").text = ""; } // 字數提示 var tipLength = FGUtil.getTextField(this.recruitPanel, "alert/length_tip"); // 輸入框 var contentEdit = FGUtil.getTextInput(this.recruitPanel, "alert/content_edit"); contentEdit.on("text-changed", () => { tipLength.text = `共24字,還剩${24 - contentEdit.text.length}個字`; if (contentEdit.text.length > 0) { FGUtil.getControl(this.recruitPanel, "alert/showClear").selectedIndex = 1; } else { FGUtil.getControl(this.recruitPanel, "alert/showClear").selectedIndex = 0; } }, this) // 清除按鈕 var clearBtn = FGUtil.getButton(this.recruitPanel, "alert/clear_btn"); clearBtn.onClick(() => { contentEdit.text = "" tipLength.text = `共24字,還剩24個字`; FGUtil.getControl(this.recruitPanel, "alert/showClear").selectedIndex = 0; }, this) // 標籤組 var labelGroup = FGUtil.getComponent(this.recruitPanel, "alert/label_group"); for (let i = 1; i < 8; i++) { let item = FGUtil.getButton(labelGroup.asCom, `label${i}`); item.text = this.recruitLabelList[i - 1]; item.onClick(() => { if (item.text == "") return; var str = contentEdit.text == "" ? item.text : (contentEdit.text + ";" + item.text); if (str.length > 24) str = str.substring(0, 24) contentEdit.text = str; tipLength.text = `共24字,還剩${24 - contentEdit.text.length}個字`; }, this); } FGUtil.getButton(labelGroup.asCom, "edit_label_btn").onClick(() => { this.openEditLabelPanel(); }, this) // 發布按鈕 var publishBtn = FGUtil.getButton(this.recruitPanel, "alert/publish_btn"); this.pushCloseEvent(publishBtn, this.recruitPanel, () => { if (!GameModel.player.isleader) return if (this.teamRecruitText && this.teamRecruitText.node) { this.teamRecruitText.text = contentEdit.text } var recruinObj = { type: "", content: "" }; var typeStr = this.recruitPanelTeamTargetText.text; if (typeStr == this.targetCustomName || typeStr == "點擊選擇目標") recruinObj.type = "無目標" recruinObj.type = this.recruitPanelTeamTargetText.text == "點擊選擇目標" ? "無目標" : this.recruitPanelTeamTargetText.text recruinObj.content = contentEdit.text GameModel.send("c2s_issue_recruit", { roleid: GameModel.player.roleid, teamid: GameModel.player.teamid, datum: JSON.stringify(recruinObj) }) // GameModel.send("c2s_game_chat", { // scale: 1, // msg: `[${recruinObj.type}@${GameModel.player.teamid}@9](${GameModel.player.teamInfo.teamcnt}/5)${recruinObj.content}[join@${GameModel.player.teamid}@10]` // }) }) } /** * 生成種族面板 */ openRacePanel() { if (!this.racePanel || (this.racePanel && !this.racePanel.node && !SKUIUtil.isValid(this.racePanel.node))) { this.racePanel = FGUtil.create("main_ui", "race_panel"); FGUtil.root().addChild(this.racePanel); this.stopCocosNodeButton(this.racePanel); this.racePanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.racePanel, "mask"); this.pushCloseEvent(mask, this.racePanel, () => { var str = ""; for (var n in this.raceLimit) { if (this.raceLimit[n].getController("selected").selectedIndex == 1) { str = str + this.raceLimit[n].text + ";"; } } if (str != "" && this.recruitPanel && this.recruitPanel.node) { var raceText = FGUtil.getTextField(this.recruitPanel, "alert/target_race/race_btn/title"); raceText.text = str; } this.raceLimit = []; }) var allRaceBtn = FGUtil.getButton(this.racePanel, "alert/all_btn"); for (let i = 1; i <= 10; i++) { let item = FGUtil.getButton(this.racePanel, "alert/race" + i.toString()); item.onClick(() => { var select = item.getController("selected").selectedIndex; item.getController("selected").selectedIndex = select == 1 ? 0 : 1; }) this.raceLimit.push(item); } allRaceBtn.onClick(() => { if (allRaceBtn.getController("selected").selectedIndex == 0) { allRaceBtn.getController("selected").selectedIndex = 1; for (var n in this.raceLimit) { this.raceLimit[n].getController("selected").selectedIndex = 1; } } else { allRaceBtn.getController("selected").selectedIndex = 0; for (var n in this.raceLimit) { this.raceLimit[n].getController("selected").selectedIndex = 0; } } }, this) } /** * 生成編輯標籤面板 */ openEditLabelPanel() { if (!this.editLabelPanel || (this.editLabelPanel && !this.editLabelPanel.node && !SKUIUtil.isValid(this.editLabelPanel.node))) { this.editLabelPanel = FGUtil.create("main_ui", "edit_label_panel"); FGUtil.root().addChild(this.editLabelPanel); this.stopCocosNodeButton(this.editLabelPanel); this.editLabelPanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.editLabelPanel, "mask"); this.pushCloseEvent(mask, this.editLabelPanel); var list = FGUtil.getList(this.editLabelPanel, "alert/labelList"); for (let i = 0; i < 7; i++) { let item = list.getChildAt(i).asCom; item.getController("isCustom").selectedIndex = 1; FGUtil.getTextField(item, "custom_group/custom_title").text = this.recruitLabelList[i]; FGUtil.getButton(item, "custom_group/modify_btn").onClick(() => { this.openEditLabelInputPanel(i, FGUtil.getTextField(item, "custom_group/custom_title").text); }) } } /** * 生成編輯標籤輸入面板 */ openEditLabelInputPanel(index : number, defineText : string) { if (!this.changeTargetNamePanel || (this.changeTargetNamePanel && !this.changeTargetNamePanel.node && !SKUIUtil.isValid(this.changeTargetNamePanel.node))) { this.changeTargetNamePanel = FGUtil.create("main_ui", "change_target_name_panel"); FGUtil.root().addChild(this.changeTargetNamePanel); this.stopCocosNodeButton(this.changeTargetNamePanel); this.changeTargetNamePanel.makeFullScreen(); } FGUtil.getTextField(this.changeTargetNamePanel, "alert/title").text = "編輯招募標籤"; FGUtil.getTextField(this.changeTargetNamePanel, "alert/tip").text = "標籤最多6個字"; //輸入框 var customName = FGUtil.getTextInput(this.changeTargetNamePanel, "alert/input"); customName.maxLength = 6; //輸入或清除按鈕 let input_clear_btn = FGUtil.getButton(this.changeTargetNamePanel, "alert/input_clear"); customName.text = defineText; customName.on("text-changed", () => { if (customName.text.length > 0) { input_clear_btn.getController("showClear").selectedIndex = 1; } else { input_clear_btn.getController("showClear").selectedIndex = 0; } }, this) input_clear_btn.getController("showClear").selectedIndex = (customName.text.length == 0) ? 0 : 1; input_clear_btn.onClick(() => { if (customName.text.length == 0) { customName.requestFocus(); } else { customName.text = ""; input_clear_btn.getController("showClear").selectedIndex = 0; } }, this) // 遮罩、取消和關閉按鈕 var mask = FGUtil.getComponent(this.changeTargetNamePanel, "mask"); var closeBtn = FGUtil.getButton(this.changeTargetNamePanel, "alert/close_btn"); var cancelBtn = FGUtil.getButton(this.changeTargetNamePanel, "alert/cancel_btn"); this.pushCloseEvent(mask, this.changeTargetNamePanel); this.pushCloseEvent(closeBtn, this.changeTargetNamePanel); this.pushCloseEvent(cancelBtn, this.changeTargetNamePanel); //確認按鈕 var sureBtn = FGUtil.getButton(this.changeTargetNamePanel, "alert/sure_btn"); this.pushCloseEvent(sureBtn, this.changeTargetNamePanel, () => { this.refreshRecruitPanelLabel(index, customName.text); this.refreshEditLabelPanelLabel(index, customName.text); this.recruitLabelList[index] = customName.text; }); } /** * 刷新組隊招募面板編輯標籤 */ refreshEditLabelPanelLabel(index : number, labelStr : string) { if (!this.editLabelPanel || !this.editLabelPanel.node) { console.warn("找不到‘edit_label_panel’"); return; } var list = FGUtil.getList(this.editLabelPanel, "alert/labelList"); FGUtil.getTextField(list.getChildAt(index).asCom, "custom_group/custom_title").text = labelStr; } /** * 刷新組隊招募面板標籤 */ refreshRecruitPanelLabel(index : number, labelStr : string) { if (!this.recruitPanel || !this.recruitPanel.node) { console.warn("找不到‘team_recruit_panel’"); return; } FGUtil.getButton(this.recruitPanel, `alert/label_group/label${index - 1}`).text = labelStr; } /** * 打開組隊大廳面板 */ public openMatchHallPanel(targetList : any = {}, refreshTargetList : Boolean = false, teamList : any = [], refreshTeamList : Boolean = false) { if (GameModel.player.mapid == 4004 || GameModel.player.mapid == 1213) { MsgAlert.addMsg("本地圖不可進行此操作") return } if (!this.matchHallPanel || (this.matchHallPanel && !this.matchHallPanel.node && !SKUIUtil.isValid(this.matchHallPanel.node))) { this.matchHallPanel = FGUtil.create("main_ui", "match_hall_panel"); FGUtil.root().addChild(this.matchHallPanel); this.stopCocosNodeButton(this.matchHallPanel); this.matchHallPanel.makeFullScreen(); this.taskTargetItemList = []; } var mask = FGUtil.getComponent(this.matchHallPanel, "mask"); var close = FGUtil.getButton(this.matchHallPanel, "alert/closeBtn"); this.pushCloseEvent(mask, this.matchHallPanel); this.pushCloseEvent(close, this.matchHallPanel); if (refreshTargetList) { this.taskTargetItemList = []; let taskTargetList = FGUtil.getList(this.matchHallPanel, "alert/target_list"); taskTargetList.removeChildrenToPool(); let item = taskTargetList.addItemFromPool().asCom; item.clearClick(); this.taskTargetItemList.push(item); item.text = "無目標"; item.getController("selected").selectedIndex = 1; item.onClick(() => { for (let i = 0; i < this.taskTargetItemList.length; i++) { if (i == 0) { this.taskTargetItemList[0].getController("selected").selectedIndex = 1; continue; } this.taskTargetItemList[i].getController("selected").selectedIndex = 0; } this.teamListType = "無目標"; GameModel.send('c2s_hall_list', { roleid: GameModel.player.roleid, type: "無目標" }); this.getTeamList(); }) // 顯示全部任務 if (FGUtil.getControl(this.matchHallPanel, "alert/show_over_task/selected").selectedIndex == 1) { var allTargetObj = JSON.parse(JSON.stringify(GameModel.game_conf.daily)); let listArr = []; let taskTargetList = FGUtil.getList(this.matchHallPanel, "alert/target_list"); for (let i in allTargetObj) { listArr.push(allTargetObj[i]) } for (let i in listArr) { let item = taskTargetList.addItemFromPool().asCom; item.getController("selected").selectedIndex = 0; item.clearClick(); this.taskTargetItemList.push(item); item.onClick(() => { for (let j = 0; j < this.taskTargetItemList.length; j++) { if (j == parseInt(i) + 1) { this.taskTargetItemList[j].getController("selected").selectedIndex = 1; continue; } this.taskTargetItemList[j].getController("selected").selectedIndex = 0; } this.teamListType = listArr[i].name; GameModel.send('c2s_hall_list', { roleid: GameModel.player.roleid, type: listArr[i].name }); this.getTeamList(); }) } } else { // 只顯示未完成任務 var allTargetObj = JSON.parse(JSON.stringify(GameModel.game_conf.daily)); let unOverTargetList = []; for (let i in allTargetObj) { if (targetList[(parseInt(i) - 1).toString()]) allTargetObj[i].total -= targetList[(parseInt(i) - 1).toString()]; if (allTargetObj[i].total > 0) unOverTargetList.push(allTargetObj[i]) } for (let n in unOverTargetList) { let item = taskTargetList.addItemFromPool().asCom; item.getController("selected").selectedIndex = 0; item.clearClick(); item.text = unOverTargetList[n].name; this.taskTargetItemList.push(item); item.onClick(() => { for (let j = 0; j < this.taskTargetItemList.length; j++) { if (j == parseInt(n) + 1) { this.taskTargetItemList[j].getController("selected").selectedIndex = 1; continue; } this.taskTargetItemList[j].getController("selected").selectedIndex = 0; } this.teamListType = unOverTargetList[n].name; GameModel.send('c2s_hall_list', { roleid: GameModel.player.roleid, type: unOverTargetList[n].name }); this.getTeamList(); }) } } } if (refreshTeamList) { this.getTeamList(teamList) } if (refreshTargetList || refreshTeamList) return; FGUtil.getComponent(this.matchHallPanel, "alert/refresh").onClick(() => { GameModel.send('c2s_hall_list', { roleid: GameModel.player.roleid, type: this.teamListType }); // for (let i in this.taskTargetItemList) { // if (this.taskTargetItemList[i].getController("selected").selectedIndex == 1) { // console.log(`刷新第${i}項列表`) // this.getTeamList(); // return // } // } }, this) FGUtil.getComponent(this.matchHallPanel, "alert/edit_recruit").onClick(() => { this.openRecruitPanel(); }, this) FGUtil.getComponent(this.matchHallPanel, "alert/one_key").onClick(() => { console.log("一鍵申請") }, this) FGUtil.getComponent(this.matchHallPanel, "alert/eazy_match").onClick(() => { if (this.isMatching) this.openTeamAutoMatchPanel(); else this.openTeamMatchPanel(); }, this) FGUtil.getComponent(this.matchHallPanel, "alert/show_over_task").onClick(() => { var btn = FGUtil.getComponent(this.matchHallPanel, "alert/show_over_task") if (btn.getController("selected").selectedIndex == 1) btn.getController("selected").selectedIndex = 0; else btn.getController("selected").selectedIndex = 1; GameModel.send('c2s_ask_daily_info', { roleid: GameModel.player.roleid, teamid: GameModel.player.teamid }); GameModel.send('c2s_hall_list', { roleid: GameModel.player.roleid, type: "無目標" }); }, this) GameModel.send('c2s_hall_list', { roleid: GameModel.player.roleid, type: "無目標" }); GameModel.send('c2s_ask_daily_info', { roleid: GameModel.player.roleid, teamid: GameModel.player.teamid }); } /** * 獲取隊伍列表 */ getTeamList(listData : any = []) { var num = listData.length; if (num == 0) { console.log("沒有隊伍") FGUtil.getControl(this.matchHallPanel, "alert/noTeam").selectedIndex = 1; } else { let list = FGUtil.getList(this.matchHallPanel, "alert/team_list"); list.removeChildrenToPool(); FGUtil.getControl(this.matchHallPanel, "alert/noTeam").selectedIndex = 0; for (let i = 0; i < num; i++) { console.log(listData[i]) // 是隊長且已經加入此隊伍 if (this.isLeader && listData[i].teamid == this.teamId) continue; let item = list.addItemFromPool().asCom; // 隊長頭像 FGUtil.getLoader(item, "leader/icon").texture = GameModel.getRoleHead(listData[i].resid) // 隊員頭像 let membersList = FGUtil.getComponent(item, "team_list"); var m = 1; var members = JSON.parse(listData[i].teamMembers) for (let key in members) { if (members[key] == listData[i].resid) continue; FGUtil.getLoader(membersList, `m${m}/icon`).texture = GameModel.getRoleHead(members[key]); m++; } FGUtil.getButton(item, "join_btn").clearClick(); if (listData[i].teamid == this.teamId) { // 不是隊長但是已經加入此隊伍 FGUtil.getTextField(item, "join_btn/title").text = "已加入"; } else { // 沒有加入此隊伍 FGUtil.getTextField(item, "join_btn/title").text = "加入"; FGUtil.getButton(item, "join_btn").onClick(() => { GameModel.send('c2s_requst_team', { roleid: GameModel.player.roleid, teamid: listData[i].teamid }); }) } } } } /** * 打開自動匹配面板 */ openTeamAutoMatchPanel() { if (!this.autoMatchPanel || (this.autoMatchPanel && !this.autoMatchPanel.node && !SKUIUtil.isValid(this.autoMatchPanel.node))) { this.autoMatchPanel = FGUtil.create("main_ui", "team_automatch_panel"); FGUtil.root().addChild(this.autoMatchPanel); this.stopCocosNodeButton(this.autoMatchPanel); this.autoMatchPanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.autoMatchPanel, "mask"); var close = FGUtil.getButton(this.autoMatchPanel, "alert/close"); this.pushCloseEvent(mask, this.autoMatchPanel); this.pushCloseEvent(close, this.autoMatchPanel); } /** * 打開隊伍匹配面板 */ openTeamMatchPanel() { if (!this.teamMatchPanel || (this.teamMatchPanel && !this.teamMatchPanel.node && !SKUIUtil.isValid(this.teamMatchPanel.node))) { this.teamMatchPanel = FGUtil.create("main_ui", "team_match_panel"); FGUtil.root().addChild(this.teamMatchPanel); this.stopCocosNodeButton(this.teamMatchPanel); this.teamMatchPanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.teamMatchPanel, "mask"); var close = FGUtil.getButton(this.teamMatchPanel, "alert/close_btn"); this.pushCloseEvent(mask, this.teamMatchPanel); this.pushCloseEvent(close, this.teamMatchPanel); var typeList = FGUtil.getList(this.teamMatchPanel, "alert/type_list"); var typeNameArr = ["日常活動", "日常副本", "限時活動"]; for (let i = 0; i < 3; i++) { var item = typeList.addItemFromPool().asCom item.getController("hideArrow").selectedIndex = 1; item.text = typeNameArr[i] item.onClick(() => { this.getTaskList(i); }, this) } var allMatchBtn = FGUtil.getComponent(this.teamMatchPanel, "alert/n52"); allMatchBtn.asButton.onClick(() => { FGUtil.getControl(allMatchBtn, "selected").selectedIndex = FGUtil.getControl(allMatchBtn, "selected").selectedIndex == 1 ? 0 : 1; }) var beLeader = FGUtil.getComponent(this.teamMatchPanel, "alert/n53"); FGUtil.getControl(beLeader, "selected").selectedIndex = this.matchTeamLimit.beLeader ? 1 : 0 beLeader.asButton.onClick(() => { var control = FGUtil.getControl(beLeader, "selected"); if (control.selectedIndex == 1) { control.selectedIndex = 0; this.matchTeamLimit.beLeader = false; } else { control.selectedIndex = 1; this.matchTeamLimit.beLeader = true; } }) FGUtil.getButton(this.teamMatchPanel, "alert/set_level").onClick(() => { this.openSelectLevelPanel(); }, this) FGUtil.getButton(this.teamMatchPanel, "alert/publish_btn").onClick(() => { console.log(this.matchTeamLimit) this.isMatching = true; }, this) this.getTaskList(0); } /** * 獲取任務列表 */ getTaskList(idx) { var num = this.matchTaskLimit[idx].length; var list = FGUtil.getList(this.teamMatchPanel, "alert/target_list"); list.removeChildrenToPool(); for (let i = 0; i < num; i++) { let item = list.addItemFromPool().asCom; FGUtil.getTextField(item, "title").text = this.matchTaskLimit[idx][i].name; if (this.matchTeamLimit.target[FGUtil.getTextField(item, "title").text]) FGUtil.getControl(item, "selected_btn/selected").selectedIndex = 1; else FGUtil.getControl(item, "selected_btn/selected").selectedIndex = 0; // 無條件只顯示名字 if (this.matchTaskLimit[idx][i].type == 1) FGUtil.getControl(item, "type").selectedIndex = 1; else if (this.matchTaskLimit[idx][i].type == 2) { // 滿次和無條件 FGUtil.getControl(item, "type").selectedIndex = 0; if (this.matchTaskLimit[idx][i].all == 0) FGUtil.getTextField(item, "limit").text = "無條件"; else FGUtil.getTextField(item, "limit").text = "滿次"; } else { FGUtil.getControl(item, "type").selectedIndex = 0; FGUtil.getTextField(item, "limit").text = `${this.matchTaskLimit[idx][i].setStart}${this.matchTaskLimit[idx][i].unit} - ${this.matchTaskLimit[idx][i].setEnd}${this.matchTaskLimit[idx][i].unit}` } item.clearClick(); item.onClick(() => { var con = FGUtil.getControl(item, "selected_btn/selected") if (con.selectedIndex == 0) { var temp = {} if (this.matchTaskLimit[idx][i].type == 2) { temp = { all: this.matchTaskLimit[idx][i].all } } else if (this.matchTaskLimit[idx][i].type == 0) { temp = { setStart: this.matchTaskLimit[idx][i].setStart, setEnd: this.matchTaskLimit[idx][i].setEnd, } } this.matchTeamLimit.target[FGUtil.getTextField(item, "title").text] = temp; con.selectedIndex = 1; } else { delete this.matchTeamLimit.target[FGUtil.getTextField(item, "title").text] con.selectedIndex = 0; } }, this) FGUtil.getButton(item, "edit_btn").clearClick() FGUtil.getButton(item, "edit_btn").onClick((eve) => { eve.stopPropagation(); if (this.matchTaskLimit[idx][i].type == 0) this.openTargetRangePanel(this.matchTaskLimit[idx][i], item); }) } } /** * 打開目標範圍面板 */ openTargetRangePanel(info, obj) { if (!this.targetRangePanel || (this.targetRangePanel && !this.targetRangePanel.node && !SKUIUtil.isValid(this.targetRangePanel.node))) { this.targetRangePanel = FGUtil.create("main_ui", "target_range_panel"); FGUtil.root().addChild(this.targetRangePanel); this.stopCocosNodeButton(this.targetRangePanel); this.targetRangePanel.makeFullScreen(); this.targetStartRangeList = []; this.targetEndRangeList = []; } var mask = FGUtil.getComponent(this.targetRangePanel, "mask"); this.pushCloseEvent(mask, this.targetRangePanel); let startList = FGUtil.getList(this.targetRangePanel, "alert/start_list"); let endList = FGUtil.getList(this.targetRangePanel, "alert/end_list"); startList.removeChildrenToPool(); endList.removeChildrenToPool(); for (let i = info.start; i <= info.end; i++) { let sitem = startList.addItemFromPool().asCom; this.targetStartRangeList.push(sitem); if (i == info.setStart) FGUtil.getControl(sitem, "selected").selectedIndex = 1; sitem.clearClick() sitem.text = i.toString() + info.unit; sitem.onClick(() => { if (i > info.setEnd) return this.changeUnSelectedState(this.targetStartRangeList); FGUtil.getControl(sitem, "selected").selectedIndex = 1; info.setStart = i; FGUtil.getTextField(obj, "limit").text = `${info.setStart}${info.unit} - ${info.setEnd}${info.unit}` if (this.matchTeamLimit.target[info.name]) { this.matchTeamLimit.target[info.name].setStart = info.setStart } console.log(this.matchTeamLimit) }) let eitem = endList.addItemFromPool().asCom; this.targetEndRangeList.push(eitem); if (i == info.setEnd) FGUtil.getControl(eitem, "selected").selectedIndex = 1; eitem.clearClick() eitem.text = i.toString() + info.unit; eitem.onClick(() => { if (i < info.setStart) return this.changeUnSelectedState(this.targetEndRangeList); FGUtil.getControl(eitem, "selected").selectedIndex = 1; info.setEnd = i; FGUtil.getTextField(obj, "limit").text = `${info.setStart}${info.unit} - ${info.setEnd}${info.unit}` if (this.matchTeamLimit.target[info.name]) { this.matchTeamLimit.target[info.name].setEnd = info.setEnd } console.log(this.matchTeamLimit) }) } } /** * 關閉所有選擇狀態 */ changeUnSelectedState(list) { for (let i in list) { FGUtil.getControl(list[i], "selected").selectedIndex = 0 } } /** * 打開選擇等級面板 */ openSelectLevelPanel() { if (!this.selectLevelPanel || (this.selectLevelPanel && !this.selectLevelPanel.node && !SKUIUtil.isValid(this.selectLevelPanel.node))) { this.selectLevelPanel = FGUtil.create("main_ui", "team_grade_select_panel"); FGUtil.root().addChild(this.selectLevelPanel); this.stopCocosNodeButton(this.selectLevelPanel); this.selectLevelPanel.makeFullScreen(); } var mask = FGUtil.getComponent(this.selectLevelPanel, "mask"); this.pushCloseEvent(mask, this.selectLevelPanel, () => { var str = FGUtil.getButton(this.selectLevelPanel, "alert/start_zhuan_btn").text + FGUtil.getButton(this.selectLevelPanel, "alert/start_level_btn").text + " - " + FGUtil.getButton(this.selectLevelPanel, "alert/end_zhuan_btn").text + FGUtil.getButton(this.selectLevelPanel, "alert/end_level_btn").text FGUtil.getTextField(this.teamMatchPanel, "alert/set_level/targetName").text = str; this.matchTeamLimit.level["startZhuan"] = FGUtil.getButton(this.selectLevelPanel, "alert/start_zhuan_btn").text; this.matchTeamLimit.level["startLevel"] = FGUtil.getButton(this.selectLevelPanel, "alert/start_level_btn").text; this.matchTeamLimit.level["endZhuan"] = FGUtil.getButton(this.selectLevelPanel, "alert/end_zhuan_btn").text; this.matchTeamLimit.level["endLevel"] = FGUtil.getButton(this.selectLevelPanel, "alert/end_level_btn").text; FGUtil.getList(this.selectLevelPanel, "n2/list").removeChildrenToPool(); }); var allLevelBtn = FGUtil.getButton(this.selectLevelPanel, "alert/all_level"); allLevelBtn.onClick(() => { FGUtil.getButton(this.selectLevelPanel, "alert/start_zhuan_btn").text = "0轉"; FGUtil.getButton(this.selectLevelPanel, "alert/start_level_btn").text = "0級"; FGUtil.getButton(this.selectLevelPanel, "alert/end_zhuan_btn").text = "3轉"; FGUtil.getButton(this.selectLevelPanel, "alert/end_level_btn").text = "180級"; FGUtil.getComponent(this.selectLevelPanel, "n2").visible = false; FGUtil.getList(this.selectLevelPanel, "n2/list").removeChildrenToPool(); }, this) FGUtil.getButton(this.selectLevelPanel, "alert/start_zhuan_btn").text = this.matchTeamLimit.level["startZhuan"]; FGUtil.getButton(this.selectLevelPanel, "alert/start_zhuan_btn").onClick(() => { FGUtil.getComponent(this.selectLevelPanel, "n2").visible = true; var list = FGUtil.getList(this.selectLevelPanel, "n2/list"); for (let i = 0; i < 4; i++) { let item = list.addItemFromPool().asCom; item.clearClick(); item.text = i.toString() + "轉"; item.onClick(() => { FGUtil.getButton(this.selectLevelPanel, "alert/start_zhuan_btn").text = i.toString() + "轉"; FGUtil.getComponent(this.selectLevelPanel, "n2").visible = false; FGUtil.getList(this.selectLevelPanel, "n2/list").removeChildrenToPool(); }, this) } }, this) FGUtil.getButton(this.selectLevelPanel, "alert/end_zhuan_btn").text = this.matchTeamLimit.level["endZhuan"]; FGUtil.getButton(this.selectLevelPanel, "alert/end_zhuan_btn").onClick(() => { FGUtil.getComponent(this.selectLevelPanel, "n2").visible = true; var list = FGUtil.getList(this.selectLevelPanel, "n2/list"); for (let i = 0; i < 4; i++) { let item = list.addItemFromPool().asCom; item.clearClick(); item.text = i.toString() + "轉"; item.onClick(() => { FGUtil.getButton(this.selectLevelPanel, "alert/end_zhuan_btn").text = i.toString() + "轉"; FGUtil.getComponent(this.selectLevelPanel, "n2").visible = false; FGUtil.getList(this.selectLevelPanel, "n2/list").removeChildrenToPool(); }, this) } }, this) FGUtil.getButton(this.selectLevelPanel, "alert/start_level_btn").text = this.matchTeamLimit.level["startLevel"]; FGUtil.getButton(this.selectLevelPanel, "alert/start_level_btn").onClick(() => { FGUtil.getComponent(this.selectLevelPanel, "n2").visible = true; var list = FGUtil.getList(this.selectLevelPanel, "n2/list"); for (let i = 0; i < 19; i++) { let item = list.addItemFromPool().asCom; item.clearClick(); item.text = (i * 10).toString() + "級"; item.onClick(() => { FGUtil.getButton(this.selectLevelPanel, "alert/start_level_btn").text = (i * 10).toString() + "級"; FGUtil.getComponent(this.selectLevelPanel, "n2").visible = false; FGUtil.getList(this.selectLevelPanel, "n2/list").removeChildrenToPool(); }, this) } }, this) FGUtil.getButton(this.selectLevelPanel, "alert/end_level_btn").text = this.matchTeamLimit.level["endLevel"]; FGUtil.getButton(this.selectLevelPanel, "alert/end_level_btn").onClick(() => { FGUtil.getComponent(this.selectLevelPanel, "n2").visible = true; var list = FGUtil.getList(this.selectLevelPanel, "n2/list"); for (let i = 0; i < 19; i++) { let item = list.addItemFromPool().asCom; item.clearClick(); item.text = (i * 10).toString() + "級"; item.onClick(() => { FGUtil.getButton(this.selectLevelPanel, "alert/end_level_btn").text = (i * 10).toString() + "級"; FGUtil.getComponent(this.selectLevelPanel, "n2").visible = false; FGUtil.getList(this.selectLevelPanel, "n2/list").removeChildrenToPool(); }, this) } }, this) } /** * 創建添加預製體 * @param parent 父節點 * @param pos 位置 * @param prefabName 預製體名稱 * @param nodeName 節點名稱 * @returns */ createPrefab(parent : cc.Node, pos : any, prefabName : string, nodeName : string) : cc.Node { if (!this.prefabObject[prefabName]) { console.warn("沒有找到預製體————" + prefabName); return; } let Item = cc.instantiate(this.prefabObject[prefabName]); Item.parent = parent; Item.name = nodeName; Item.setPosition(cc.v2(pos.x, pos.y)); return Item; } /** * 確認彈框 * @param text * @param cancelBlock * @param sureBlock */ private showAlert(text : string, cancelBlock : () => void, sureBlock : () => void) { if (!this.alertPanel || (this.alertPanel && !this.alertPanel.node && !SKUIUtil.isValid(this.alertPanel.node))) { this.alertPanel = FGUtil.create("main_ui", "alert_main"); FGUtil.root().addChild(this.alertPanel); this.stopCocosNodeButton(this.alertPanel); } let alert = FGUtil.getComponent(this.alertPanel, "alert"); var title = FGUtil.getTextField(alert, "title"); var cancelBtn = FGUtil.getButton(alert, "cancel_btn"); this.pushCloseEvent(cancelBtn, this.alertPanel, cancelBlock); var sureBtn = FGUtil.getButton(alert, "sure_btn") this.pushCloseEvent(sureBtn, this.alertPanel, sureBlock); var progressBar = FGUtil.getProgressBar(alert, "progress"); cancelBtn.visible = true; sureBtn.visible = true; progressBar.visible = false; let root = FGUtil.root(); if (root) { title.text = text; root.addChild(this.alertPanel); FGUtil.fitScreen(this.alertPanel); } } /** * 添加關閉事件 */ pushCloseEvent(item : fairygui.GComponent, target : fairygui.GComponent, call : Function = null) { item.clearClick(); item.onClick(() => { call && call() FGUtil.dispose(target); this.recoveryCocosNodeButton(); this.unscheduleAllCallbacks() }, this) } /** * 停止隊員的原生button相應 */ private stopCocosNodeButton(item : fairygui.GComponent) { if (this.popList == null) this.popList = []; this.popList.push(item) try { var list = this.teamPanel.node.getChildByName("team_member_node").children; if (list.length > 1) { for (let i in list) { list[i].getComponent(cc.Button).interactable = false; // console.log(cc.find("normal/petIcon", list[i])) if (list[i].name == "goPartnerCard_1") cc.find("normal/petIcon", list[i]).getComponent(cc.Button).interactable = false; } // console.log("不可點擊") } } catch (err) { console.warn(err) } } /** * 恢復隊員的原生button相應 */ private recoveryCocosNodeButton() { this.popList.pop(); if (this.popList.length > 1) return; try { if (this.teamPanel && this.teamPanel.node) { var list = this.teamPanel.node.getChildByName("team_member_node").children; if (list.length > 1) { for (let i in list) { list[i].getComponent(cc.Button).interactable = true; if (list[i].name == "goPartnerCard_1") cc.find("normal/petIcon", list[i]).getComponent(cc.Button).interactable = true; } // console.log("可點擊") } } } catch (err) { console.warn(err) } } }