| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- 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));
- },
- });
|