void GetComponents() { m_sceneTransition = GetComponent <SceneTransition>(); m_gameLoading = GetComponent <GameLoading>(); m_emptyDataHandler = GetComponent <EmptyDataSaving>(); m_gameSaving = GetComponent <GameSaving>(); }
public void LoadCreditsScene() { if (!isLoading) { GameLoading?.Invoke(); StartCoroutine(Loading("Credits")); } }
private void OutGame() { GameClient.Instance.MG.Reset(); Reset(); UIGameSetingController.Instance.Close(); UIGameResultController.Instance.Close(); GameLoading.SwitchScene(2); }
private void Construct(SceneTransition sceneTransition, GameSaving gameSaving, GameLoading gameLoading, PauseMenuToggler pauseMenuToggler) { _sceneTransition = sceneTransition; _gameSaving = gameSaving; _gameLoading = gameLoading; _pauseMenuToggler = pauseMenuToggler; }
public void LoadGameScene() { // audioSources[0].Play(); // audioSources[1].Play(); if (!isLoading) { GameLoading?.Invoke(); StartCoroutine(Loading("Game")); } }
void OnStartLoading(GameLoading gl) { Debug.Log("start loading " + GameLoading.level); if (slider != null) { slider.maxValue = 100; } Resources.UnloadUnusedAssets(); GameClient.Instance.AssetLoader.CheckVersion("", delegate() { }); CreateDontDestroy(); switch (GameLoading.level) { case 0: // break; case 1: //login { } break; case 2: //mainmenu break; case 3: //game { var effectRes = new InGameEffectRes(); Debug.Log("current task count -> " + GameClient.Instance.AssetLoader.TaskCount()); var res0 = new MahjongGameRes(); Debug.Log("current task count -> " + GameClient.Instance.AssetLoader.TaskCount()); var res1 = new InGame2dRes(); Debug.Log("current task count -> " + GameClient.Instance.AssetLoader.TaskCount()); } break; default: Debug.LogError("Unknown level :" + GameLoading.level); break; } }
private void Construct(SceneTransition sceneTransition, GameLoading gameLoading) { _sceneTransition = sceneTransition; _gameLoading = gameLoading; }
private static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("+---------------------------+\n" + "| MAIN MENU |\n" + "+---------------------------+"); Console.ForegroundColor = ConsoleColor.Cyan; var playerType = new Menu(MenuLevel.Level2Plus); playerType.AddMenuItem(new MenuItem( "Player VS Player", "1", Battleship)); playerType.AddMenuItem(new MenuItem( "Player vs AI", "2", BattleshipPlayerAi)); playerType.AddMenuItem(new MenuItem( "AI vs AI", "3", BattleshipAiAi)); var gameType = new Menu(MenuLevel.Level1); gameType.AddMenuItem(new MenuItem( "Start Basic Game", "S", playerType.RunMenu )); gameType.AddMenuItem(new MenuItem( "Start Custom Game", "C", CustomBattleship )); gameType.AddMenuItem(new MenuItem( "Load Last Game", "L", LoadGame )); gameType.AddMenuItem(new MenuItem( "Load All Games", "O", () => { var allGamesMenu = new Menu(MenuLevel.Level2Plus); foreach (var(id, desc) in GameLoading.GetListOfAllGames()) { allGamesMenu.AddMenuItem(new MenuItem( desc, id.ToString(), () => LoadGameById(id) )); } if (!GameLoading.GetListOfAllGames().Any()) { Console.Write("No saved games!"); } return(allGamesMenu.RunMenu()); }
public void InitBaseMessage(OdaoClient client) { _gsProxy = client; var playerInfo = UIOperation.playerLobbyInfo; _gsProxy.on(BaseMessage.LOGIN_REQ_MSG, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; //BaseMessage.LoginResDef data = XConvert.ConvertToObject<BaseMessage.LoginResDef>(msg.data); var serializer = MsgPack.Serialization.MessagePackSerializer.Get <BaseMessage.LoginResDef>(); var data = serializer.UnpackSingleObject(msg.data); Debug.LogError("LOGIN_RES_MSG: " + BaseMessage.LOGIN_REQ_MSG + ",cErrorCode:" + data.cErrorCode + ", iUserID:" + data.iUserID + ",accountId:" + data.accountId + ",serviceId:" + data.serviceId + ",szPasswdToken:" + data.szPasswdToken + ",cGender:" + data.cGender + ",cVipLv:" + data.cVipLv + ",llGameCoin:" + data.llGameCoin + ",llBankCoin:" + data.llBankCoin + ",llDiamondNum:" + data.llDiamondNum + ",llGoldBean:" + data.llGoldBean + ",szNickName:" + data.szNickName + ",szWXIconURL:" + data.szWXIconURL + ",szWXNickName:" + data.szWXNickName + ",iVipExp:" + data.iVipExp + ",cLevel:" + data.cLevel + ",iLevelExp:" + data.iLevelExp); playerInfo.iUserID = data.iUserID; playerInfo.accountId = data.accountId; playerInfo.serviceId = data.serviceId; playerInfo.szPasswdToken = data.szPasswdToken; playerInfo.cGender = data.cGender; playerInfo.cVipLv = data.cVipLv; playerInfo.llGameCoin = data.llGameCoin; playerInfo.llBankCoin = data.llBankCoin; playerInfo.llDiamondNum = data.llDiamondNum; playerInfo.llGoldBean = data.llGoldBean; playerInfo.szNickName = data.szNickName; playerInfo.szWXIconURL = data.szWXIconURL; playerInfo.szWXNickName = data.szWXNickName; playerInfo.iVipExp = data.iVipExp; playerInfo.cLevel = data.cLevel; playerInfo.iLevelExp = data.iLevelExp; #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { //GameLoading.SwitchScene(2); UnityEngine.SceneManagement.SceneManager.LoadScene(2); }); if (data.cErrorCode == 0) { var gameClient = GameClient.Instance; gameClient.MahjongGamePlayer.ConnectGameServer(UIOperation.ipRes, 36665, delegate() { gameClient.MahjongGamePlayer.LobbyLoginReqDef(data.iUserID, data.szPasswdToken); }); } #endif }); _gsProxy.on(BaseMessage.LOBBY_LOGIN_RES_MSG, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; //BaseMessage.LoginResDef data = XConvert.ConvertToObject<BaseMessage.LoginResDef>(msg.data); var serializer = MsgPack.Serialization.MessagePackSerializer.Get <BaseMessage.LobbyLoginResDef>(); var data = serializer.UnpackSingleObject(msg.data); Debug.LogError("LOBBY_LOGIN_RES_MSG: " + BaseMessage.LOBBY_LOGIN_RES_MSG + ", cErrorCode:" + data.cErrorCode + ",iUserID:" + data.iUserID); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { //GameLoading.SwitchScene(2); //UnityEngine.SceneManagement.SceneManager.LoadScene(2); }); #endif }); _gsProxy.on(BaseMessage.LOBBY_SHOP_EXCHANGE_COIN_RES_MSG, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; //BaseMessage.LoginResDef data = XConvert.ConvertToObject<BaseMessage.LoginResDef>(msg.data); var serializer = MsgPack.Serialization.MessagePackSerializer.Get <BaseMessage.BuyGoldResDef>(); var data = serializer.UnpackSingleObject(msg.data); Debug.LogError("LOBBY_SHOP_EXCHANGE_COIN_RES_MSG: " + BaseMessage.LOBBY_SHOP_EXCHANGE_COIN_RES_MSG + ", cErrorCode:" + data.cErrorCode + ",iAddCoin:" + data.iAddCoin + ",iSubIDiamond:" + data.iSubIDiamond); if (data.cErrorCode == 0) { playerInfo.llGameCoin += data.iAddCoin; playerInfo.llDiamondNum -= data.iSubIDiamond; } else if (data.cErrorCode == 1) { //钻石不足 } else { //配置错误 } }); _gsProxy.on(BaseMessage.LOBBY_MODIFY_NICK_NAME_RES_MSG, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; //BaseMessage.LoginResDef data = XConvert.ConvertToObject<BaseMessage.LoginResDef>(msg.data); var serializer = MsgPack.Serialization.MessagePackSerializer.Get <BaseMessage.ChangeNameResDef>(); var data = serializer.UnpackSingleObject(msg.data); Debug.LogError("LOBBY_MODIFY_NICK_NAME_RES_MSG: " + BaseMessage.LOBBY_MODIFY_NICK_NAME_RES_MSG + ", cErrorCode:" + data.cErrorCode + ",iSubDiamond:" + data.iSubDiamond + ",szNickName:" + data.szNickName); if (data.cErrorCode == 0) { playerInfo.szNickName = data.szNickName; playerInfo.llDiamondNum -= data.iSubDiamond; //GameObject.Find("Canvas/personalInfoPanel/comfirmPanel").SetActive(false); } else if (data.cErrorCode == 1) { //钻石不足 } else { //配置错误 } }); _gsProxy.on(BaseMessage.LOBBY_MODIFY_GENDER_RES_MSG, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; //BaseMessage.LoginResDef data = XConvert.ConvertToObject<BaseMessage.LoginResDef>(msg.data); var serializer = MsgPack.Serialization.MessagePackSerializer.Get <BaseMessage.ChangeGenderResDef>(); var data = serializer.UnpackSingleObject(msg.data); Debug.LogError("LOBBY_MODIFY_GENDER_RES_MSG: " + BaseMessage.LOBBY_MODIFY_GENDER_RES_MSG + ", cErrorCode:" + data.cErrorCode + ",cGender:" + data.cGender); if (data.cErrorCode == 0) { playerInfo.cGender = data.cGender; Loom.QueueOnMainThread(delegate() { PlayerDataManager.Instance.LoadGenderImage(); }); } else if (data.cErrorCode == 1) { //钻石不足 } else { //配置错误 } }); _gsProxy.on(BaseMessage.AUTHEN_RES_MSG, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; BaseMessage.AuthenResDef data = XConvert.ConvertToObject <BaseMessage.AuthenResDef> (msg.data); Debug.Log("AUTHEN_RES_MSG " + data.cError + "," + data.iPlayerServerID + "," + data.iPlayerGameID); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { GameLoading.SwitchScene(2); }); #endif }); _gsProxy.on(BaseMessage.AGAIN_LOGIN_RES_MSG, delegate(Message obj) { Debug.Log("AGAIN_LOGIN_RES_MSG "); OdaoMessage msg = (OdaoMessage)obj; int offset = 0; BaseMessage.AgainLoginRes data = XConvert.ConvertToObject <BaseMessage.AgainLoginRes> (msg.data, ref offset); Debug.Log("AGAIN_LOGIN_RES_MSG " + data.iUserID + "," + data.iServerTime + "," + data.iTableNum + "," + data.usTableNumExtra + "," + data.cPlayerNum); //userinfo for (int i = 0; i < data.cPlayerNum; ++i) { BaseMessage.PlayerInfoExtra userInfo = XConvert.ConvertToObject <BaseMessage.PlayerInfoExtra> (msg.data, ref offset); //byte[] bytes = System.Text.Encoding.GetEncoding("GBK").GetBytes(userInfo.szUserName); //string name = System.Text.Encoding.UTF8.GetString(bytes); } int tempHandCardLen = 0; #if USER_MP byte[] dataMP = msg.data.Skip(offset).ToArray(); /* * System.IO.FileStream fsForWrite = new System.IO.FileStream("MP.GameMessage.GameStateDef.bytes", System.IO.FileMode.Create); * try * { * fsForWrite.Write(dataMP,0,dataMP.Length); * } * catch(Exception ex) * { * Debug.Log(ex.ToString()); * } * finally * { * fsForWrite.Close(); * } */ var serializer = MsgPack.Serialization.MessagePackSerializer.Get <MP.GameMessage.GameStateDef>(); GameMessage.GameStateDef info = serializer.UnpackSingleObject(dataMP); tempHandCardLen = info.cHandCards.Count; #else GameMessage.GameStateDef info = XConvert.ConvertToObject <GameMessage.GameStateDef>(msg.data, ref offset); tempHandCardLen = info.cHandCards.Length; #endif #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN GameClient.Instance.GameStateDef = info; #endif PocketList.Clear(); // total 14 for (int i = 0; i < tempHandCardLen; ++i) { if (TileDef.IsValid(info.cHandCards [i])) { TileDef def = TileDef.Create(info.cHandCards [i]); PocketList.Add(def); } } #if USER_MP //玩家已经出的牌 List <TileDef> list = new List <TileDef>(); for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; ++i) { for (int j = 0; j < info.cSendCards[i].cCards.Count; ++j) { byte card = info.cSendCards[i].cCards[j]; Console.Write("{0} ", card); list.Add(TileDef.Create(card)); } Debug.Log("##################"); } #else //玩家已经出的牌 List <TileDef> list = new List <TileDef> (); for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; ++i) { for (int j = 0; j < 21; ++j) { byte card = info.cSendCards [i * 21 + j]; Console.Write("{0} ", card); list.Add(TileDef.Create(card)); } Debug.Log("##################"); } #endif MahjongTile.TotalClickCount = 1; //HUAN PAI if (info.iGameStates == GameMessage.GS_WK_HUANPAI) { for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; i++) { UIOperation.Instance._headDatas[i].gameState = UIOperation.gameState.XUANPAI; UIOperation.Instance._headDatas[i].isShow = true; } for (int i = 0; i < info.v_RecommendCard.Count; i++) { if (i < GameMessage.MAXHUANPAINUM) { UIOperation.Instance._HuanPaiOldDef[i] = TileDef.Create(info.v_RecommendCard[i]); } } MahjongTile.TotalClickCount = 3; } else if (info.iGameStates == GameMessage.GS_WK_DINGQUE) { //DING QUE for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; i++) { UIOperation.Instance._headDatas[i].gameState = UIOperation.gameState.DINGQUE; UIOperation.Instance._headDatas[i].isShow = true; } } if (info.cDingQueCards.Count > 0) { //定缺完毕 for (int i = 0; i < info.cDingQueCards.Count; ++i) { TileDef.Kind k = (TileDef.Kind)info.cDingQueCards[i]; if (k != TileDef.Kind.NONE) { UIOperation.Instance._headDatas[i].dingque = k; UIOperation.Instance._headDatas[i].gameState = UIOperation.gameState.NONE; } } } GameClient.Instance.SpecialType = 0; if (info.iSpecialTypeTotal > 0 && info.v_SpecialCard.Count > 0) { //等待吃碰杠胡 GameClient.Instance.SpecialCard = info.v_SpecialCard[0]; GameClient.Instance.SpecialType = info.iSpecialTypeTotal; } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { if (GameClient.Instance.IsInMahjongGame()) { GameClient.Instance.MahjongGamePlayer.Index = data.usTableNumExtra; GameClient.Instance.MG.OnRestoreGameState(info); //游戏状态 换牌:0x50, 定缺:0x53 等待吃胡碰杠状态:0x08 等待出牌:0x09 // if(info.iGameStates == 0x50) // { // UIGameSetingController.Instance.OnRefreshPlayerState(); // // }else if(info.iGameStates == 0x53) // { // UIGameSetingController.Instance.OnRefreshHeadDingqueState(); // } UIGameSetingController.Instance.OnRefreshHeadAll(); } else { GameClient.Instance.MahjongGamePlayer.Index = data.usTableNumExtra; GameLoading.SwitchScene(3); } }); #endif }); _gsProxy.on(BaseMessage.AGAIN_LOGIN_OTHER_NOTICE_MSG, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; Debug.Log("AGAIN_LOGIN_OTHER_NOTICE_MSG"); //userid /* * typedef struct OtherAgainLoginNotice * //AGAIN_LOGIN_OTHER_NOTICE_MSG重入通知其他玩家 { * MsgHeader msgHeadInfo; * int iUserID; * } OtherAgainLoginNoticeDef; */ }); _gsProxy.on(BaseMessage.SITDOWN_RES_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : SITDOWN_RES_MSG"); return; OdaoMessage msg = (OdaoMessage)obj; BaseMessage.SitDownResDef data = new BaseMessage.SitDownResDef(); data = XConvert.ConvertToObject <BaseMessage.SitDownResDef> (msg.data); Debug.Log(string.Format("NotImplementedException : SITDOWN_RES_MSG -> {0},{1},{2},{3}", data.iTableNum, data.cError, data.usTableNumExtra, data.cPlayerNum)); }); _gsProxy.on(BaseMessage.TABLE_PLAYER_JOIN_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : TABLE_PLAYER_JOIN_MSG"); }); _gsProxy.on(BaseMessage.TABLE_PLAYER_LEAVE_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : TABLE_PLAYER_LEAVE_MSG"); }); _gsProxy.on(BaseMessage.READY_RES_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : READY_RES_MSG"); return; OdaoMessage msg = (OdaoMessage)obj; BaseMessage.ReadyResDef data = new BaseMessage.ReadyResDef(); data = XConvert.ConvertToObject <BaseMessage.ReadyResDef> (msg.data); Debug.Log(string.Format("椅子号{0}", data.usTableNumExtra)); }); //玩家输赢数据,经验值 _gsProxy.on(BaseMessage.USER_SCORE_INFO_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : USER_SCORE_INFO_MSG"); }); //旁观玩家进入桌子 _gsProxy.on(BaseMessage.JOIN_TABLE_AS_VISITOR, delegate(Message obj) { Debug.Log("NotImplementedException : JOIN_TABLE_AS_VISITOR"); }); //更新一桌玩家身份 _gsProxy.on(BaseMessage.UPDATE_TABLE_PLAYER_STATUS, delegate(Message obj) { Debug.Log("NotImplementedException : UPDATE_TABLE_PLAYER_STATUS"); }); //VIP踢人请求 _gsProxy.on(BaseMessage.VIP_KICKOUT_PLAYER_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : VIP_KICKOUT_PLAYER_REQ"); }); //VIP踢人回应 _gsProxy.on(BaseMessage.VIP_KICKOUT_PLAYER_RES, delegate(Message obj) { Debug.Log("NotImplementedException : VIP_KICKOUT_PLAYER_RES"); }); //自由设定桌子人数 0XA013后在Odao_SiteActivity_Msg.h中用 _gsProxy.on(BaseMessage.TABLE_SET_PLAYER_NUMBER, delegate(Message obj) { Debug.Log("NotImplementedException : TABLE_SET_PLAYER_NUMBER"); }); //充值同步积分 _gsProxy.on(BaseMessage.CLIENT_CHARGE_REFRESH_MONEY_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : CLIENT_CHARGE_REFRESH_MONEY_REQ"); }); //服务器踢除玩家 _gsProxy.on(BaseMessage.KICK_OUT_SERVER_MSG, delegate(Message obj) { Debug.Log("KICK_OUT_SERVER_MSG"); OdaoMessage msg = (OdaoMessage)obj; BaseMessage.TablePlayerLeaveDef data = new BaseMessage.TablePlayerLeaveDef(); data = XConvert.ConvertToObject <BaseMessage.TablePlayerLeaveDef> (msg.data); Debug.Log("***************KICK_OUT_SERVER_MSG type:" + data.cLeaveType); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { GameClient.Instance.MahjongGamePlayer.LeaveOut(data.cLeaveType); UIDebugViewController.Instance.SetText("你为啥把我踢下去????????KICK_OUT_SERVER_MSG"); UIDebugViewController.Instance.OnRefresh(); }); #endif }); //入座请求密码 _gsProxy.on(BaseMessage.CHECK_SITDOWN_PASSWD_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : CHECK_SITDOWN_PASSWD_REQ"); }); //请求设定桌底柱消息 _gsProxy.on(BaseMessage.SET_TABLE_BASEPOINT_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : SET_TABLE_BASEPOINT_REQ"); }); _gsProxy.on(BaseMessage.TABLE_PLAYER_LEAVE_NOTICE, delegate(Message obj) { Debug.Log("NotImplementedException : TABLE_PLAYER_LEAVE_NOTICE"); }); _gsProxy.on(BaseMessage.SEND_ALL_USERINFO_TO_CLIENT, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_ALL_USERINFO_TO_CLIENT"); return; OdaoMessage msg = (OdaoMessage)obj; int offset = 0; BaseMessage.SendAllUserInfo data = XConvert.ConvertToObject <BaseMessage.SendAllUserInfo> (msg.data, ref offset); for (int i = 0; i < data.iUserCount; ++i) { BaseMessage.UserInfo userInfo = XConvert.ConvertToObject <BaseMessage.UserInfo> (msg.data, ref offset); byte[] bytes = System.Text.Encoding.GetEncoding("GBK").GetBytes(userInfo.szUserName); string name = System.Text.Encoding.UTF8.GetString(bytes); Debug.Log("SEND_ALL_USERINFO_TO_CLIENT---->" + name); } }); //游戏结束服务器通知 所有游戏公用 _gsProxy.on(BaseMessage.GAME_RESULT_SERVER_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : GAME_RESULT_SERVER_MSG"); }); //游戏公告消息 _gsProxy.on(BaseMessage.GAME_BULL_NOTICE_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : GAME_BULL_NOTICE_MSG"); }); //对应玩家的催牌消息 _gsProxy.on(BaseMessage.URGR_CARD_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : URGR_CARD_MSG"); }); //玩家的喊话消息 _gsProxy.on(BaseMessage.SHOUT_INFO_RES_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : SHOUT_INFO_RES_MSG"); }); //游戏基本房间信息 _gsProxy.on(BaseMessage.SEND_GAME_ROOM_INFO, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_GAME_ROOM_INFO"); }); //发送所有玩家的桌信息 _gsProxy.on(BaseMessage.SEND_ALL_TABLE_INFO, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_ALL_TABLE_INFO"); /* * OdaoMessage msg = (OdaoMessage)obj; * int offset = 0; * BaseMessage.TableInfo tableInfo = XConvert.ConvertToObject<BaseMessage.TableInfo>(msg.data, ref offset); * Debug.Log(tableInfo.iAllTableCount); * for (int i = 0; i < tableInfo.iAllTableCount; ++i) * { * BaseMessage.TableStatusInfo tableStatusInfo = XConvert.ConvertToObject<BaseMessage.TableStatusInfo>(msg.data, ref offset); * //Debug.Log(i + "," + offset); * } */ }); //群发消息处理 //发送所有玩家信息给客户端 _gsProxy.on(BaseMessage.SEND_ALLUSER_STATUS_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_ALLUSER_STATUS_MSG"); return; OdaoMessage msg = (OdaoMessage)obj; BaseMessage.UserStatusInfo userStatusInfo = XConvert.ConvertToObject <BaseMessage.UserStatusInfo> (msg.data); Debug.Log(string.Format("{0}", userStatusInfo.iMsgCount)); }); _gsProxy.on(BaseMessage.SEND_TABLE_STAUTS_TO_CLIENT, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_TABLE_STAUTS_TO_CLIENT"); }); _gsProxy.on(BaseMessage.SEND_TABLE_LOCKED_TO_CLIENT, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_TABLE_LOCKED_TO_CLIENT"); }); _gsProxy.on(BaseMessage.SEND_TABLE_LEVEL_TO_CLIENT, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_TABLE_LEVEL_TO_CLIENT"); return; OdaoMessage msg = (OdaoMessage)obj; BaseMessage.TableLevel tableLevel = XConvert.ConvertToObject <BaseMessage.TableLevel> (msg.data); Debug.Log(string.Format("{0},{1}", tableLevel.cTableLevel, tableLevel.usTableNum)); }); _gsProxy.on(BaseMessage.SEND_TABLE_SETTING_TO_CLIENT, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_TABLE_SETTING_TO_CLIENT"); }); _gsProxy.on(BaseMessage.SEND_TABLE_ANTE_TO_CLIENT, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_TABLE_ANTE_TO_CLIENT"); }); //是否需要发送底注 _gsProxy.on(BaseMessage.SET_BASE_POINT_SERVER, delegate(Message obj) { Debug.Log("NotImplementedException : SET_BASE_POINT_SERVER"); }); //游戏开始通知 _gsProxy.on(BaseMessage.GAME_START_NOTICE_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : GAME_START_NOTICE_MSG"); }); //入座成功收到道具信息 _gsProxy.on(BaseMessage.SIT_DOWN_SUCCESS_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : SIT_DOWN_SUCCESS_MSG"); }); //同意底注请求 _gsProxy.on(BaseMessage.TABLE_BASEINFO_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : TABLE_BASEINFO_MSG"); }); //是否需要发送底注(特殊) _gsProxy.on(BaseMessage.SET_BASE_POINT_SPE_SERVER, delegate(Message obj) { Debug.Log("NotImplementedException : SET_BASE_POINT_SPE_SERVER"); }); //同意底注请求(特殊) _gsProxy.on(BaseMessage.TABLE_BASEINFO_SPE_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : TABLE_BASEINFO_SPE_MSG"); }); //是否需要发送底注(特殊) _gsProxy.on(BaseMessage.HONGBAO_TABLE_INFO, delegate(Message obj) { Debug.Log("NotImplementedException : HONGBAO_TABLE_INFO"); }); //玩家登录银行请求 _gsProxy.on(BaseMessage.USER_LOGIN_BANK_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : USER_LOGIN_BANK_REQ"); }); //银行登录结果相应 _gsProxy.on(BaseMessage.USER_LOGIN_RESULT_NOTICE, delegate(Message obj) { Debug.Log("NotImplementedException : USER_LOGIN_RESULT_NOTICE"); }); //取款清求 _gsProxy.on(BaseMessage.GET_BANK_COIN_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : GET_BANK_COIN_REQ"); }); //取款结果响应 _gsProxy.on(BaseMessage.GET_COIN_RESULT_RES, delegate(Message obj) { Debug.Log("NotImplementedException : GET_COIN_RESULT_RES"); }); //存款请求 _gsProxy.on(BaseMessage.USER_SAVE_COIN_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : USER_SAVE_COIN_REQ"); }); //存款结果响应 _gsProxy.on(BaseMessage.USER_SAVE_COIN_RES, delegate(Message obj) { Debug.Log("NotImplementedException : USER_SAVE_COIN_RES"); }); //用户修改银行密码请求 _gsProxy.on(BaseMessage.MODIFY_BANK_PASSWD_REQ, delegate(Message obj) { Debug.Log("NotImplementedException : MODIFY_BANK_PASSWD_REQ"); }); //用户修改银行密码响应 //玩家积分变化时,通知同桌其他玩家 _gsProxy.on(BaseMessage.MODIFY_BANK_PASSWD_RES, delegate(Message obj) { Debug.Log("NotImplementedException : MODIFY_BANK_PASSWD_RES"); }); _gsProxy.on(BaseMessage.SC_MSG_NOTIFY_TABLE_PLAYERS_COIN_CHANGE, delegate(Message obj) { Debug.Log("NotImplementedException : SC_MSG_NOTIFY_TABLE_PLAYERS_COIN_CHANGE"); }); //玩家身上的额外道具 _gsProxy.on(BaseMessage.GAME_USER_PROPEX_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : GAME_USER_PROPEX_MSG"); }); //客户端站点类型 _gsProxy.on(BaseMessage.GAME_CLIENT_SITE_TYPE_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : GAME_CLIENT_SITE_TYPE_MSG"); }); }
void OnFinishLoading(GameLoading gl) { }
public void InitGameMessage(OdaoClient client) { _gsProxy = client; //客户端发送换牌消息 _gsProxy.on(GameMessage.c2s_HuanPaiDef, delegate(Message obj) { Debug.Log("NotImplementedException : SUB_C_HUANPAI"); }); //客户端发送认输消息 _gsProxy.on(GameMessage.SUB_C_QUEDINGRENSHU, delegate(Message obj) { Debug.Log("NotImplementedException : SUB_C_QUEDINGRENSHU"); }); //客户端托管 _gsProxy.on(GameMessage.s2c_TrusteeShipDef, delegate(Message obj) { Debug.Log("TRUSTEESHIP_NOTICE_MSG"); OdaoMessage msg = (OdaoMessage)obj; GameMessage.TrusteeShipDef data = XConvert.ConvertToObject <GameMessage.TrusteeShipDef>(msg.data); Debug.Log("托管 " + (data.flag > 0 ? "开启" : "关闭") + "," + "椅子号 " + data.cTableNumExtra); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { GameClient.Instance.MG.ComputerManageFor(data.cTableNumExtra, data.flag); }, delegate(){ return(GameClient.Instance.MG != null); }); #endif }); //2:Server 服务器通知客户端消息(将某玩家的动作告诉所有桌上的玩家) //出牌通知 _gsProxy.on(GameMessage.s2c_SendCardNoticeDef, delegate(Message obj) { Debug.Log("SEND_CARDS_NOTICE_MSG"); OdaoMessage msg = (OdaoMessage)obj; #if USE_MSGPACK2 var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.SendCardNoticeDef>(); var data = serializer.UnpackSingleObject(msg.data); #else GameMessage.SendCardNoticeDef data = XConvert.ConvertToObject <GameMessage.SendCardNoticeDef>(msg.data); #endif TileDef def = TileDef.Create(data.cCard); Debug.Log(string.Format("椅子号{0},出牌{1}", data.cTableNumExtra, def.ToString())); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { GameClient.Instance.MG.AutoPlay(data.cTableNumExtra, def, data.flag); }, delegate() { return(GameClient.Instance.MG != null); }); #endif }); //吃杠碰胡请求 _gsProxy.on(GameMessage.s2c_SpecialCardDef, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; #if USE_MSGPACK2 var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.SpecialCardDef>(); var data = serializer.UnpackSingleObject(msg.data); #else GameMessage.SpecialCardDef data = XConvert.ConvertToObject <GameMessage.SpecialCardDef>(msg.data); #endif Debug.Log(string.Format("s2c_SpecialCardDef0x{0:x} --> {1:x}", data.specialType, data.card)); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { GameClient.Instance.SpecialCard = data.card; if (IsSpecialType(data.specialType, (byte)GameMessage.SPECIAL_TYPE.PASS)) { Debug.Log("---OpenCombo PASS---"); UIGameComboController.Instance.OpenCombo(TileDef.ComboType.PASS, GameClient.Instance.MG.Self); } if (IsSpecialType(data.specialType, (byte)GameMessage.SPECIAL_TYPE.PONG)) { Debug.Log("---OpenCombo PONG---"); UIGameComboController.Instance.OpenCombo(TileDef.ComboType.PONG, GameClient.Instance.MG.Self); } if (IsSpecialType(data.specialType, (byte)GameMessage.SPECIAL_TYPE.KONG)) { Debug.Log("---OpenCombo KONG---"); UIGameComboController.Instance.OpenCombo(TileDef.ComboType.KONG_DARK, GameClient.Instance.MG.Self); } if (IsSpecialType(data.specialType, (byte)GameMessage.SPECIAL_TYPE.DARK_KONG)) { Debug.Log("---OpenCombo DARK_KONG---"); UIGameComboController.Instance.OpenCombo(TileDef.ComboType.KONG_DARK, GameClient.Instance.MG.Self); } if (IsSpecialType(data.specialType, (byte)GameMessage.SPECIAL_TYPE.SPECIAL_TYPE_PENGGANG)) { Debug.Log("---OpenCombo SPECIAL_TYPE_PENGGANG---"); UIGameComboController.Instance.OpenCombo(TileDef.ComboType.KONG_TURN, GameClient.Instance.MG.Self); } if (IsSpecialType(data.specialType, (byte)GameMessage.SPECIAL_TYPE.WIN)) { Debug.Log("---OpenCombo WIN---"); UIGameComboController.Instance.OpenCombo(TileDef.ComboType.WIN, GameClient.Instance.MG.Self); } }, delegate() { return(GameClient.Instance.MG != null); }); #endif }); //玩家吃杠碰胡通知 _gsProxy.on(GameMessage.s2c_SpecialNoticeSerDef, delegate(Message obj) { Debug.Log("********************s2c_SpecialNoticeSerDef********************"); OdaoMessage msg = (OdaoMessage)obj; #if USE_MSGPACK2 var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.SpecialNoticeSerDef>(); var data = serializer.UnpackSingleObject(msg.data); #else GameMessage.SpecialNoticeSerDef data = XConvert.ConvertToObject <GameMessage.SpecialNoticeSerDef>(msg.data); #endif TileComboDef tileComboDef = null; if (IsSpecialType(data.cSpecialType, (byte)GameMessage.SPECIAL_TYPE.PONG)) { tileComboDef = TileComboDef.Create(data.cDianPao, TileDef.ComboType.PONG, TileDef.Create(data.cCard)); } if (IsSpecialType(data.cSpecialType, (byte)GameMessage.SPECIAL_TYPE.KONG)) { tileComboDef = TileComboDef.Create(data.cDianPao, TileDef.ComboType.KONG, TileDef.Create(data.cCard)); } if (IsSpecialType(data.cSpecialType, (byte)GameMessage.SPECIAL_TYPE.DARK_KONG)) { tileComboDef = TileComboDef.Create(data.cDianPao, TileDef.ComboType.KONG_DARK, TileDef.Create(data.cCard)); } if (IsSpecialType(data.cSpecialType, (byte)GameMessage.SPECIAL_TYPE.SPECIAL_TYPE_PENGGANG)) { tileComboDef = TileComboDef.Create(data.cDianPao, TileDef.ComboType.KONG_TURN, TileDef.Create(data.cCard)); } if (IsSpecialType(data.cSpecialType, (byte)GameMessage.SPECIAL_TYPE.WIN)) { WinState = true; tileComboDef = TileComboDef.Create(data.cDianPao, TileDef.ComboType.WIN, TileDef.Create(data.cCard)); } if (null != tileComboDef) { Debug.Log("--------------------->s2c_SpecialNoticeSerDef " + tileComboDef.ToString()); } #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { UIGameComboController.Instance.Close(); if (!IsSpecialType(data.cSpecialType, (byte)GameMessage.SPECIAL_TYPE.PASS)) { GameClient.Instance.MG.AutoCombo(data.cExtraTableNum, tileComboDef, data.flag); if (data.cExtraTableNum == Index) { UIGameEffectController.Instance.ShowComboEffect(tileComboDef.Combo); } } }); #endif }); //通知玩家定缺 _gsProxy.on(GameMessage.s2c_DingQueDef, delegate(Message obj) { Debug.Log("******************s2c_DingQueDef"); #if USE_MSGPACK2 OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.DingQueDef>(); var lactKind = serializer.UnpackSingleObject(msg.data); #else Debug.Log("s2c_DingQueDef"); OdaoMessage msg = (OdaoMessage)obj; GameMessage.DingQueDef lactKind = XConvert.ConvertToObject <GameMessage.DingQueDef>(msg.data); #endif #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; i++) { UIOperation.Instance._headDatas[i].gameState = UIOperation.gameState.DINGQUE; UIOperation.Instance._headDatas[i].isShow = true; } Loom.QueueOnMainThread(delegate() { UIDQSettingController.Instance.Open(); UIGameSetingController.Instance.OnRefreshPlayerState(); //default lackKind }, delegate() { if (GameClient.Instance.MG != null) { //UnityEngine.Debug.Log("!!!&&&&&&&&&"+GameClient.Instance.MG.GameInitDone); } return(GameClient.Instance.MG != null && GameClient.Instance.MG.GameInitDone); }); #endif }); //服务器通知玩家换牌 _gsProxy.on(GameMessage.s2c_HuaiPaiDef, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.HuanPaiDef>(); var data = serializer.UnpackSingleObject(msg.data); for (int i = 0; i < GameMessage.MAXHUANPAINUM; i++) { if (i < data.vHuanPai.Count) { TileDef def = TileDef.Create(data.vHuanPai[i]); UIOperation.Instance._HuanPaiOldDef[i] = def; Debug.Log("开始换牌[" + i + "]:" + def.ToString()); } } for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; i++) { UIOperation.Instance._headDatas[i].gameState = UIOperation.gameState.XUANPAI; UIOperation.Instance._headDatas[i].isShow = true; } Loom.QueueOnMainThread(delegate() { UIGameSetingController.Instance.OnRefreshPlayerState(); MahjongTile.TotalClickCount = 3; }, delegate() { return(GameClient.Instance.MG != null && UIGameSetingController.Instance.IsOpen() && GameClient.Instance.MG.GameInitDone); }); }); //const int SC_MSG_NOTIFY_TABLE_PLAYERS_COIN_CHANGE = 59432;//当玩家取钱后更新玩家身上的钱 //ADD //通知玩家有人定缺完毕 //_gsProxy.on(GameMessage.SEND_SOMEONEDINGQUE_MSG, delegate (Message obj) // { // Debug.Log("SEND_SOMEONEDINGQUE_MSG"); // }); //服务器的发牌请求 _gsProxy.on(GameMessage.s2c_SendMjSerDef, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; #if USE_MSGPACK2 var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.SendMjSerDef>(); var data = serializer.UnpackSingleObject(msg.data); #else GameMessage.SendMjSerDef data = XConvert.ConvertToObject <GameMessage.SendMjSerDef>(msg.data); #endif Debug.Log("s2c_SendMjSerDef " + "椅子号" + data.tableNumExtra + "需要出牌" + data.draw + "#######" + data.specialType); /* * public class SendMjSerDef * { * public byte cTableNumExtra; //出牌的那个人 * public byte cGetMj; //摸的那张牌 0表示没有从剩余的牌墙中取牌,也就是刚才的动作是碰,然后该出牌了 * public int iSpeciaType; //胡,暗杠,碰杠的二进制合 * }*/ //*只有胡和转弯杠* GameClient.Instance.SpecialCard = data.draw; #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN Loom.QueueOnMainThread(delegate() { GameClient.Instance.MG.TurnTo(data.tableNumExtra); // dont draw, because last operation is pong, now you should play if (data.draw == 0) { } else { TileDef def = TileDef.Create(data.draw); GameClient.Instance.MG.Draw(data.tableNumExtra, def); } //GameClient.Instance.SpecialCard = data.draw; // if(IsSpecialType(data.specialType, (byte)GameMessage.SPECIAL_TYPE.PASS)) // { // UIGameComboController.Instance.OpenCombo(TileDef.ComboType.PASS,GameClient.Instance.MG.Self); // } // // if(IsSpecialType(data.specialType,(byte)GameMessage.SPECIAL_TYPE.PONG)) // { // UIGameComboController.Instance.OpenCombo(TileDef.ComboType.PONG,GameClient.Instance.MG.Self); // } // // if(IsSpecialType(data.specialType,(byte)GameMessage.SPECIAL_TYPE.KONG)) // { // UIGameComboController.Instance.OpenCombo(TileDef.ComboType.KONG_DARK,GameClient.Instance.MG.Self); // } // // if(IsSpecialType(data.specialType,(byte)GameMessage.SPECIAL_TYPE.DARK_KONG)) // { // UIGameComboController.Instance.OpenCombo(TileDef.ComboType.KONG_DARK,GameClient.Instance.MG.Self); // } // // if(IsSpecialType(data.specialType,(byte)GameMessage.SPECIAL_TYPE.SPECIAL_TYPE_PENGGANG)) // { // UIGameComboController.Instance.OpenCombo(TileDef.ComboType.KONG_TURN,GameClient.Instance.MG.Self); // } // // if(IsSpecialType(data.specialType,(byte)GameMessage.SPECIAL_TYPE.WIN)) // { // UIGameComboController.Instance.OpenCombo(TileDef.ComboType.WIN,GameClient.Instance.MG.Self); // } UIGameComboController.Instance.OpenAllCombos(data.specialType); }, delegate() { return(GameClient.Instance.MG != null); } ); #endif }); //服务器给玩家发送换的牌 _gsProxy.on(GameMessage.s2c_Notice_HuanPaiDef, delegate(Message obj) { OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.HuanPaiResDef>(); var data = serializer.UnpackSingleObject(msg.data); MahjongTile.TotalClickCount = 1; for (int i = 0; i < GameMessage.MAXHUANPAINUM; i++) { if (i < data.cCards.Count) { TileDef def = TileDef.Create(data.cCards[i]); UIOperation.Instance._HuanPaiNewDef[i] = def; Debug.Log("***********************换的牌:" + def.ToString()); Debug.Log("***********************删除的牌:" + UIOperation.Instance._HuanPaiOldDef[i].ToString()); } } List <TileDef> newPocketList = new List <TileDef>(); int[] removeIndex = new int[GameMessage.MAXHUANPAINUM] { 0, 0, 0 }; for (int i = 0; i < PocketList.Count; i++) { bool canAdd = true; for (int j = 0; j < GameMessage.MAXHUANPAINUM; j++) { if (PocketList[i].Value == UIOperation.Instance._HuanPaiOldDef[j].Value && removeIndex[j] == 0) { Debug.Log("**********************删除手牌:" + UIOperation.Instance._HuanPaiOldDef[j].ToString()); canAdd = false; removeIndex[j] = 1; break; } } if (canAdd) { newPocketList.Add(PocketList[i]); } } for (int i = 0; i < GameMessage.MAXHUANPAINUM; i++) { newPocketList.Add(UIOperation.Instance._HuanPaiNewDef[i]); } string oldStr = "*********************换牌前手牌" + PocketList.Count + ":"; foreach (var def in PocketList) { oldStr += def.ToString() + ", "; } PocketList = newPocketList; string newStr = "*********************换牌后手牌" + PocketList.Count + ":"; foreach (var def in PocketList) { newStr += def.ToString() + ", "; } Debug.Log(oldStr); Debug.Log(newStr); UIOperation.Instance._HuanPaiType = (GameMessage.HUANPAI_TYPE)data.iChangeType; Loom.QueueOnMainThread(delegate() { GameClient.Instance.MG.Self.ResetPocketList(PocketList.Count == GameMessage.HANDLE_MJ_NUM); UIGameSetingController.Instance.CloseHuanpaiTips(); }, delegate() { return(GameClient.Instance.MG != null); }); }); //通知客户端玩家的定缺牌 _gsProxy.on(GameMessage.s2c_Notice_DingQueResDef, delegate(Message obj) { int dataCount = 0; #if USE_MSGPACK2 OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.DingQueResDef>(); var data = serializer.UnpackSingleObject(msg.data); dataCount = data.cques.Count; #else OdaoMessage msg = (OdaoMessage)obj; GameMessage.DingQueResDef data = XConvert.ConvertToObject <GameMessage.DingQueResDef>(msg.data); dataCount = data.cques.Length; #endif #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN for (int i = 0; i < dataCount; ++i) { TileDef.Kind k = (TileDef.Kind)data.cques[i]; if (k != TileDef.Kind.NONE) { GameClient.Instance.MG.SetLackTile(i, k); UIOperation.Instance._headDatas[i].dingque = k; UIOperation.Instance._headDatas[i].gameState = UIOperation.gameState.NONE; } } Loom.QueueOnMainThread(delegate() { GameClient.Instance.MG.UpdateLackState(); UIGameSetingController.Instance.OnRefreshHeadAll(); UIDQSettingController.Instance.Close(); }); #endif }); //通知客户端玩家没钱了 _gsProxy.on(GameMessage.SEND_NO_MONEY_MSG, delegate(Message obj) { Debug.Log("NotImplementedException : SEND_NO_MONEY_MSG"); }); //通知客户端 认输 _gsProxy.on(GameMessage.SUB_S_QUEDINGRENSHU, delegate(Message obj) { Debug.Log("NotImplementedException : SUB_S_QUEDINGRENSHU"); }); //3:Server 发起客户端消息(服务器端发起,告诉桌上所有玩家) //服务器给所有玩家发牌 _gsProxy.on(GameMessage.s2c_DealMjServerDef, delegate(Message obj) { #if USE_MSGPACK2 OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.DealMjServerDef>(); GameMessage.DealMjServerDef data = serializer.UnpackSingleObject(msg.data); PocketList.Clear(); for (int i = 0; i < data.cCards.Count; i++) { var valueTemp = data.cCards[i]; Debug.Log(((valueTemp >> 4) & 0x0f) + ":" + (valueTemp & 0x0f) + "value:" + valueTemp); if (TileDef.IsValid(valueTemp)) { TileDef def = TileDef.Create(valueTemp); PocketList.Add(def); } } #else Debug.Log("s2c_DealMjServerDef***************************"); OdaoMessage msg = (OdaoMessage)obj; GameMessage.DealMjServerDef data = XConvert.ConvertToObject <GameMessage.DealMjServerDef>(msg.data); PocketList.Clear(); for (int i = 0; i < GameMessage.HANDLE_MJ_NUM; ++i) { Debug.Log(((data.cCards[i] >> 4) & 0x0f) + ":" + (data.cCards[i] & 0x0f)); if (TileDef.IsValid(data.cCards[i])) { TileDef def = TileDef.Create(data.cCards[i]); PocketList.Add(def); } } #endif #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN //BUG UnityEngine.Debug.Log("DEAL_CARD_SERVER_MSG---->>>>" + ToString()); SortPocketList(TileDef.Comparison); UnityEngine.Debug.Log("DEAL_CARD_SERVER_MSG---->>>> SORTED " + ToString()); Loom.QueueOnMainThread(delegate() { GameClient.Instance.MG.DealerIndex = data.cZhuang; GameClient.Instance.MG.StartRun(); UIGameSetingController.Instance.OnRefreshHeadZhuangState(); }, delegate() { return(GameClient.Instance.MG != null); } ); #endif }); //match 返回,换桌也会返回 _gsProxy.on(GameMessage.s2c_MatchGameRes, delegate(Message obj) { Debug.Log("MatchGameRes"); OdaoMessage msg = (OdaoMessage)obj; GameMessage.MatchGameRes data = XConvert.ConvertToObject <GameMessage.MatchGameRes>(msg.data); #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN if (data.errorCode < 0) { Debug.Log("ErrorCode " + data.errorCode); } Loom.QueueOnMainThread(() => { UIOperation.Instance.Matching = false; for (int i = 0; i < data.playerIndex.Length; ++i) { if (data.playerIndex[i] == Info.UserId) { if (!GameClient.Instance.IsInMahjongGame()) { Index = i; UIOperation.Instance.SelfIndex = Index; GameLoading.SwitchScene(3); } else { GameClient.Instance.MG.ArrangePlayer(i, 4); } break; } } }); #endif }); _gsProxy.on(GameMessage.s2c_GameResultServerDef, delegate(Message obj) { #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN UnityEngine.Debug.Log("NotImplementedException : s2c_GameResultServerDef "); OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.GameResultServerDef>(); GameMessage.GameResultServerDef data = serializer.UnpackSingleObject(msg.data); UIOperation.Instance._gameResultDatas = data.GameResult; UIOperation.Instance.Reset(); Loom.QueueOnMainThread(delegate() { UIGameResultController.Instance.Open(); UIGameHuPromptController.Instance.Close(); for (int i = 0; i < GameMessage.TABLE_PLAYER_NUM; i++) { GameClient.Instance.MG.ShowPocketList(i); } UIGameEffectController.Instance.DespawnAllEffect(); }, delegate() { return(GameClient.Instance.MG != null); } ); #endif }); //离开游戏,换桌返回(换桌还会返回0x22;)其他玩家离开也会收到此消息 _gsProxy.on(GameMessage.s2c_Notice_LeaveTableDef, delegate(Message obj) { #if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN UnityEngine.Debug.Log("======================= NotImplementedException : s2c_Notice_LeaveTableDef ======================= "); OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.NoticeLeaveTableDef>(); GameMessage.NoticeLeaveTableDef data = serializer.UnpackSingleObject(msg.data); Loom.QueueOnMainThread(delegate() { if ((int)data.cLeaveType == (int)GameMessage.LEAVETABLE_TYPE.LEAVETABLE_LEAVE) { if (data.iUserID == Info.UserId && GameClient.Instance.IsInMahjongGame()) { UIGameSetingController.Instance.Close(); UIGameResultController.Instance.Close(); GameLoading.SwitchScene(2); } } }, delegate() { return(true); } ); #endif }); //胡牌提示返回,每次发手牌会收到此消息 _gsProxy.on(GameMessage.s2c_HuTipsResDef, delegate(Message obj) { //#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN UnityEngine.Debug.Log("======================= NotImplementedException : s2c_HuTipsResDef ======================= "); OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.AllOutCard>(); GameMessage.AllOutCard data = serializer.UnpackSingleObject(msg.data); UIOperation.Instance._huTipsCards = data.v_OutCards; if (UIOperation.Instance._huTipsCards.Count > 0) { foreach (var card in data.v_OutCards) { TileDef def = TileDef.Create(card.cOutCard); string ss = "******************************打出:" + def.ToString() + "胡:"; foreach (var tips in card.v_Tips) { TileDef def1 = TileDef.Create(tips.cCard); ss += def1.ToString() + ",倍数" + tips.cTimes + ",张数:" + tips.cLeftNum + "------"; } Debug.Log(ss); } } Loom.QueueOnMainThread(delegate() { }, delegate() { return(GameClient.Instance.MG != null); } ); //#endif }); //通知客户端显示按钮(血战到底会收到此消息) _gsProxy.on(GameMessage.s2c_LeaveTableDef, delegate(Message obj) { //#if UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN UnityEngine.Debug.Log("======================= NotImplementedException : s2c_LeaveTableDef ======================= "); OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.LeaveTableDef>(); GameMessage.LeaveTableDef data = serializer.UnpackSingleObject(msg.data); Loom.QueueOnMainThread(delegate() { }, delegate() { return(GameClient.Instance.MG != null); } ); //#endif }); _gsProxy.on(0x57, delegate(Message obj) { List <GameMessage.TEST_MSGPACK_PlayerCard> cardList = new List <GameMessage.TEST_MSGPACK_PlayerCard>(); List <byte> m_vCType = new List <byte>(); List <int> m_viType = new List <int>(); List <long> m_vLLType = new List <long>(); List <GameMessage.TEST_MSGPACK_TableNum> m_vPosition = new List <GameMessage.TEST_MSGPACK_TableNum>(); GameMessage.TEST_MSGPACK testMsgPack = new GameMessage.TEST_MSGPACK(); testMsgPack.cType = 0; testMsgPack.iType = 1; testMsgPack.llType = 2; testMsgPack.m_allPlayerCard = cardList; testMsgPack.m_string = "ok"; testMsgPack.m_vCType = m_vCType; testMsgPack.m_viType = m_viType; testMsgPack.m_vLLType = m_vLLType; testMsgPack.m_vPosition = m_vPosition; testMsgPack.m_vusType = new List <ushort> { 1, 2, 3, 4 }; testMsgPack.usType = 3; OdaoMessage msg = (OdaoMessage)obj; var serializer = MsgPack.Serialization.MessagePackSerializer.Get <GameMessage.TEST_MSGPACK> (); var recvbuffer = new System.IO.MemoryStream(msg.data); var test = serializer.Unpack(recvbuffer); var test2 = serializer.UnpackSingleObject(msg.data); Debug.Log(test); Debug.Log("****************MessagePack StringTest:" + test2.m_string + ", len:" + test2.m_string.Length); // byte[] strByte = Encoding.Unicode.GetBytes(test2.m_string); // foreach(var temp in strByte) // { // Debug.Log("****:"+temp); // } var sendbuffer = new System.IO.MemoryStream(); serializer.Pack(sendbuffer, testMsgPack); byte[] t = serializer.PackSingleObject(testMsgPack); byte[] a = sendbuffer.GetBuffer(); sendbuffer.Position = 0; byte[] b = sendbuffer.GetBuffer(); /* * for(int i=0;i<107;++i) * { * if(t[i]!=msg.data[i]) * { * UnityEngine.Debug.LogError("byte match error " + i); * } * * if(a[i]!=msg.data[i]) * { * UnityEngine.Debug.LogError("AAA byte match error " + i); * } * * if(b[i]!=msg.data[i]) * { * UnityEngine.Debug.LogError("BBB byte match error " + i); * } * } */ _gsProxy.notifyMP(0x57, t); /* * GameMessage.TEST_RAW data= XConvert.ConvertToObject<GameMessage.TEST_RAW>(msg.data); * * for(int i=0;i<msg.data.Length;++i) * { * //Debug.Log(string.Format("{0:x}", msg.data[i])); * UnityEngine.Debug.Log(msg.data[i]); * } * UnityEngine.Debug.Log("========================================="); * * byte[] list = XConvert.ConvertToByte(data); * for(int i=0;i<list.Length;++i) * { * UnityEngine.Debug.Log(list[i]); * } * _gsProxy.notify(0x57, list); */ }); }
private void GameSocket_OnGameLoading(GameLoading Packet) { this.Game.WriteToLog("Game Loading", Color.Yellow); }