cc.Class({ extends: cc.Component, properties: { m_UserScore: cc.Label, m_Ready: cc.Node, m_Zhuang: cc.Node, m_LeaveHead: cc.Node, m_Gang: cc.Label, m_CurEffect: cc.Node, m_Ting: cc.Node, m_Trustee: cc.Node, m_Score: cc.Label, m_Flower: cc.Node, m_FlowerNumber: cc.Label, m_Flowercard: cc.Node, m_FlowerLayout: cc.Node, m_Feng: cc.Label, m_Flowerbg3: cc.SpriteFrame, m_playingNode: cc.Node, m_Diamond: cc.Node, }, ctor: function () { this.m_lScore = 0; }, start: function () { }, Init: function (View, Chair) { this.m_UserCtrl = this.node.getComponent('UserCtrl'); this.m_Hook = View; this.m_ChairID = Chair; this.m_Gang.node.active = false; this.m_Ting.active = false; this.m_Trustee.active = false; this.m_Score.node.active = false; this.node.active = false; this.m_Flower.active = false; this.Reset(); }, Reset: function () { this.m_Ready.active = false; this.m_LeaveHead.active = false; this.m_Zhuang.active = false; this.m_Gang.node.active = false; this.m_Ting.active = false; this.m_Trustee.active = false; this.m_Score.node.active = false; this.node.active = false; //初始不显示头像 this.m_Flower.active = false; this.m_Flowercard.active = false; for (let i = 0; i < this.m_FlowerLayout.childrenCount; i++) { this.m_FlowerLayout.children[i].active = false; } this.m_Feng.string = ""; this.m_playingNode.active = false; this.m_Diamond.active = false; }, SetReady: function (show) { if (this.m_ChairID == 3) { this.m_Ready.setPosition(-100, 0); } if (this.m_ChairID == 0) { this.m_Ready.setPosition(-100, 0); } this.m_Ready.active = show; }, SetUserItem: function (pUserItem) { this.m_dwUserID = pUserItem.GetUserID(); this.m_pUserItem = pUserItem; this.node.getComponent('UserCtrl').SetUserByID(this.m_dwUserID); this.node.getComponent('UserCtrl').SetShowFullName(false, 5); console.log("设置SetUserItem", GameDef.m_dwGameRuleArr) if (GameDef.m_dwGameRuleArr&&GameDef.m_dwGameRuleArr[3] > 0) { this.getUserMedal(); } //this.SetUserScore(pUserItem.GetUserScore()); }, //初始化花牌 ClearFlower: function (display) { this.m_Flower.active = display; this.m_FlowerNumber.string = '×0'; for (let i = 0; i < this.m_FlowerLayout.childrenCount; i++) { this.m_FlowerLayout.children[i].active = false; } }, UserLeave: function (pUserItem) { if (pUserItem.GetUserID() == this.m_dwUserID) { this.m_dwUserID = 0; this.node.getComponent('UserCtrl').SetUserByID(this.m_dwUserID); this.m_UserScore.string = ''; this.Reset(); } }, //点击花 OnClickFlower: function () { let flowercard = this.m_Flower.getChildByName('flowercard'); if (!flowercard.active) { flowercard.active = true; setTimeout(() => { if (flowercard.active) { flowercard.active = false; } }, 2000); } }, OnBtClickedUser: function () { if (this.m_dwUserID == null || this.m_dwUserID == 0) return; var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData(); if (this.m_dwUserID == pGlobalUserData.dwUserID) { return } if (this.m_Hook.m_FaceExCtrl) this.m_Hook.m_FaceExCtrl.SetShowInfo( this.m_dwUserID, this.m_ChairID, this.m_pUserItem.GetUserIP()); //, this.m_Hook.strAddress[this.m_ChairID]); return; var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData(); // if(this.m_dwUserID == pGlobalUserData.dwUserID){ // return // } if (this.m_Hook.m_FaceExCtrl) this.m_Hook.m_FaceExCtrl.SetShowInfo( this.m_dwUserID, 'IP:' + this.m_pUserItem.GetUserIP(), this.m_ChairID, this.m_Hook.strAddress[this.m_ChairID]); }, UpdateScore: function (pUserItem) { // if (pUserItem.GetUserID() == this.m_dwUserID) { // this.SetUserScore(pUserItem.GetUserScore()); // } if (GameDef.m_dwGameRuleArr&&GameDef.m_dwGameRuleArr[3] > 0) { this.getUserMedal(); }else{ this.m_Diamond.active = false; } }, SetUserScore: function (Score) { console.log("设置SetUserScore-2", Score) // 将传入的分数赋值给当前对象的m_lScore属性 this.m_lScore = Score; // 将分数转换为字符串格式,并设置给m_UserScore节点的string属性,用于显示用户分数 this.m_UserScore.string = Score; }, SetUserFlower: function (viewID, flower, wFlowercard, displayF, displayC) { this.m_Flowercard.active = displayC; this.m_FlowerNumber.string = '×' + flower; let flowerLayout = this.m_FlowerLayout; for (let i = 0; i < wFlowercard.length; i++) { if (wFlowercard[i] > 0) { flowerLayout.getChildByName('' + wFlowercard[i]).active = true; } } setTimeout(() => { this.m_Flowercard.active = false; }, 3000); }, SetFeng: function (cbQuan, cbFeng, display) { let directions = ["東", "南", "西", "北"]; let cbQuanStr = directions[cbQuan]; let cbFengStr = directions[cbFeng]; this.m_Feng.string = cbQuanStr + " 風 " + cbFengStr; if (!display) { this.m_Feng.string = ""; console.log("显示风位", cbQuan, cbFeng, display, this.m_Feng.string); } }, SetShowFenganFlower: function () { // console.log("关闭显示花牌,风位"); this.m_Flower.active = false; this.m_Feng.string = ""; }, SetCurrentAction: function (cur) { this.m_CurEffect.active = cur; }, OnUserOffLine: function (bShow) { this.SetLeave(bShow); }, //基准位置 SetBenchmarkPos: function (nXPos, nYPos) { this.node.setPosition(nXPos, nYPos); }, SetBanker: function (bBanker) { this.m_Zhuang.active = bBanker; }, //离开状态 SetLeave: function (bLeave) { this.m_LeaveHead.active = bLeave; }, SetGang: function (cbDouble) { if (cbDouble == 0) { this.m_Gang.node.active = false; } else { this.m_Gang.node.active = true; if (cbDouble == 255) { //this.m_Gang.string = '不下嘴'; } else { this.m_Gang.string = '飘' + cbDouble; } } }, SetTing: function (bShow) { this.m_Ting.active = bShow; }, SetTrustee: function (bShow) { this.m_Trustee.active = bShow; }, updateEndDimond: function (viewID, lScore) { let tmpeS = parseInt(this.m_lScore) +parseInt(lScore) console.log("最新的钻石",this.m_lScore,tmpeS,lScore) this.scheduleOnce(function() { console.log("最新的钻石2",this.m_lScore,tmpeS,lScore) this.SetUserScore( tmpeS); }, 2); }, SetScore: function (viewID, lScore) { if (GameDef.m_dwGameRuleArr&&GameDef.m_dwGameRuleArr[3] > 0) { this.getUserMedal(); } else { this.SetUserScore(lScore); } return; // this.m_Score.node.stopAllActions(); this.m_Score.node.active = true; var Score = lScore; if (lScore > 0) { this.m_Score.string = lScore;//'+'+Score2Str(lScore); //this.m_Score.font = this.m_Font[0]; this.m_Score.node.color = cc.color(0, 255, 0); } else { //this.m_Score.font = this.m_Font[1]; this.m_Score.node.color = cc.color(255, 0, 0); this.m_Score.string = lScore; //Score2Str(lScore); } if (viewID == 1 || viewID == 3 || viewID == 2) { this.m_Score.node.setPosition(cc.v2(0, 50)); } else if (viewID == 0) { this.m_Score.node.setPosition(cc.v2(70, 0)); } // var sequence = cc.sequence // ( // cc.moveBy(0.5, cc.v2(0, 50)), // cc.delayTime(0.5), // cc.callFunc(function () { // this.m_Score.node.active = false; // }, this) // ); // this.m_Score.node.runAction(sequence); }, SetFlower: function (viewID, wFlower, wFlowercard, displayF, displayC) { this.m_Flower.active = displayF; this.SetUserFlower(viewID, wFlower, wFlowercard, displayF, displayC); }, SetPlaying(status) { this.m_playingNode.active = status; }, getUserMedal: function () { // // 将传入的分数赋值给当前对象的m_lScore属性 // this.m_lScore = Score; // // 将分数转换为字符串格式,并设置给m_UserScore节点的string属性,用于显示用户分数 // this.m_scoreLab.string = formatToChineseAbbreviation(Score); if(this.m_dwUserID==0) return; var webUrl = window.PHP_HOME + '/UserFunc.php?&GetMark=5&dwUserID=' + this.m_dwUserID; WebCenter.GetData(webUrl, 3, function (data) { var resData = JSON.parse(data); this.SetUserScore(resData && resData.UserMedal) this.m_Diamond.active = true; }.bind(this)); }, });