var CGameLogic = require("GameLogic_21201"); cc.Class({ extends: cc.GameEngine, properties: { m_ViewNode: cc.Node, m_BtDissolve: cc.Node, m_BtExit: cc.Node, }, // use this for initialization start: function () { this.Init(); }, Init: function () { if (this.m_bInit == true) return; this.m_bInit = true; //this.SInit(); this.m_UserLocation = new Array(); this.m_GameLogic = new CGameLogic(); //游戏逻辑 GameDef.g_GameLogic = this.m_GameLogic; GameDef.g_GameEngine = this; for (var i = 0; i < GameDef.GAME_PLAYER; i++) { for (var j = 0; j < GameDef.MAX_WEAVE; ++j) { this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem(); } } // this.m_LeaveControl = this.node.getChildByName('LeaveCtrl').getComponent('LeaveControl'); // this.m_LeaveControl.SetClientEngine(this); // this.m_LeaveControl.ShowView(false); }, ctor: function () { //游戏变量 this.m_wBankerUser = 0; this.m_wCurrentUser = 0; this.m_wActionMask = 0; this.m_bStustee = false; this.m_wTimeOutCount = 0; this.m_cbLeftCardCount = 0; //发牌数目 this.m_GameLogic = null; //游戏逻辑 this.m_WeaveItemArray = new Array(); this.m_cbWeaveCount = new Array(); this.m_bListen = new Array(); for (var i = 0; i < 4; i++) { this.m_bListen[i] = false; this.m_cbWeaveCount[i] = 0; this.m_WeaveItemArray[i] = new Array(); } this.m_cbCardIndex = new Array(); for (var i = 0; i < 42; ++i) {//GameDef.MAX_INDEX this.m_cbCardIndex[i] = 0; } //玩家变量 this.m_wCurrentUser = INVALID_CHAIR; this.m_SoundArr = new Array( ['BGM', 'BGM'],//.mp3 ['GAME_START', 'GAME_START'], ['GAME_END', 'GAME_END'], ['GAME_WARN', 'GAME_WARN'], ['SEND_CARD', 'SEND_CARD'], ['CHUPAI', 'CHUPAI'], ['TIPAI', 'TIPAI'], // //女 // ['W_CHI', 'w/CHI'], // ['W_HU', 'w/CHI_HU'], // ['W_ZIMO', 'w/ZIMO'], // ['W_GANG', 'w/GANG'], // ['W_PENG', 'w/PENG'], // ['W_TING', 'w/TING'], // ['W_ZHUNBEI', 'w/zhunbei'], // //男 // ['M_CHI', 'm/CHI'], // ['M_HU', 'm/CHI_HU'], // ['M_ZIMO', 'm/ZIMO'], // ['M_GANG', 'm/GANG'], // ['M_PENG', 'm/PENG'], // ['M_TING', 'm/TING'], // ['M_ZHUNBEI', 'm/zhunbei'], ); //出牌声音 for (var j = 0; j < 4; j++) { //女 this.m_SoundArr[this.m_SoundArr.length] = ["W_CHIL" + j, 'w/CHIL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["W_HUL" + j, 'w/CHI_HUL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["W_ZIMOL" + j, 'w/ZIMOL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["W_GANGL" + j, 'w/GANGL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["W_PENGL" + j, 'w/PENGL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["W_TINGL" + j, 'w/TINGL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["W_ZHUNBEIL" + j, 'w/zhunbeiL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["W_BUHUAL" + j, 'w/BUHUAL' + j]; //男 this.m_SoundArr[this.m_SoundArr.length] = ["M_CHIL" + j, 'm/CHIL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_HUL" + j, 'm/CHI_HUL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_ZIMOL" + j, 'm/ZIMOL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_GANGL" + j, 'm/GANGL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_PENGL" + j, 'm/PENGL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_TINGL" + j, 'm/TINGL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_ZHUNBEIL" + j, 'm/zhunbeiL' + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_BUHUAL" + j, 'm/BUHUAL' + j]; for (var i = 1; i < 10; ++i) { this.m_SoundArr[this.m_SoundArr.length] = ["M_W_" + i + "L" + j, 'm/W_' + i + "L" + j]; this.m_SoundArr[this.m_SoundArr.length] = ['W_W_' + i + "L" + j, 'w/W_' + i + "L" + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_S_" + i + "L" + j, 'm/S_' + i + "L" + j]; this.m_SoundArr[this.m_SoundArr.length] = ['W_S_' + i + "L" + j, 'w/S_' + i + "L" + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_T_" + i + "L" + j, 'm/T_' + i + "L" + j]; this.m_SoundArr[this.m_SoundArr.length] = ['W_T_' + i + "L" + j, 'w/T_' + i + "L" + j]; this.m_SoundArr[this.m_SoundArr.length] = ["M_F_" + i + "L" + j, 'm/F_' + i + "L" + j]; this.m_SoundArr[this.m_SoundArr.length] = ['W_F_' + i + "L" + j, 'w/F_' + i + "L" + j]; } for (var i = 0; i < 12; ++i) { var num = "w_" + i; this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_w" + (i + 1), 'ShortcutPhrase/' + num]; num = "m_" + i; this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_m" + (i + 1), 'ShortcutPhrase/' + num]; } // for (var i = 0; i < 12; ++i) { // var num = "w_" + i+"L"+j; // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_w" + (i + 1)+"L"+j, 'ShortcutPhrase/' + num]; // num = "m_" + i+"L"+j; // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_m" + (i + 1)+"L"+j, 'ShortcutPhrase/' + num]; // } } // //出牌声音 // for(var i=1;i<10;++i){ // this.m_SoundArr[this.m_SoundArr.length] = ["M_W_"+i,'m/W_'+i]; // this.m_SoundArr[this.m_SoundArr.length] = ['W_W_'+i,'w/W_'+i]; // this.m_SoundArr[this.m_SoundArr.length] = ["M_S_"+i,'m/S_'+i]; // this.m_SoundArr[this.m_SoundArr.length] = ['W_S_'+i,'w/S_'+i]; // this.m_SoundArr[this.m_SoundArr.length] = ["M_T_"+i,'m/T_'+i]; // this.m_SoundArr[this.m_SoundArr.length] = ['W_T_'+i,'w/T_'+i]; // this.m_SoundArr[this.m_SoundArr.length] = ["M_F_"+i,'m/F_'+i]; // this.m_SoundArr[this.m_SoundArr.length] = ['W_F_'+i,'w/F_'+i]; // } // for (var i = 0; i < 12; ++i) { // var num = "w_" + i; // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_w" + (i + 1), 'ShortcutPhrase/' + num]; // num = "m_" + i; // this.m_SoundArr[this.m_SoundArr.length] = ["Phrase_m" + (i + 1), 'ShortcutPhrase/' + num]; // } this.m_szText = new Array( '快點動手!你是來打牌還是來當雕像?', '哇靠~盯這麼緊?打張牌來吃吃吧!', '拖什麼拖!我還得趕去談生意咧!', '等等,我接個電話,別偷牌啊!', '想這麼久幹嘛?出張二筒吧!', '不是阿大哥,在忙啥,動作這麼慢?', '有種再打同一張!這把我要胡到你哭!', '又是我放槍?這牌桌有毒吧!', ' 你家網路是撥接的喔?卡成這樣!', '老子回來了!看你急得跟什麼一樣!', ' 又胡!?這人是不是開外掛啦!', // '這咋又胡了呢,腦瓜子嗡一下子', ); this.m_cbGameStatus = 0; this.m_bCanShowBigEnd = false; this.m_bEnd = false; this.m_bInit = false; this.m_bFirstCard = false; }, //网络消息 OnEventGameMessage: function (wSubCmdID, pData, wDataSize) { switch (wSubCmdID) { case GameDef.SUB_S_GAME_START: //游戏开始 { return this.OnSubGameStart(pData, wDataSize); } case GameDef.SUB_S_OUT_CARD: //用户出牌 { return this.OnSubOutCard(pData, wDataSize); } case GameDef.SUB_S_SEND_CARD: //发牌消息 { return this.OnSubSendCard(pData, wDataSize); } case GameDef.SUB_S_OPERATE_NOTIFY: //操作提示 { return this.OnSubOperateNotify(pData, wDataSize); } case GameDef.SUB_S_OPERATE_TIMER://别人有提示显示时间 { return this.OnSubOperateTimer(pData, wDataSize); } case GameDef.SUB_S_OPERATE_RESULT: //操作结果 { return this.OnSubOperateResult(pData, wDataSize); } case GameDef.SUB_S_GAME_END: //游戏结束 { return this.OnSubGameEnd(pData, wDataSize); } case GameDef.SUB_S_TRUSTEE: //用户托管 { return this.OnSubTrustee(pData, wDataSize); } case GameDef.SUB_S_LEAVE: //用户托管 { return this.OnSubLeave(pData, wDataSize); } case GameDef.SUB_S_NEXT_READY: //下局准备 { return this.OnSubNextReady(pData, wDataSize); } case GameDef.SUB_S_USER_DOUBLE: //用户加刚 { return this.OnSubPlayerDouble(pData, wDataSize); } case GameDef.SUB_S_GAME_DOUBLE: //开始选刚 { return this.OnSubStartDouble(pData, wDataSize); } case GameDef.SUB_S_UPDATE_CARD: //刷新 { return this.OnUpdateCardData(pData, wDataSize); } case GameDef.SUB_S_TING: { return this.OnTing(pData, wDataSize); } case GameDef.SUB_S_REPLACE_CARD: //用户补牌 { return this.OnSubReplaceCard(pData, wDataSize); } case GameDef.SUB_S_BANKER_CAN_OUT: { this.m_wCurrentUser = this.m_wBankerUser; this.m_bFirstCard = false; this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(true); } } return true; }, //游戏场景 OnEventSceneMessage: function (cbGameStatus, bLookonUser, pData, wDataSize) { if (GameDef.TMP_TEST) { this.__test(); return true; } //this.m_GameClientView.m_BtFriend.active = (this.m_dwRoomID != 0 && this.m_wGameProgress == 0); this.m_cbGameStatus = cbGameStatus; switch (cbGameStatus) { case GameDef.GAME_SCENE_FREE: //空闲状态 { var pStatusFree = GameDef.CMD_S_StatusFree(); if (wDataSize != gCByte.Bytes2Str(pStatusFree, pData)) return false; for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, pStatusFree.lSumGameScore[i]) } return true; } case GameDef.GAME_SCENE_DOUBLE: //加倍状态 { // function binaryData(ev) { // return JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(ev.data))) // } var pStatusFree = GameDef.CMD_S_StatusFree(); if (wDataSize != gCByte.Bytes2Str(pStatusFree, pData)) return false; console.log("pStatusFree--", pStatusFree) for (var i = 0; i < GameDef.GAME_PLAYER; i++) { this.m_GameClientView.SetTrustee(i, pStatusFree.bTrustee[i]); } var wMeChairID = this.GetMeChairID(); this.m_bStustee = pStatusFree.bTrustee[wMeChairID]; if (this.m_wGameProgress == 0) { var kernel = gClientKernel.get(); if (this.m_dwCreater != 0 && this.m_dwCreater == kernel.mMeUserItem.GetUserID()) { this.m_BtExit.active = false; this.m_BtDissolve.active = true; } else { this.m_BtExit.active = true; this.m_BtDissolve.active = false; } } else { this.m_BtExit.active = false; this.m_BtDissolve.active = true; // 没开始不用计时 if (this.m_bStustee) { this.checkTotalEnd(true); } // else // { // //计算时间 // var wTimeCount=this.GetOperateTime() - pStatusFree.dwOperateTime; // this.SetGameClock(this.m_wCurrentUser,GameDef.IDI_OPERATE_CARD,wTimeCount); // } } //this.m_GameClientView.m_BtStart.active = !this.m_bStustee; this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR); // this.m_GameClientView.SetHuangZhuang(pStatusFree.wHuangZhuangCount); var kernel = gClientKernel.get(); if (GameDef.GAME_SCENE_DOUBLE == cbGameStatus && !kernel.IsLookonMode()) { this.m_GameClientView.m_BtStart.active = false; var cbDoubleT = pStatusFree.cbDouble[this.GetMeChairID()]; if (cbDoubleT == 0) { this.m_GameClientView.SetGangOperator(1); } else { //计算时间 var wTimeCount = this.GetOperateTime() - pStatusFree.dwOperateTime; this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, wTimeCount); this.m_GameClientView.SetGangOperator(2); } for (var i = 0; i < GameDef.GAME_PLAYER; i++) { var viewId = this.SwitchViewChairID(i); var cbDouble = pStatusFree.cbDouble[i]; this.m_GameClientView.m_UserInfo[viewId].SetGang(cbDouble); } } return true; } case GameDef.GAME_SCENE_PLAY: //游戏状态 { var BankViewID = this.SwitchViewChairID(0); this.m_GameClientView.m_BtFriend.active = false; //效验数据 var pStatusPlay = GameDef.CMD_S_StatusPlay(); pStatusPlay.weaveItem = this.m_WeaveItemArray; pStatusPlay.cbWeaveCount = this.m_cbWeaveCount; if (wDataSize != gCByte.Bytes2Str(pStatusPlay, pData)) return false; console.log("pStatusPlay--", pStatusPlay) var displayF = true; var displayC = true; if (GameDef.GAME_RULE_SP_16 & GameDef.m_dwGameRuleArr[0]) displayF = false; if (this.m_cbGameStatus & GameDef.GAME_SCENE_PLAY) displayC = false; this.m_wGameProgress = pStatusPlay.cbQuan + 1; this.m_GameClientView.UpdateRoomProgress(); //风局 this.m_GameClientView.Fengju(pStatusPlay.cbQuan, pStatusPlay.cbFeng, displayF); //骰子 this.m_GameClientView.DiceNum(pStatusPlay.cbSick) //风位 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[OtherViewID].SetFeng(pStatusPlay.cbQuan, pStatusPlay.cbUserDNXB[i], displayF); } //花牌数据 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[OtherViewID].SetFlower(OtherViewID, pStatusPlay.cbFlowerCount[i], pStatusPlay.cbCardDataFlower[i], displayF, displayC); this.m_GameClientView.showGotFlowers(OtherViewID, displayC); } this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); this.m_GameClientView.m_CardView.ResetView(); //设置刚状态 var wViewChairID = new Array(); for (var i = 0; i < GameDef.GAME_PLAYER; i++) { wViewChairID[i] = this.SwitchViewChairID(i); this.m_bListen[i] = pStatusPlay.bListen[i]; // cbDouble= pStatusPlay.cbDouble[i]; this.m_GameClientView.SetTrustee(i, pStatusPlay.bTrustee[i]); this.m_GameClientView.m_UserInfo[wViewChairID[i]].SetTing(this.m_bListen[i]); var cbDouble = pStatusPlay.cbDouble[i]; this.m_GameClientView.m_UserInfo[wViewChairID[i]].SetGang(cbDouble); } var wMeChairID = this.GetMeChairID(); this.m_bStustee = pStatusPlay.bTrustee[wMeChairID]; //会牌 this.m_GameClientView.m_CardView.SetMakeMagicIndex(pStatusPlay.cbMakeMagicIndex); //this.m_HuiCardDate = this.m_GameLogic.GetNextCardIndex( pStatusPlay.cbMakeMagicIndex); // this.m_GameClientView.m_CardView.SetMagicIndex(this.m_HuiCardDate); //this.m_HuiCardDate = this.m_GameLogic.SwitchToCardData(this.m_HuiCardDate); this.m_DingHuiCardDate = this.m_GameLogic.SwitchToCardData(pStatusPlay.cbMakeMagicIndex); //this.m_GameClientView.SetHuiPai(this.m_DingHuiCardDate,this.m_HuiCardDate); //GameDef.m_cbMagicData = this.m_HuiCardDate; this.m_wBankerUser = pStatusPlay.wBankerUser; this.m_wCurrentUser = pStatusPlay.wCurrentUser; this.m_cbLeftCardCount = pStatusPlay.cbLeftCardCount; // this.m_GameClientView.SetHuangZhuang(pStatusPlay.wHuangZhuangCount); //玩家变量 //for (var i = 0; i < GameDef.GAME_PLAYER; i++) { //用户名字 // var kernel = gClientKernel.get(); // var pIClientUserItem = kernel.GetTableUserItem(i); // if (pIClientUserItem == null) continue; // this.m_GameClientView.SetScoreInfo(this.SwitchViewChairID(i), pIClientUserItem.GetUserScore() + pStatusPlay.lGangScore[i]); for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, pStatusPlay.lSumGameScore[i]) } this.m_GameClientView.SetLeftCardCount(this.m_cbLeftCardCount); this.m_GameLogic.SwitchToCardIndex3(pStatusPlay.cbCardData, pStatusPlay.cbCardCount, this.m_cbCardIndex); //界面设置 this.m_GameClientView.SetCellScore(pStatusPlay.lCellScore); this.m_GameClientView.SetBankerUser(wViewChairID[this.m_wBankerUser]); //组合扑克 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { // var wOperateViewID = this.SwitchViewChairID(i); for (var j = 0; j < this.m_cbWeaveCount[i]; j++) { this.m_GameClientView.m_CardView.SetWeaveData(wViewChairID[i], j, this.m_WeaveItemArray[i][j].cbCardData, this.m_WeaveItemArray[i][j].cbCardCount); this.m_GameClientView.m_CardView.SetWeaveState(wViewChairID[i], j, this.m_WeaveItemArray[i][j]); } } //用户扑克 if (this.m_wCurrentUser == wMeChairID && this.m_cbCardIndex[this.m_GameLogic.SwitchToCardIndex(pStatusPlay.cbSendCardData)] > 0) { this.m_GameClientView.m_CardView.SetSelfCardIndex(this.m_cbCardIndex, pStatusPlay.cbSendCardData, this.m_bListen[wMeChairID], pStatusPlay.cbCantOutCard); } else { this.m_GameClientView.m_CardView.SetSelfCardIndex(this.m_cbCardIndex, 0, this.m_bListen[wMeChairID], pStatusPlay.cbCantOutCard); } //扑克设置 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; //用户扑克 var cbCardCount = GameDef.MAX_COUNT - this.m_cbWeaveCount[i] * 3 - 1; if (i != wMeChairID) { if (pStatusPlay.wCurrentUser == i) { cbCardCount++; } var wUserCardIndex = wViewChairID[i]; this.m_GameClientView.m_CardView.SetCardData(wUserCardIndex, null, cbCardCount); } //丢弃扑克 this.m_GameClientView.m_CardView.SetDiscardCardDate(wViewChairID[i], pStatusPlay.cbDiscardCard[i], pStatusPlay.cbDiscardCount[i]); } //丢弃效果 if (pStatusPlay.wOutCardUser != INVALID_CHAIR) { this.m_GameClientView.m_CardView.AddDiscard(wViewChairID[pStatusPlay.wOutCardUser], pStatusPlay.cbOutCardData); this.m_GameClientView.m_CardView.SetDiscardTip(this.SwitchViewChairID(pStatusPlay.wOutCardUser)); } //控制设置 this.m_GameClientView.m_CardView.SetPositively(true); //操作界面 if (pStatusPlay.wActionMask != GameDef.WIK_NULL) { //获取变量 this.m_wActionMask = pStatusPlay.wActionMask; } this.m_GameClientView.SetCurrentUser(this.m_wCurrentUser); //设置时间 if (this.m_wCurrentUser != INVALID_CHAIR) { //计算时间 var wTimeCount = this.GetOperateTime() - pStatusPlay.dwOperateTime; //设置时间 if (pStatusPlay.bLeave[this.m_wCurrentUser]) { this.m_GameClientView.SetUserTimer(this.SwitchViewChairID(this.m_wCurrentUser), 0); } else { this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, wTimeCount); } } this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(pStatusPlay.bCanOutCard); this.m_BtExit.active = false; this.m_BtDissolve.active = true; return true; // } } return false; } }, SetGameClock: function (wChairID, nTimerID, nElapse) { this.m_GameClientView.SetUserTimer(wChairID, nElapse, 1); if (this.m_ReplayMode) return g_TimerEngine.SetGameTimer(wChairID, nTimerID, nElapse * 1000, null, this, 'OnTimerMessage'); }, //删除定时器 KillGameClock: function (nTimerID) { this.m_GameClientView.SetUserTimer(INVALID_CHAIR, 0); g_TimerEngine.KillGameTimer(); return true; }, //时间消息 OnTimerMessage: function (wChairID, CountDown, nTimerID, Progress) { var nElapse = parseInt(CountDown / 1000) + 1; if (CountDown == 0) nElapse = 0; this.m_GameClientView.SetUserTimer(wChairID, nElapse); return true; }, StusteeOperateCard: function (wChairID) { if (this.m_bStustee == false) { this.ListenAutoOutCard(wChairID); return false; } // if (this.m_bStustee){ // if(this.m_wActionMask & GameDef.WIK_CHI_HU){ // this.OnCardOperate(GameDef.WIK_CHI_HU, 0); // return true; // } // } //获取位置 var wMeChairID = this.GetMeChairID(); //动作处理 if (wChairID == wMeChairID) { // //玩家未听牌,且未托管,则累加超时次数 // if( this.m_bStustee==false && ++this.m_wTimeOutCount>=3 ) // { // this.m_wTimeOutCount = 0; // this.OnStusteeControl(0,TRUE); // } if (this.m_wCurrentUser == wMeChairID) { //获取扑克 var wViewID = this.SwitchViewChairID(wChairID); var cbCardData = this.m_GameClientView.m_CardView.GetHandCurrentCard(wViewID); //出牌效验 if (this.VerdictOutCard(cbCardData) == false) { for (var i = 0; i < 42; i++)//GameDef.MAX_INDEX { //出牌效验 if (this.m_cbCardIndex[i] == 0) continue; if (this.VerdictOutCard(this.m_GameLogic.SwitchToCardData(i)) == false) continue; //设置变量 cbCardData = this.m_GameLogic.SwitchToCardData(i); } } //出牌动作 var sequence = cc.sequence( cc.callFunc(function () { // this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(false); if (this.m_wCurrentUser != wChairID) { this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(false); return; } this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true); }, this), cc.delayTime(1), cc.callFunc(function () { this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetOutCard(cbCardData); // this.OnOutCard(0, 0, cbCardData); }, this )); this.node.runAction(sequence); } else { this.OnCardOperate(0, 0); if (this.m_cbGameStatus == GameDef.GAME_SCENE_PLAY) { //过 var sequence = cc.sequence( cc.delayTime(1), cc.callFunc(function () { this.OnCardOperate(0, 0); }, this )); this.node.runAction(sequence); } else if (this.m_cbGameStatus == GameDef.GAME_SCENE_DOUBLE) { //不下 this.OnDoubleOperate(1); this.m_GameClientView.SetGangOperator(2); } } } return true; }, ListenAutoOutCard: function (wChairID) { if (this.m_bStustee == true) return; //托管不走这 var wMeChairID = this.GetMeChairID(); if (wMeChairID != wChairID) return; if (this.m_wCurrentUser != wMeChairID) return; if (this.m_bListen[wChairID] == false) return; //可以杠 if (this.m_wActionMask & (GameDef.WIK_GANG | GameDef.WIK_CHI_HU)) { return; } //获取扑克 var wViewID = this.SwitchViewChairID(wChairID); var cbCardData = this.m_GameClientView.m_CardView.GetHandCurrentCard(wViewID); //出牌效验 if (this.VerdictOutCard(cbCardData) == false) { for (var i = 0; i < 42; i++)//GameDef.MAX_INDEX { //出牌效验 if (this.m_cbCardIndex[i] == 0) continue; if (this.VerdictOutCard(this.m_GameLogic.SwitchToCardData(i)) == false) continue; //设置变量 cbCardData = this.m_GameLogic.SwitchToCardData(i); } } //出牌动作 var sequence = cc.sequence( cc.callFunc(function () { this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(false); }, this), cc.delayTime(1), cc.callFunc(function () { this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetOutCard(cbCardData); this.OnOutCard(0, 0, cbCardData); }, this )); this.node.runAction(sequence); }, //出牌判断 VerdictOutCard: function (cbCardData) { return this.m_GameLogic.IsValidCard(cbCardData); }, //游戏开始 OnSubGameStart: function (pBuffer, wDataSize) { this.m_pGameStart = GameDef.CMD_S_GameStart(); //效验 if (wDataSize != gCByte.Bytes2Str(this.m_pGameStart, pBuffer)) return false; this.CleanView(); if (this.m_EndLittleView) { this.m_EndLittleView.HideView(); } this.m_GameClientView.SetGangOperator(0); this.m_cbGameStatus = GameDef.GAME_SCENE_PLAY; var pGameStart = this.m_pGameStart; console.log("pGameStart--", pGameStart); this.m_GameClientView.m_BtFriend.active = false; this.m_wGameProgress = this.m_pGameStart.cbQuan + 1; this.m_GameClientView.UpdateRoomProgress(); //郑骰子 this.m_GameClientView.OnRollDice(this.m_pGameStart.cbSick); setTimeout(() => { this.starts(); }, 1500); this.m_bEnd = false; return true; }, starts: function () { var display = true; if (GameDef.m_dwGameRuleArr[0] & GameDef.GAME_RULE_SP_16) display = false; //骰子 this.m_GameClientView.DiceNum(this.m_pGameStart.cbSick); //风局 this.m_GameClientView.Fengju(this.m_pGameStart.cbQuan, this.m_pGameStart.cbFeng, display); //风位 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[OtherViewID].SetFeng(this.m_pGameStart.cbQuan, this.m_pGameStart.cbUserDNXB[i], display); } //初始花牌显示 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[OtherViewID].ClearFlower(display); } //会牌 this.m_GameClientView.m_CardView.SetMakeMagicIndex(this.m_pGameStart.cbMakeMagicIndex); //this.m_HuiCardDate = this.m_GameLogic.GetNextCardIndex( pGameStart.cbMakeMagicIndex ); // this.m_GameClientView.m_CardView.SetMagicIndex(this.m_HuiCardDate); if (!this.m_bRollBack) this.m_GameClientView.SetMakeMagicIndex(this.m_pGameStart.cbMakeMagicIndex); //this.m_HuiCardDate = this.m_GameLogic.SwitchToCardData(this.m_HuiCardDate); // GameDef.m_cbMagicData = this.m_HuiCardDate; var BankViewID = this.SwitchViewChairID(this.m_pGameStart.wBankerUser); this.m_GameClientView.m_CardView.SetPositively(false); var wMeChairID = this.GetMeChairID(); this.m_bStustee = this.m_pGameStart.bTrustee[wMeChairID]; for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var viewId = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[viewId].SetTing(false); var cbDouble = this.m_pGameStart.cbDouble[i]; this.m_GameClientView.m_UserInfo[viewId].SetGang(cbDouble); this.m_GameClientView.SetTrustee(i, this.m_pGameStart.bTrustee[i]); } // this.m_GameClientView.SetHuangZhuang(pGameStart.wHuangZhuangCount); if (!this.m_bRollBack) cc.gSoundRes.PlayGameSound("GAME_START"); //保存数据 this.m_wBankerUser = this.m_pGameStart.wBankerUser; this.m_wCurrentUser = this.m_pGameStart.wCurrentUser; this.m_cbLeftCardCount = this.m_pGameStart.cbLastCardCount; this.m_wActionMask = this.m_pGameStart.wUserAction; this.m_GameClientView.SetLeftCardCount(this.m_cbLeftCardCount); //设置扑克 var cbCardCount = (wMeChairID == this.m_wBankerUser) ? GameDef.MAX_COUNT : (GameDef.MAX_COUNT - 1); this.m_GameLogic.SwitchToCardIndex3(this.m_pGameStart.cbCardData, cbCardCount, this.m_cbCardIndex); //设置界面 this.m_GameClientView.SetBankerUser(this.SwitchViewChairID(this.m_wBankerUser)); this.m_GameClientView.m_CardView.SetPositively(true); this.m_GameClientView.m_BtStart.active = false; this.m_BtExit.active = false; this.m_BtDissolve.active = true; //扑克设置 for (var i = 0; i < GameDef.GAME_PLAYER; ++i) { //听 this.m_bListen[i] = false; //变量定义 var wViewChairID = this.SwitchViewChairID(i); if (this.m_GameClientView.m_pIClientUserItem[wViewChairID] == null) continue; //用户扑克 if (wViewChairID != GameDef.MYSELF_VIEW_ID) { this.m_GameClientView.m_CardView.SetCardData(wViewChairID, null, GameDef.MAX_COUNT - 1, null); } else { var cbCardData = new Array(); this.m_GameLogic.SwitchToCardData2(this.m_cbCardIndex, cbCardData); var cbBankerCard = (i == this.m_wBankerUser ? cbCardData[GameDef.MAX_COUNT - 1] : null); this.m_GameClientView.m_CardView.SetSelfCardData(cbCardData, GameDef.MAX_COUNT - 1, cbBankerCard); } this.m_GameClientView.m_CardView.m_HandCard[wViewChairID].SetCanTouch(false); } //出牌提示 // if (this.m_wCurrentUser != INVALID_CHAIR) { // this.m_GameClientView.SetCurrentUser(this.m_wCurrentUser); // this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, this.GetOperateTime()); // } }, //补 OnSubReplaceCard: function (pData, wDataSize) { var pSendCard = GameDef.CMD_S_ReplaceCard(); //效验 if (wDataSize != gCByte.Bytes2Str(pSendCard, pData)) return false; var wCurrentUser = pSendCard.wReplaceUser; console.log("补OnSubReplaceCard--", pSendCard) var displayF = true; var displayC = true; if (GameDef.m_dwGameRuleArr[0] & GameDef.GAME_RULE_SP_16) displayF = false; // if(this.m_cbGameStatus & GameDef.GAME_SCENE_PLAY)displayC = true; if (this.GetClientUserItem(wCurrentUser) != null) { var OtherViewID = this.SwitchViewChairID(wCurrentUser); this.PlayActionSound(wCurrentUser, "BUHUA"); this.m_GameClientView.m_UserInfo[OtherViewID].SetFlower(OtherViewID, pSendCard.cbFlowerCount[wCurrentUser], pSendCard.cbCardDataFlower[wCurrentUser], displayF, displayC); this.m_GameClientView.showGotFlowers(OtherViewID, displayC); } return true; }, //发牌 OnSubSendCard: function (pData, wDataSize) { var pSendCard = GameDef.CMD_S_SendCard(); //效验 if (wDataSize != gCByte.Bytes2Str(pSendCard, pData)) return false; console.log("发牌--", pSendCard, pSendCard.wActionMask) //清空听牌提示 this.m_GameClientView.m_CardView.ShowTingData(); this.m_GameClientView.m_CardView.ShowTingTip(0); this.m_bFirstCard = pSendCard.bFirstCard; var wMeChairID = this.GetMeChairID(); var wViewChairID = this.SwitchViewChairID(pSendCard.wSendCardUser); var wChairId = pSendCard.wSendCardUser; var cbSendCardData = pSendCard.cbCardData; this.m_wCurrentUser = pSendCard.wCurrentUser; this.m_cbLeftCardCount = pSendCard.cbLeftCardCount; this.m_GameClientView.SetLeftCardCount(this.m_cbLeftCardCount); //取牌界面 if (wViewChairID != GameDef.MYSELF_VIEW_ID) { if (this.m_ReplayMode) { this.m_GameClientView.m_CardView.SetCurrentCard(wViewChairID, cbSendCardData, this.m_bListen[wChairId]); } else { this.m_GameClientView.m_CardView.SetCurrentCard(wViewChairID, 0, this.m_bListen[wChairId]); } } else { this.m_GameClientView.m_CardView.SetCurrentCard(wViewChairID, cbSendCardData, this.m_bListen[wChairId]); //插入扑克 this.m_cbCardIndex[this.m_GameLogic.SwitchToCardIndex(cbSendCardData)]++; } //当前用户 if (this.m_wCurrentUser == wMeChairID) { this.m_wActionMask = pSendCard.wActionMask; this.StusteeOperateCard(this.m_wCurrentUser); var wViewID = this.SwitchViewChairID(wMeChairID); this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(pSendCard.bCanOut); } this.m_GameClientView.SetCurrentUser(this.m_wCurrentUser); this.SetGameClock(this.m_wCurrentUser, GameDef.IDI_OPERATE_CARD, this.GetOperateTime()); cc.gSoundRes.PlayGameSound("SEND_CARD"); console.log("cbSendCardData--", cbSendCardData) if (this.m_wCurrentUser == wMeChairID && cbSendCardData > 55) { // this.OnReplaceCard(cbSendCardData) } return true; }, //出牌 OnSubOutCard: function (pData, wDataSize) { // 创建一个CMD_S_OutCard对象,用于存储出牌信息 var pOutCard = GameDef.CMD_S_OutCard(); // 效验数据大小是否与出牌数据结构一致,不一致则返回false if (wDataSize != gCByte.Bytes2Str(pOutCard, pData)) return false; this.m_GameClientView.m_CardView.SetControlInfo(false);//关闭操作面板? // 将出牌用户的椅子ID转换为视角ID var wOutUserViewId = this.SwitchViewChairID(pOutCard.wOutCardUser); // 更新出牌数据 this.m_cbOutCardData = pOutCard.cbOutCardData; // 清空听牌提示 this.m_GameClientView.m_CardView.ShowTingData(); // 隐藏听牌提示标志 this.m_GameClientView.m_CardView.ShowTingTip(0); // 删除游戏计时器 this.KillGameClock(); // 播放出牌动作声音 this.PlayActionSound(pOutCard.wOutCardUser, this.GetCardStr(this.m_cbOutCardData)); // 设置扑克 if (wOutUserViewId == GameDef.MYSELF_VIEW_ID) { // 从玩家的手牌中移除出的牌,失败则返回false if (!this.m_GameLogic.RemoveCard2(this.m_cbCardIndex, this.m_cbOutCardData)) return false; // 创建一个新的数组来存储手牌数据 var cbHandCardData = new Array(); // 获取更新后手牌的数量 var cbCardCount = this.m_GameLogic.SwitchToCardData2(this.m_cbCardIndex, cbHandCardData); // 获取客户端内核实例 var kernel = gClientKernel.get(); // 如果是回放模式 if (this.m_ReplayMode) { // 在回放中添加出的牌到弃牌堆 this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true); // 更新手牌显示 this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount); } else if (kernel.IsLookonMode()) { // 找到出牌在手牌中的索引位置 var CardCtrl = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId]; var OutIndex = 0; for (var i = 0; i < CardCtrl.m_CardItemArray.length; i++) { if (CardCtrl.m_CardItemArray[i].node.active == true && this.m_cbOutCardData == CardCtrl.m_CardItemArray[i].GetCardData()) { OutIndex = i; break; } } // 使用requestAnimationFrame来播放出牌动画 requestAnimationFrame(() => { this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount); }); } else { // 获取玩家选择的手牌数据和索引 var selCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardData(); var OutIndex = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardIndex(); selCardData = this.m_cbOutCardData if (selCardData == 0 || this.m_bStustee == true) { selCardData = this.m_cbOutCardData this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].SetOutCard(this.m_cbOutCardData) } //如果选择的牌与出的牌相同,则播放出牌动画 if (selCardData == this.m_cbOutCardData) { requestAnimationFrame(() => { this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount); }); } // if (this.m_bStustee == true) { // if (selCardData == 0) { // selCardData = this.m_cbOutCardData // this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].SetOutCard(this.m_cbOutCardData) // } // requestAnimationFrame(() => { // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount); // }); // } else { // //如果选择的牌与出的牌相同,则播放出牌动画 // if (selCardData == this.m_cbOutCardData) { // requestAnimationFrame(() => { // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount); // }); // } // } } } else { if (this.m_ReplayMode) { // 获取对手的手牌数据和数量 var cbHandCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_cbCardData; var cbCardCount = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_wCardCount; // 创建一个数组来存储移除的牌 var cbRemoveCard = new Array(); cbRemoveCard[0] = this.m_cbOutCardData; // 从对手的手牌中移除出的牌,失败则返回false if (!this.m_GameLogic.RemoveCard4(cbHandCardData, cbCardCount, cbRemoveCard, 1)) { return false; } // 对手手牌重新排序 this.m_GameLogic.SortCardList(cbHandCardData, cbCardCount - 1); // 更新对手手牌显示 this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount - 1); // 在回放中添加出的牌到弃牌堆 this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true); } else { // 设置当前玩家的出牌状态 this.m_GameClientView.m_CardView.SetCurrentCard(wOutUserViewId, null, this.m_bListen[pOutCard.wOutCardUser]); // 播放对手出牌动画 requestAnimationFrame(() => { this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData); }); } } // 如果出牌用户不是当前玩家 if (pOutCard.wOutCardUser != this.GetMeChairID()) { // 设置当前操作用户为无效 this.m_wCurrentUser = INVALID_CHAIR; // 清空操作掩码 this.m_wActionMask = 0; // 设置界面显示的当前操作用户为无效 this.m_GameClientView.SetCurrentUser(INVALID_CHAIR); // 设置用户操作界面为无效 this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); } // 出牌处理完成,返回true return true; }, // //出牌 // OnSubOutCard: function (pData, wDataSize) { // var pOutCard = GameDef.CMD_S_OutCard(); // //效验 // if (wDataSize != gCByte.Bytes2Str(pOutCard, pData)) return false; // var wOutUserViewId = this.SwitchViewChairID(pOutCard.wOutCardUser); // this.m_cbOutCardData = pOutCard.cbOutCardData; // //清空听牌提示 // this.m_GameClientView.m_CardView.ShowTingData(); // this.m_GameClientView.m_CardView.ShowTingTip(0); // //删除定时器 // this.KillGameClock(); // //播放声音 // this.PlayActionSound(pOutCard.wOutCardUser, this.GetCardStr(this.m_cbOutCardData)); // //设置扑克 // if (wOutUserViewId == GameDef.MYSELF_VIEW_ID) { // //删除扑克 // if (!this.m_GameLogic.RemoveCard2(this.m_cbCardIndex, this.m_cbOutCardData)) return false; // var cbHandCardData = new Array();//[GameDef.MAX_COUNT]; // var cbCardCount = this.m_GameLogic.SwitchToCardData2(this.m_cbCardIndex, cbHandCardData); // var kernel = gClientKernel.get(); // if (this.m_ReplayMode) { // this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true); // this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount); // } // else if (kernel.IsLookonMode()) { // var CardCtrl = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId]; // var OutIndex = 0; // for (var i = 0; i < CardCtrl.m_CardItemArray.length; i++) { // if (CardCtrl.m_CardItemArray[i].node.active == true && this.m_cbOutCardData == CardCtrl.m_CardItemArray[i].GetCardData()) { // OutIndex = i; // break; // } // } // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount); // } // else { // var selCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardData(); // var OutIndex = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].GetDoubleCardIndex(); // if (selCardData == this.m_cbOutCardData) { // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData, cbHandCardData, cbCardCount); // } // } // } else { // if (this.m_ReplayMode) { // var cbHandCardData = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_cbCardData;//[GameDef.MAX_COUNT]; // var cbCardCount = this.m_GameClientView.m_CardView.m_HandCard[wOutUserViewId].m_wCardCount; // var cbRemoveCard = new Array(); // cbRemoveCard[0] = this.m_cbOutCardData; // //删除扑克 // if (!this.m_GameLogic.RemoveCard4(cbHandCardData, cbCardCount, cbRemoveCard, 1)) { // return false; // } // this.m_GameLogic.SortCardList(cbHandCardData, cbCardCount - 1); // this.m_GameClientView.m_CardView.SetCardData(wOutUserViewId, cbHandCardData, cbCardCount - 1); // this.m_GameClientView.m_CardView.AddDiscard(wOutUserViewId, this.m_cbOutCardData, true); // } else { // this.m_GameClientView.m_CardView.SetCurrentCard(wOutUserViewId, null, this.m_bListen[pOutCard.wOutCardUser]); // this.m_GameClientView.m_CardView.PlayDiscard(wOutUserViewId, OutIndex, this.m_cbOutCardData); // } // } // if (pOutCard.wOutCardUser != this.GetMeChairID()) { // //设置变量 // this.m_wCurrentUser = INVALID_CHAIR; // this.m_wActionMask = 0; // //设置界面 // this.m_GameClientView.SetCurrentUser(INVALID_CHAIR); // this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); // } // return true; // }, huAuto: function(){ var OperateCard = GameDef.CMD_C_OperateCard(); OperateCard.wOperateCode = GameDef.WIK_CHI_HU; this.SendGameData(GameDef.SUB_C_OPERATE_CARD, OperateCard); }, //操作提示 OnSubOperateNotify: function (pData, wDataSize) { var pOperateNotify = GameDef.CMD_S_OperateNotify(); var size = gCByte.Bytes2Str(pOperateNotify, pData); var pObj = new Object() pObj.pItem = new Array(pOperateNotify.wCount); for (var i = 0; i < pOperateNotify.wCount; i++) { pObj.pItem[i] = GameDef.CMD_WeaveItem(); } //效验 if (wDataSize != gCByte.Bytes2Str(pObj, pData, size) + size) return false; //回放、观战不显示选飘界面 var kernel = gClientKernel.get(); if (this.m_ReplayMode || kernel.IsLookonMode()) return true; console.log("操作提示--", pOperateNotify, pObj) //用户界面 if (pOperateNotify.wActionMask != GameDef.WIK_NULL) { if (pOperateNotify.wActionMask & GameDef.WIK_CHI_HU) { console.log("操作提示-胡") this.scheduleOnce(() => { this.huAuto(); // var OperateCard = GameDef.CMD_C_OperateCard(); // OperateCard.wOperateCode = GameDef.WIK_CHI_HU; // OperateCard.cbOperateCard[0] = pOperateNotify.cbActionCard; // OperateCard.cbOperateCount = 1; // OperateCard.cbIndex = 0; // this.SendGameData(GameDef.SUB_C_OPERATE_CARD, OperateCard); }, 0.3); } // if (pOperateNotify.wActionMask & GameDef.WIK_GANG) { // console.log("操作提示-杠") // } // if (pOperateNotify.wActionMask & GameDef.WIK_PENG) { // console.log("操作提示-碰") // } // if (pOperateNotify.wActionMask & GameDef.WIK_LEFT) { // console.log("操作提示-左吃") // } // if (pOperateNotify.wActionMask & GameDef.WIK_CENTER) { // console.log("操作提示-中吃") // } // if (pOperateNotify.wActionMask & GameDef.WIK_RIGHT) { // console.log("操作提示-右吃") // } //this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(false); //获取变量 var wMeChairID = this.GetMeChairID(); this.m_wActionMask = pOperateNotify.wActionMask; //设置界面 cc.error("OnSubOperateNotify ", pObj.pItem); this.m_GameClientView.m_CardView.SetControlInfo(true, pObj.pItem, pObj.pItem.length); //设置时间 this.m_GameClientView.SetCurrentUser(pOperateNotify.wResumeUser); this.SetGameClock(wMeChairID, GameDef.IDI_OPERATE_CARD, this.GetOperateTime()); this.StusteeOperateCard(wMeChairID); } return true; }, OnSubOperateTimer: function (pData, wDataSize) { this.SetGameClock(INVALID_CHAIR, GameDef.IDI_OPERATE_CARD, this.GetOperateTime()); return true; }, //操作提示 OnSubOperateResult: function (pData, wDataSize) { var pOperateResult = GameDef.CMD_S_OperateResult(); //效验 if (wDataSize != gCByte.Bytes2Str(pOperateResult, pData)) return false; console.log("pOperateResult--", pOperateResult) var wOperateViewID = this.SwitchViewChairID(pOperateResult.wOperateUser); if (pOperateResult.wOperateUser != pOperateResult.wProvideUser && pOperateResult.bQiangGang == false) { var PrivideViewID = this.SwitchViewChairID(pOperateResult.wProvideUser); this.m_GameClientView.m_CardView.StopDiscard(PrivideViewID, pOperateResult.cbCenterCard); } var wOperateUser = pOperateResult.wOperateUser; this.m_GameClientView.m_CardView.SetControlInfo(false); this.m_GameClientView.SetUserAction(wOperateViewID, pOperateResult.wOperateCode); //环境设置 if (pOperateResult.wOperateCode & (GameDef.WIK_GANG)) { this.PlayActionSound(wOperateUser, "GANG"); // if (pOperateResult.dwGangScore > 0) { // if (pOperateResult.wProvideUser == wOperateUser) { // //暗杠,补杠 // var AddScore = 0; // for (var i = 0; i < GameDef.GAME_PLAYER; i++) { // if (this.GetClientUserItem(i) == null) continue; // if (i == wOperateUser) continue; // var OtherViewID = this.SwitchViewChairID(i); // this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, -pOperateResult.dwGangScore);// - // AddScore += pOperateResult.dwGangScore; // } // // this.m_GameClientView.m_UserInfo[wOperateViewID].SetScore(OtherViewID, AddScore);//+ AddScore // } // else { // //叉杠 // var PrivideViewID = this.SwitchViewChairID(pOperateResult.wProvideUser); // this.m_GameClientView.m_UserInfo[PrivideViewID].SetScore(PrivideViewID, -pOperateResult.dwGangScore);;//- // this.m_GameClientView.m_UserInfo[wOperateViewID].SetScore(wOperateViewID, pOperateResult.dwGangScore);;//+ // } // } } else if (pOperateResult.wOperateCode & (GameDef.WIK_LEFT | GameDef.WIK_CENTER | GameDef.WIK_RIGHT)) this.PlayActionSound(wOperateUser, "CHI"); else if (pOperateResult.wOperateCode & GameDef.WIK_PENG) this.PlayActionSound(wOperateUser, "PENG"); else if (pOperateResult.wOperateCode & GameDef.WIK_CHI_HU) this.PlayActionSound(wOperateUser, "HU"); else if (pOperateResult.wOperateCode & GameDef.WIK_LISTEN) { this.PlayActionSound(wOperateUser, "TING"); this.m_bListen[wOperateUser] = true; var viewID = this.SwitchViewChairID(wOperateUser); this.m_GameClientView.m_UserInfo[viewID].SetTing(true); } else if (pOperateResult.wOperateCode & GameDef.WIK_GANG_FENG) { this.PlayActionSound(wOperateUser, "FENG"); } else if (pOperateResult.wOperateCode & GameDef.WIK_DNJ) { this.PlayActionSound(wOperateUser, "DNJ"); } else if (pOperateResult.wOperateCode & GameDef.WIK_CAI_ZFB) { this.PlayActionSound(wOperateUser, "ZFB"); } //设置时间 if (pOperateResult.bBeiQiangGang) { this.m_wCurrentUser = INVALID_CHAIR; } else { this.m_wCurrentUser = wOperateUser; } var wMeChairID = this.GetMeChairID(); if (wOperateUser == wMeChairID) { var wViewID = this.SwitchViewChairID(wMeChairID); this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true); } this.m_GameClientView.SetCurrentUser(wOperateUser); this.SetGameClock(wOperateUser, GameDef.IDI_OPERATE_CARD, this.GetOperateTime()); return true; }, OnSubGameEnd: function (pData, wDataSize) { this.m_GameEnd = GameDef.CMD_S_GameEnd(); if (wDataSize != gCByte.Bytes2Str(this.m_GameEnd, pData)) return false; GameDef.cbLianZhuangCount = this.m_GameEnd.cbLianZhuangCount; console.log("連莊cbLianZhuangCount", GameDef.cbLianZhuangCount); this.m_cbGameStatus = GameDef.GAME_SCENE_FREE; console.log("this.m_GameEnd--", this.m_GameEnd); this.m_bCanShowBigEnd = false; //清空听牌提示 this.m_GameClientView.m_CardView.ShowTingData(); this.m_GameClientView.m_CardView.ShowTingTip(0); //删除定时器 this.KillGameClock(); GameDef.dwChiHuRightAdd = this.m_GameEnd.dwChiHuRightAdd; this.m_wGameProgress = this.m_GameEnd.cbQuan + 1; // this.m_GameClientView.UpdateRoomProgress(); this.MyChairID = this.GetMeChairID() let isZimo = false; //赢家 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; if (this.m_GameEnd.dwChiHuKind[i] == GameDef.WIK_CHI_HU) { var viewID = this.SwitchViewChairID(i); if (this.m_GameEnd.dwChiHuRight[i] & GameDef.CHR_ZI_MO) { //自摸 this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_CHI_HU, GameDef.CHR_ZI_MO); isZimo = true; } else { //胡牌 this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_CHI_HU); } } } //输家 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.m_GameEnd.lGameScore[i] >= 0) { continue; } if (this.GetClientUserItem(i) == null) continue; var viewID = this.SwitchViewChairID(i); this.m_GameClientView.SetUserAction(viewID, GameDef.WIK_FANG_PAO, isZimo ? GameDef.CHR_ZI_MO : 0); } for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); if (GameDef.m_dwGameRuleArr[3] > 0) { this.m_GameClientView.m_UserInfo[OtherViewID].updateEndDimond(OtherViewID, this.m_GameEnd.lGangScore[i]) }else{ this.m_GameClientView.m_UserInfo[OtherViewID].SetScore(OtherViewID, this.m_GameEnd.lSumGameScore[i]) } } //设置控件 this.m_GameClientView.m_CardView.SetControlInfo(false); this.m_GameClientView.m_CardView.SetPositively(false); this.m_GameClientView.SetCurrentUser(INVALID_CHAIR); for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; for (var j = 0; j < this.m_GameEnd.cbWeaveCount[i]; ++j) { var cbCenterCard = this.m_GameEnd.weaveItem[i][j].cbCenterCard; var wWeaveKind = this.m_GameEnd.weaveItem[i][j].wWeaveKind; var cbCardData = this.m_GameEnd.weaveItem[i][j].cbCardData; var cbWeaveCardCount = this.m_GameEnd.weaveItem[i][j].cbCardCount; var cbPublicCard = this.m_GameEnd.weaveItem[i][j].cbPublicCard; var viewID = this.SwitchViewChairID(i); this.m_GameClientView.m_CardView.SetWeaveData(viewID, j, cbCardData, cbWeaveCardCount, cbPublicCard); this.m_GameClientView.m_CardView.SetWeaveState(viewID, j, this.m_GameEnd.weaveItem[i][j]); if (cbWeaveCardCount == 4 && !cbPublicCard) { this.m_GameClientView.m_CardView.SetWeaveState(viewID, j, GameDef.GAME_THREE_BACK_SELF); } } } //设置扑克 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var cbCardData = this.m_GameEnd.cbCardData; var wCardCount = this.m_GameEnd.cbCardCount[i]; var viewID = this.SwitchViewChairID(i); if ((wCardCount + 1) % 3 == 0) { var tmpCardData = new Array(); for (var j = 0; j < wCardCount; j++) { tmpCardData[j] = cbCardData[i][j]; } var cbRemoveCard = new Array(); if (this.m_GameEnd.cbProvideCard != 0) { cbRemoveCard[0] = this.m_GameEnd.cbProvideCard; } else { cbRemoveCard[0] = tmpCardData[wCardCount - 1]; } if (this.m_GameEnd.cbLastCardData[i]) { cbRemoveCard[0] = this.m_GameEnd.cbLastCardData[i]; } if (this.m_GameLogic.RemoveCard4(tmpCardData, wCardCount, cbRemoveCard, 1)) { this.m_GameClientView.m_CardView.SetCardData(viewID, tmpCardData, wCardCount - 1); this.m_GameClientView.m_CardView.SetCurrentCard(viewID, cbRemoveCard[0]); } } else { this.m_GameClientView.m_CardView.SetCardData(viewID, cbCardData[i], wCardCount); } this.m_GameClientView.m_CardView.SetCardItemState(viewID, GameDef.HAND_STATE_SHOW); } //播放声音 if (this.m_GameEnd.wProvideUser != INVALID_CHAIR) { for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.m_GameEnd.dwChiHuKind[i] != GameDef.WIK_NULL) { if (this.m_GameEnd.dwChiHuRight[i] & GameDef.CHR_ZI_MO) { this.PlayActionSound(i, "ZIMO"); } else { this.PlayActionSound(i, "HU"); } } } } else { cc.gSoundRes.PlayGameSound("GAME_END"); } var WaitTime = 3; // if(this.m_GameEnd.cbBirdCardCount > 0) // { // this.m_GameClientView.ShowBird(this.m_GameEnd.cbBirdCard, this.m_GameEnd.cbBirdCardCount); // WaitTime = 4; // } //设置定时 this.schedule(this.OnTimeIDI_PERFORM_END, WaitTime); // this.OnTimeIDI_PERFORM_END(); return true; }, //用户托管 OnSubTrustee: function (pData, wDataSize) { var pTrustee = GameDef.CMD_S_Trustee(); if (wDataSize != gCByte.Bytes2Str(pTrustee, pData)) return false; this.m_GameClientView.SetTrustee(pTrustee.wChairID, pTrustee.bTrustee); var wMeChairID = this.GetMeChairID(); if (wMeChairID == pTrustee.wChairID) { this.m_bStustee = pTrustee.bTrustee; if (pTrustee.bTrustee) { if (this.m_bEnd) { if (this.m_EndLittleView) { this.m_EndLittleView.HideView(); } this.checkTotalEnd(true); } else { this.StusteeOperateCard(pTrustee.wChairID); } } } console.log("是否托管---", this.m_bStustee) return true; }, OnSubLeave: function (pData, wDataSize) { var pLeave = GameDef.CMD_S_Leave(); if (wDataSize != gCByte.Bytes2Str(pLeave, pData)) return false; this.m_GameClientView.SetUserTimer(this.SwitchViewChairID(this.m_wCurrentUser), 0); // for(var i = 0; i < GameDef.GAME_PLAYER; ++ i) // this.m_GameClientView.SetLeave(this.SwitchViewChairID(i), pLeave.bLeave[i]); return true; }, OnSubPlayerDouble: function (pData, wDataSize) { var pDouble = GameDef.CMD_S_Double(); if (wDataSize != gCByte.Bytes2Str(pDouble, pData)) return false; var viewID = this.SwitchViewChairID(pDouble.wCallUser); this.m_GameClientView.m_UserInfo[viewID].SetGang(pDouble.cbDouble); return true; }, UpdateHandActionCard: function () { }, OnTing: function (pData, wDataSize) { var pTing = new Object(); pTing.wCount = 0; var size = gCByte.Bytes2Str(pTing, pData); var pObj = new Object() pObj.pItem = new Array(pTing.wCount); for (var i = 0; i < pTing.wCount; i++) { pObj.pItem[i] = GameDef.CMD_TingTip(); } console.log("听--", pObj) //效验 if (wDataSize != gCByte.Bytes2Str(pObj, pData, size) + size) return false; var wMeChairID = this.GetMeChairID(); this.m_GameClientView.m_CardView.ShowTingData(pObj.pItem, this.m_bListen[wMeChairID]); return true; }, OnUpdateCardData: function (pData, wDataSize) { var pHandCardData = GameDef.CMD_S_HandCardData(); if (wDataSize != gCByte.Bytes2Str(pHandCardData, pData)) return false; console.log("刷新pHandCardData--", pHandCardData); var wMeChairID = this.GetMeChairID(); if (pHandCardData.wChairID == wMeChairID) { this.m_cbCardIndex = new Array(); this.m_GameLogic.SwitchToCardIndex3(pHandCardData.cbCardData, pHandCardData.wCardCount, this.m_cbCardIndex); this.m_GameClientView.m_CardView.SetSelfCardIndex(this.m_cbCardIndex, pHandCardData.cbSendCardData, this.m_bListen[wMeChairID], pHandCardData.cbCantOutCard); } else { var viewID = this.SwitchViewChairID(pHandCardData.wChairID); if (this.m_ReplayMode) { if (pHandCardData.cbCardData[0] != 0) { if ((pHandCardData.wCardCount + 1) % 3 == 0) { var curCardData = pHandCardData.cbSendCardData; if (curCardData == 0) curCardData = pHandCardData.cbCardData[0] this.m_GameClientView.m_CardView.SetCardData(viewID, pHandCardData.cbCardData, pHandCardData.wCardCount, curCardData); } else { this.m_GameClientView.m_CardView.SetCardData(viewID, pHandCardData.cbCardData, pHandCardData.wCardCount); } } } else { // if((pHandCardData.wCardCount+1)%3==0){ // this.m_GameClientView.m_CardView.SetCardData(viewID,null,pHandCardData.wCardCount-1,0); // }else{ // this.m_GameClientView.m_CardView.SetCardData(viewID,null,pHandCardData.wCardCount); // } this.m_GameClientView.m_CardView.SetCardData(viewID, null, pHandCardData.wCardCount); } } var i = pHandCardData.wChairID; this.m_cbWeaveCount[i] = pHandCardData.dwWeaveCount; for (var j = 0; j < GameDef.MAX_WEAVE; ++j) { this.m_WeaveItemArray[i][j].wWeaveKind = pHandCardData.WeaveItem[j].wWeaveKind; this.m_WeaveItemArray[i][j].cbCenterCard = pHandCardData.WeaveItem[j].cbCenterCard; this.m_WeaveItemArray[i][j].cbPublicCard = pHandCardData.WeaveItem[j].cbPublicCard; this.m_WeaveItemArray[i][j].wProvideUser = pHandCardData.WeaveItem[j].wProvideUser; this.m_WeaveItemArray[i][j].cbCardCount = pHandCardData.WeaveItem[j].cbCardCount; for (var k = 0; k < 4; ++k) { this.m_WeaveItemArray[i][j].cbCardData[k] = pHandCardData.WeaveItem[j].cbCardData[k]; this.m_WeaveItemArray[i][j].cbExtraCount[k] = pHandCardData.WeaveItem[j].cbExtraCount[k]; } } var ViewID = this.SwitchViewChairID(i); for (var j = 0; j < this.m_cbWeaveCount[i]; j++) { this.m_GameClientView.m_CardView.SetWeaveData(ViewID, j, this.m_WeaveItemArray[i][j].cbCardData, this.m_WeaveItemArray[i][j].cbCardCount); this.m_GameClientView.m_CardView.SetWeaveState(ViewID, j, this.m_WeaveItemArray[i][j]); } return true; }, //开始选刚 OnSubStartDouble: function (pData, wDataSize) { var pGameDouble = GameDef.CMD_S_Game_Double(); if (wDataSize != gCByte.Bytes2Str(pGameDouble, pData)) return false; this.m_bStustee = false; this.m_wBankerUser = pGameDouble.wBankerUser; var bankerViewID = this.SwitchViewChairID(this.m_wBankerUser); this.m_GameClientView.SetBankerUser(bankerViewID); this.m_cbGameStatus = GameDef.GAME_SCENE_DOUBLE; this.SetGameClock(INVALID_CHAIR, GameDef.IDI_OPERATE_CARD, this.GetOperateTime()); this.m_GameClientView.m_BtStart.active = false; this.m_GameClientView.m_BtFriend.active = false; this.m_BtExit.active = false; this.m_BtDissolve.active = true; //回放、观战不显示选飘界面 var kernel = gClientKernel.get(); if (this.m_ReplayMode || kernel.IsLookonMode()) return true; for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var viewId = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[viewId].SetTing(false); this.m_GameClientView.m_UserInfo[viewId].SetGang(0); this.m_GameClientView.SetTrustee(i, false); } this.m_GameClientView.SetGangOperator(1); return true; }, OnMessageStart: function () { //this.ShowHead(true); this.KillGameClock(); //隐藏按钮 this.m_GameClientView.m_BtStart.active = false; //this.m_GameClientView.m_BtFriend.active = false; this.m_GameClientView.m_CardView.SetControlInfo(false); this.m_GameClientView.SetCurrentUser(INVALID_CHAIR); //设置界面 this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR); this.m_GameClientView.SetBankerUser(INVALID_CHAIR); this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); //关闭显示花,风位 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { if (this.GetClientUserItem(i) == null) continue; var OtherViewID = this.SwitchViewChairID(i); this.m_GameClientView.m_UserInfo[OtherViewID].SetShowFenganFlower(); } //隐藏骰子 this.m_GameClientView.ShowDice(false); this.m_GameClientView.m_CardView.ResetView(); //扑克设置 //游戏变量 this.m_wCurrentUser = INVALID_CHAIR; this.m_wActionMask = 0; for (var i = 0; i < GameDef.GAME_PLAYER; ++i) { this.m_cbWeaveCount[i] = 0; for (var j = 0; j < GameDef.MAX_WEAVE; ++j) { this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem(); } } //扑克变量 this.m_cbLeftCardCount = 0; for (var i = 0; i < 42; ++i)//GameDef.MAX_INDEX { this.m_cbCardIndex[i] = 0; } //if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7) //{ // this.m_GameClientView.SetLeftCardCount(112); //} //else //{ // this.m_GameClientView.SetLeftCardCount(108); //} this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY); //设置用户动作 this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); var kernel = gClientKernel.get(); if (kernel.IsLookonMode() == false) { //发送准备 this.SendUserReady(null, 0); } }, CleanView: function (bOffLineBack) { this.Init(); this.waitOperate = false; this.m_GameClientView.m_CardView.SetControlInfo(false); this.m_GameClientView.SetCurrentUser(INVALID_CHAIR); //设置界面 this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR); this.m_GameClientView.SetBankerUser(INVALID_CHAIR); this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); //扑克设置 this.m_GameClientView.m_CardView.ResetView(); //游戏变量 this.m_wCurrentUser = INVALID_CHAIR; this.m_wActionMask = 0; this.m_wTimeOutCount = 0; for (var i = 0; i < GameDef.GAME_PLAYER; ++i) { this.m_cbWeaveCount[i] = 0; for (var j = 0; j < GameDef.MAX_WEAVE; ++j) { this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem(); } } //扑克变量 this.m_cbLeftCardCount = 0; for (var i = 0; i < 42; ++i)//GameDef.MAX_INDEX { this.m_cbCardIndex[i] = 0; } if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7) { this.m_GameClientView.SetLeftCardCount(112); } else { this.m_GameClientView.SetLeftCardCount(108); } this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY); //设置用户动作 this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); }, //补牌 OnReplaceCard: function (cbCardData) { //构造数据 this.m_GameClientView.m_CardView.SetControlInfo(false); var ReplaceCard = GameDef.CMD_C_ReplaceCard4(); ReplaceCard.cbCardData[0] = cbCardData; ReplaceCard.cbCardCount = 1; console.log("补花", cbCardData, ReplaceCard) //发送数据 // if (this.m_ReplayMode) return 0; this.SendGameData(GameDef.SUB_C_REPLACE_CARD, ReplaceCard); return 0; }, //出牌消息 OnOutCard: function (HandState, CardIndex, cbCardData, bAdd) { //出牌判断 if (this.m_wCurrentUser != this.GetMeChairID()) return 0; // 检查 cbOutCardData 是否大于 55 // if (cbCardData > 55) return 0; //设置变量 this.m_wCurrentUser = INVALID_CHAIR; this.m_wActionMask = 0; var cbOutCardData = cbCardData; //设置界面 this.m_GameClientView.m_CardView.SetControlInfo(false); //定义变量 var wMeChairId = this.GetMeChairID(); var wOutCardUser = this.GetMeChairID(); var wViewOutCardUser = this.SwitchViewChairID(wOutCardUser); // this.PlayActionSound(wMeChairId,this.GetCardStr(cbOutCardData),true); //环境设置 this.KillGameClock(); //设置变量 this.m_wCurrentUser = INVALID_CHAIR; this.m_wActionMask = 0; //设置界面 this.m_GameClientView.SetCurrentUser(INVALID_CHAIR); this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); //构造数据 var OutCard = GameDef.CMD_C_OutCard(); OutCard.cbCardData = cbOutCardData; OutCard.bAddGang = bAdd == true ? true : false; //发送数据 this.SendGameData(GameDef.SUB_C_OUT_CARD, OutCard); return 0; }, //扑克操作 OnCardOperate: function (wOperateCode, cbOperateCard, cbCardCount, cbIndex) { //变量定义 if (this.m_bFirstCard == false && wOperateCode == 0 && this.m_wCurrentUser == this.GetMeChairID()) { this.m_GameClientView.m_CardView.SetControlInfo(false); var wViewID = this.SwitchViewChairID(this.GetMeChairID()); this.m_GameClientView.m_CardView.m_HandCard[wViewID].SetCanTouch(true); if (this.m_bStustee == false) { this.ListenAutoOutCard(this.m_wCurrentUser); } return; } //补扭走打牌逻辑 if (wOperateCode & (GameDef.WIK_ADD_ZFB | GameDef.WIK_ADD_DNJ | GameDef.WIK_ADD_FENG)) { this.m_GameClientView.m_CardView.m_HandCard[2].SetOutCard(cbOperateCard[0]); this.OnOutCard(0, 0, cbOperateCard[0], true); return; } //删除时间 this.KillGameClock(); this.m_wCurrentUser = INVALID_CHAIR; this.m_wActionMask = 0; //构造数据 var OperateCard = GameDef.CMD_C_OperateCard(); OperateCard.wOperateCode = wOperateCode; OperateCard.cbOperateCard[0] = cbOperateCard[0]; OperateCard.cbOperateCard[1] = cbOperateCard[1]; OperateCard.cbOperateCard[2] = cbOperateCard[2]; OperateCard.cbOperateCard[3] = cbOperateCard[3]; OperateCard.cbOperateCount = cbCardCount; OperateCard.cbIndex = cbIndex; console.log("发送胡牌操作",OperateCard) //发送数据 this.SendGameData(GameDef.SUB_C_OPERATE_CARD, OperateCard); this.m_GameClientView.m_CardView.m_HandCard[2].SetCanTouch(false); this.m_GameClientView.m_CardView.SetControlInfo(false); return 0; }, //扑克操作 OnDoubleOperate: function (cbDouble) { this.KillGameClock(); var Double = GameDef.CMD_C_Double(); Double.cbDouble = cbDouble; //发送数据 this.SendGameData(GameDef.SUB_C_USER_DOUBLE, Double); return 0; }, OnCancelTrustee: function (bTrustee) { var Trustee = GameDef.CMD_C_Trustee(); Trustee.bTrustee = bTrustee; //发送数据 this.SendGameData(GameDef.SUB_C_TRUSTEE, Trustee); }, // //扑克操作 // OnStusteeControl:function(wParam, lParam){ // //设置变量 // this.m_wTimeOutCount=0; // if(this.m_bStustee&&lParam==true)return 0; // if(!this.m_bStustee&&lParam==0)return 0; // //设置状态 // this.m_bStustee = this.m_bStustee?false:true; // //构造数据 // var Trustee = GameDef.CMD_C_Trustee(); // Trustee.bTrustee = this.m_bStustee; // //发送数据 // this.SendGameData(GameDef.SUB_C_TRUSTEE, Trustee); // return 0; // }, // //离开控制 // OnLeaveControl: function(event, customData){ // if(customData != 0){ // this.m_LeaveControl.ShowView(true); // this.m_bLeave = true; // }else{ // this.m_LeaveControl.ShowView(false); // this.m_bLeave = false; // this.SetGameClock(this.GetMeChairID(),GameDef.IDI_OPERATE_CARD,GameDef.TIME_OPERATE_CARD); // } // //构造数据 // var Leave = GameDef.CMD_C_Leave(); // Leave.bLeave = this.m_bLeave; // //发送数据 // this.SendGameData(GameDef.SUB_C_LEAVE, Leave); // return 0; // }, OnNextReady: function () { this.KillGameClock(); //游戏变量 this.m_lCellScore = 0; //设置当前玩家 this.m_wCurrentUser = INVALID_CHAIR; //隐藏按钮 this.m_GameClientView.m_BtStart.active = false; //设置游戏状态 this.m_GameClientView.SetPlayStatus(INVALID_CHAIR, 0); this.m_GameClientView.m_CardView.SetControlInfo(false); this.m_GameClientView.SetCurrentUser(INVALID_CHAIR); //设置界面 this.m_GameClientView.m_CardView.SetDiscardTip(INVALID_CHAIR); this.m_GameClientView.SetBankerUser(INVALID_CHAIR); this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); //扑克设置 this.m_GameClientView.m_CardView.ResetView(); //游戏变量 this.m_wCurrentUser = INVALID_CHAIR; this.m_wActionMask = 0; for (var i = 0; i < GameDef.GAME_PLAYER; ++i) { this.m_cbWeaveCount[i] = 0; for (var j = 0; j < GameDef.MAX_WEAVE; ++j) { this.m_WeaveItemArray[i][j] = GameDef.tagWeaveItem(); } } //扑克变量 this.m_cbLeftCardCount = 0; for (var i = 0; i < 42; ++i) {//GameDef.MAX_INDEX this.m_cbCardIndex[i] = 0; } if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_SP_7) { this.m_GameClientView.SetLeftCardCount(112); } else { this.m_GameClientView.SetLeftCardCount(108); } this.m_GameClientView.SetLeftCardCount(GameDef.MAX_REPERTORY); //设置用户动作 this.m_GameClientView.SetUserAction(INVALID_CHAIR, 0); this.SendGameData(GameDef.SUB_C_NEXT_READY, null); }, //执行结束 OnTimeIDI_PERFORM_END: function () { this.unschedule(this.OnTimeIDI_PERFORM_END); this.m_bEnd = true; //成绩界面 this.ShowGamePrefab("LittleResultBG", GameDef.KIND_ID, this.node, function (Js) { this.m_EndLittleView = Js; //this.m_EndLittleView.SetTrustee(this.m_bStustee); }.bind(this)); //this.ShowPrefabDLG('LittleResultBG_21201'); }, checkTotalEnd: function (bNext) { this.m_bEnd = false; if (this.m_RoomEnd) { if (this.m_wGameProgress > 0 || this.m_ReplayMode) { this.showRealEndView(); } else { this.ShowAlert("該房間已被解散!", Alert_Yes, function (Res) { this.m_pTableScene.ExitGame(); }.bind(this)); } } else { var kernel = gClientKernel.get(); if (!kernel.IsLookonMode() && bNext) this.OnMessageStart(); } this.m_bCanShowBigEnd = true; }, //发送准备 SendUserReady: function (pBuffer, wDataSize) { var kernel = gClientKernel.get(); if (kernel == 0 || kernel == null || kernel.IsLookonMode()) return; kernel.SendSocketData(MDM_GF_FRAME, SUB_GF_USER_READY, pBuffer, wDataSize); }, //出牌声音字符串 GetCardStr: function (cbCardData) { var str = ""; var color = cbCardData & 0xf0; var value = cbCardData & 0x0f; if (color == 0) str = "W_"; if (color == 0x10) str = "S_"; if (color == 0x20) str = "T_"; if (color == 0x30) str = "F_"; str = str + value.toString(); return str; }, //播放操作声音 PlayActionSound: function (wChairId, byAction, chuyin) { if (this.m_bRollBack) return; //椅子效验 var kernel = gClientKernel.get(); var pIClientUserItem = kernel.GetTableUserItem(wChairId); if (pIClientUserItem == null) return; console.log(pIClientUserItem) console.log(wChairId, byAction, chuyin) if (pIClientUserItem.GetGender() == 1) { cc.gSoundRes.PlayGameSound("M_" + byAction + "L" + wChairId); } else { cc.gSoundRes.PlayGameSound("W_" + byAction + "L" + wChairId); // cc.gSoundRes.PlayGameSound("W_" + byAction); } if (chuyin) { cc.gSoundRes.PlayGameSound("CHUPAI"); } }, OnExitGame: function () { //退出游戏 this.m_TableViewFrame.ExitGame(); }, ExitGame: function () { this.OnExitGame(); }, ////////////////////////////////////////////////////////////////////////// //获取用户 GetClientUserItem: function (wChairID) { var kernel = gClientKernel.get(); if (kernel == 0 || kernel == null || kernel == undefined) return null; return kernel.GetTableUserItem(wChairID); }, GetGameStatus: function () { var kernel = gClientKernel.get(); if (!kernel) return GAME_SCENE_FREE; return kernel.GetGameStatus(); }, IsValidChairID: function (wChairID) { if (wChairID >= 0 && wChairID < GameDef.GAME_PLAYER) return true; return false; }, // 获取座位 GetUserChairID: function (dwUserID) { for (var i = 0; i < GameDef.GAME_PLAYER; ++i) { var pIClientUserItem = this.GetClientUserItem(i); if (!pIClientUserItem) continue; if (pIClientUserItem.GetUserID() == dwUserID) return i; } return INVALID_CHAIR; }, SetViewRoomInfo: function (dwServerRules, dwRulesArr) { if (this.m_GameClientView) this.m_GameClientView.SetViewRoomInfo(dwRulesArr, dwServerRules); GameDef.setRule(dwServerRules, dwRulesArr); this.updateUserCount(); this.m_GameClientView.m_CardView.m_CenterViewCtrl.updateNorth(); this.m_GameClientView.updateGameRule(); //this.m_GameClientView.m_Trustee.string = GameDef.GetTrusteeString(this.m_dwRules); }, OnEventRoomEnd: function (data, datasize) { this.m_RoomEnd = GameDef.CMD_S_GameCustomInfo(); if (datasize != gCByte.Bytes2Str(this.m_RoomEnd, data)) return false; console.log("总结束", this.m_RoomEnd) this.m_RoomEnd.UserID = new Array(); //用户成绩 for (var i = 0; i < GameDef.GAME_PLAYER; i++) { //变量定义 var pIClientUserItem = this.GetClientUserItem(i); if (pIClientUserItem == null) continue; this.m_RoomEnd.UserID[i] = pIClientUserItem.GetUserID(); } if (this.m_wGameProgress > 0 || this.m_ReplayMode) { this.m_GameClientView.m_BtStart.active = false; this.KillGameClock(); if (this.m_bCanShowBigEnd) { this.showRealEndView(); } } else { var self = this; this.ShowAlert("該房間已被解散!", Alert_Yes, function (Res) { self.m_pTableScene.ExitGame(); }); } return true; }, showRealEndView() { this.RealShowEndView(); GameDef.m_AllCardItem = []; }, //点击安全监测 OnBtClickedSafe: function () { cc.gSoundRes.PlaySound('Button'); this.ShowGamePrefab('SafeCheck_21201'); }, ChangeCardBack: function (index) { this.m_CardBack = index; if (this.m_GameClientView.m_CardView == null) { this.m_GameClientView.Init(); } this.m_GameClientView.m_CardView.ChangeCardBack(this.node, index); this.m_GameClientView.ChangeCardBack(index); }, //震动会牌 ShockHuiPai: function () { if (this.m_bRollBack) return; this.m_GameClientView.ShockHuiPai(); }, updateUserCount: function () { this.m_GameClientView.m_CardView.UpdateUserCount(); this.m_GameClientView.updateUserCount(); }, //邀请好友分享 OnFriend: function () { if (cc.sys.isNative) { this.ShowPrefabDLG("SharePre"); } else { // this.m_GameClientView.m_FriendBg.node.active = true; } }, OnClearScene: function () { if (this.m_EndLittleView) this.m_EndLittleView.HideView(); var CardBack = cc.sys.localStorage.getItem(window.Key_CardColor); if (CardBack) { this.ChangeCardBack(CardBack); } else { this.ChangeCardBack(0); } this.CleanView(); }, GetOperateTime: function () { if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_15) { return GameDef.TIME_OPERATE_CARD_15; } else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_30) { return GameDef.TIME_OPERATE_CARD_30; } else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_60) { return GameDef.TIME_OPERATE_CARD_60; } else if (this.m_dwRulesArr[0] & GameDef.GAME_RULE_TUOGUAN_NONE) { return GameDef.TIME_OPERATE_CARD; } }, //测试 __test: function () { this.m_GameClientView.m_CardView.setUserCount(4); this.m_GameClientView.m_CardView.SetClientEngine(this); this.m_CardData = new Array(); this.m_CardData = [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //万子 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, //索子 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, //同子 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, //番子 ]; this.m_GameClientView.m_CardView.SetCardData(0, this.m_CardData, 10); this.m_GameClientView.m_CardView.SetCardData(1, this.m_CardData, 10); this.m_GameClientView.m_CardView.SetCardData(2, this.m_CardData, 10); this.m_GameClientView.m_CardView.SetPositively(true); var weaveCard = new Array(); weaveCard[0] = 0x21; weaveCard[1] = 0x21; weaveCard[2] = 0x21; weaveCard[3] = 0x21; this.m_GameClientView.m_CardView.SetWeaveData(0, 0, weaveCard, 4); // this.m_GameClientView.m_CardView.SetWeaveData(1,0,weaveCard,4); this.m_GameClientView.m_CardView.SetWeaveData(2, 0, weaveCard, 4); // this.m_GameClientView.m_CardView.SetWeaveData(3,0,weaveCard,4); // this.m_GameClientView.m_CardView.SetCardData(3,cardData,13,0x02); this.DiscardDate = 0x22; this.m_GameClientView.m_CardView.SetDiscardCardDate(0, this.m_CardData, 33); this.m_GameClientView.m_CardView.SetDiscardCardDate(1, this.m_CardData, 33); this.m_GameClientView.m_CardView.SetDiscardCardDate(2, this.m_CardData, 33); this.m_GameClientView.m_CardView.SetDiscardCardDate(3, this.m_CardData, 33); // this.m_GameClientView.m_CardView.PlayDiscard(0,13); }, });