const WeaveWidth = 320; const WeaveSingleWidth = 140; cc.Class({ extends: cc.Component, properties: { m_tipChi: cc.Node, m_tipPeng: cc.Node, m_tipGang: cc.Node, m_tipGangBu: cc.Node, m_tipHaiDi: cc.Node, m_tipHu: cc.Node, m_tipMenHu: cc.Node, m_tipTing: cc.Node, m_tipGuo: cc.Node, m_WeaveCardPrefab: cc.Node, m_WeaveCardItem: cc.Prefab, m_bgChi : cc.Node, }, // use this for initialization onLoad: function () { if (this.bLoad == false) { this.m_tipChi.active = false; this.m_tipPeng.active = false; this.m_tipGang.active = false; this.m_tipGangBu.active = false; this.m_tipHaiDi.active = false; this.m_tipHu.active = false; this.m_tipMenHu.active = false; this.m_tipTing.active = false; // this.m_tipDanHu.active = false; this.m_tipGuo.active = false; this.WeaveCard = this.m_WeaveCardPrefab.getComponent('WeaveItem'); this.WeaveCard.BuildCard(GameDef.HAND_BOTTOM, this.m_WeaveCardItem); this.WeaveCard.SetCardItemColor(); this.WeaveCard.m_bSelfCard = true; this.WeaveCard.m_bDisplayItem = true; this.bLoad = true; this.node.width = WeaveSingleWidth; this.node.height = 120; } }, ctor: function () { //this.WeaveCard = null; this.bLoad = false; this._resetOperateData(); this.cbExtraCount = new Array(); this.isChi = false; //this.m_bgChi.active =false; }, _resetOperateData() { this.wOperateCode = 0; this.cbWeaveCardData = []; }, SetWeaveInfo: function (pCtrl, WeaveInfo, index) { this._resetOperateData(); this.pCtrl = pCtrl; this.isChi = false; GameDef.g_GameEngine.m_GameClientView.m_CardView.ChangeCardBack(this.node, GameDef.g_GameEngine.m_CardBack); this.cbCardCont = WeaveInfo.cbCardCount; // cc.error("SetWeaveInfo ", WeaveInfo, index, this.wOperateCode, this.cbWeaveCardData); this.wOperateCode = WeaveInfo.wWeaveKind; if (this.bLoad == false) this.onLoad(); this.m_bgChi.active = false; this.m_tipChi.active = false; this.m_tipPeng.active = false; this.m_tipGang.active = false; this.m_tipGangBu.active = false; this.m_tipHaiDi.active = false; this.m_tipHu.active = false; this.m_tipMenHu.active = false; this.m_tipTing.active = false; // this.m_tipDanHu.active = false; this.m_tipGuo.active = false; let WeaveCardStatus = true; let aniNode = null; let aniName = null; switch (this.wOperateCode) { case GameDef.WIK_NULL: { this.m_tipGuo.active = true; WeaveCardStatus = false; aniNode = this.m_tipChi.getComponent("SpineAnimationCtrl"); aniName = ["qi_loop"]; this.node.width = 100; this.node.height = 120; break; } case GameDef.WIK_LEFT: case GameDef.WIK_CENTER: case GameDef.WIK_RIGHT: case GameDef.WIK_CAI_ZFB: { // if (this.pCtrl.chiCount < 1) { // this.m_tipChi.active = true; // } else { // this.node.active = false; // } this.m_tipChi.active = true; this.pCtrl.WeaveChies[this.pCtrl.chiCount] = this; this.pCtrl.chiCount++; this.isChi = true; aniNode = this.m_tipChi.getComponent("SpineAnimationCtrl"); aniName = ["chi_in", "chi_loop"]; break; } case GameDef.WIK_PENG: { this.m_tipPeng.active = true; aniNode = this.m_tipPeng.getComponent("SpineAnimationCtrl"); aniName = ["peng_in", "peng_loop"]; break; } case GameDef.WIK_GANG: case GameDef.WIK_GANG_XI: case GameDef.WIK_ADD_ZFB: { this.m_tipGang.active = true; aniNode = this.m_tipGang.getComponent("SpineAnimationCtrl"); aniName = ["gang_loop"]; break; } case GameDef.WIK_GANG_BU: { this.m_tipGangBu.active = true; aniNode = this.m_tipGangBu.getComponent("SpineAnimationCtrl"); aniName = ["gang_loop"]; break; } case GameDef.WIK_HAI_DI: { this.m_tipHaiDi.active = true; WeaveCardStatus = false; break; } case GameDef.WIK_JIA_HU: case GameDef.WIK_CHI_HU: { this.m_tipHu.active = true; WeaveCardStatus = false; aniNode = this.m_tipHu.getComponent("SpineAnimationCtrl"); aniName = ["hu_in", "hu_loop"]; break; } case GameDef.WIK_MEN_HU: { this.m_tipMenHu.active = true; WeaveCardStatus = false; break; } case GameDef.WIK_LISTEN: { this.m_tipTing.active = true; WeaveCardStatus = false; break; } } if (!!aniNode && !!aniName) { if (1 == aniName.length) { aniNode.playAnimation(aniName[0], true); } else { aniNode.playAnimation(aniName[0], false, false, aniName[1], true); } } let isPengGang = this.wOperateCode == GameDef.WIK_GANG && 1 == WeaveInfo.cbCardCount; if (typeof (WeaveInfo) != 'number') { for (var i = 0; i < 4; i++) { WeaveInfo.cbCardData[i] = (WeaveInfo.cbCardCount > i) ? WeaveInfo.cbCardData[i] : 0; this.cbWeaveCardData[i] = WeaveInfo.cbCardData[i]; if (isPengGang) { WeaveInfo.cbCardData[i] = WeaveInfo.cbCardData[0]; WeaveInfo.cbCardCount = 4; } if (WeaveInfo.cbExtraCount != null) this.cbExtraCount[i] = WeaveInfo.cbExtraCount[i]; } this.WeaveCard.SetWeaveData(WeaveInfo.cbCardData, WeaveInfo.cbCardCount, INVALID_CHAIR, true); this.WeaveCard.SetWeaveState(WeaveInfo); this.WeaveCard.SetWeaveNumber(WeaveInfo.cbExtraCount); // WeaveCardStatus = false; } else { WeaveCardStatus = false; } this.WeaveCard.node.active = WeaveCardStatus; this.onWeaveCardResize(WeaveCardStatus); }, subClickBtn: function () { if (this.wOperateCode == GameDef.WIK_GANG_XI) { for (var i = 0; i < 4; i++) { if (this.cbExtraCount[i] > 0) { this.cbWeaveCardData[3] = 0x35 + i; break; } } this.cbCardCont = 4; } if (this.isChi == false) { this.pCtrl.subClickBtn(this.wOperateCode, this.cbWeaveCardData, this.cbCardCont); } else { if (this.WeaveCard.node.active) { this.pCtrl.subClickBtn(this.wOperateCode, this.cbWeaveCardData, this.cbCardCont); } else { for (var i = 0; i < this.pCtrl.WeaveCtrl.length; ++i) { this.pCtrl.WeaveCtrl[i].node.active = false; } for (let index = 0; index < this.pCtrl.chiCount; index++) { this.pCtrl.WeaveChies[index].node.active = true; this.pCtrl.WeaveChies[index].WeaveCard.node.active = true; this.pCtrl.WeaveChies[index].onWeaveCardResize(true); this.pCtrl.WeaveChies[index].m_tipChi.active = true; this.pCtrl.WeaveChies[index].m_bgChi.active = true; } } } this._resetOperateData(); }, // called every frame, uncomment this function to activate update callback // update: function (dt) { // }, onWeaveCardResize(status) { this.node.width = status ? WeaveWidth : WeaveSingleWidth; this.m_bgChi.width = status ? WeaveWidth : WeaveSingleWidth; }, });