public void Data(Protocol data) { Loom.QueueOnMainThread(() => { Common.Sumbiting = false; Common.EndCalling(); }); if (data == null) { return; } Debug.Log(data.ToString()); switch (data.Msgid) { case MessageID.LoginRsp: if (data.LoginRsp.Ret == 0) { Common.Uid = data.LoginRsp.Uid; Common.FB_name = data.LoginRsp.Name; Common.FB_avatar = data.LoginRsp.Avatar; Common.IsOnline = true; Loom.QueueOnMainThread(() => { GetPlayingRoomServer(); }); } else { Loom.QueueOnMainThread(() => { Common.ErrorDialog(PrefabDialog, Canvas, Common.ErrorLogin); }); } break; case MessageID.ListRoomsRsp: if (data.ListRoomsRsp.Ret == 0) { Loom.QueueOnMainThread(() => { RoomIDs.Clear(); RoomLists.Clear(); foreach (ListRoomItem room in data.ListRoomsRsp.Rooms) { RoomInfo r = new RoomInfo(); r.RoomId = room.RoomId; r.Owner = room.OwnerUid; r.RoomName = room.RoomName; r.RoomNumber = room.RoomNumber; r.Hands = room.Hands; r.PlayerHands = room.PlayedHands; r.Players = new List <ListRoomPlayerInfo>(); foreach (ListRoomPlayerInfo player in room.Players) { r.Players.Add(player); } RoomLists.Add(r); RoomIDs.Add(room.RoomId); } UpdateRoomsInfo(); }); } break; case MessageID.CloseRoomRsp: if (data.CloseRoomRsp.Ret == 0) { Loom.QueueOnMainThread(() => { UpdateRoomClose(data.CloseRoomRsp.RoomId); }); } else { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas, Common.TipsCantCloseRoom); }); } break; case MessageID.GetPlayingRoomRsp: if (data.GetPlayingRoomRsp.Ret == 0) { Loom.QueueOnMainThread(() => { Common.CRoom_number = data.GetPlayingRoomRsp.RoomNumber; if (string.IsNullOrEmpty(Common.CRoom_number)) { RoomListServer(); } else { JoinRoomServer(Common.CRoom_number); } }); } break; case MessageID.GetNoticesRsp: if (data.GetNoticesRsp.Ret == 0) { Loom.QueueOnMainThread(() => { foreach (Msg.Notice s in data.GetNoticesRsp.Notices) { if (s.Type == Msg.NoticeType.HorseLamp) { NoticeMessage nm = new NoticeMessage(); nm.text = s.Content; nm.times = 3; Common.GameNotices.Add(nm); } else { Common.ErrorDialog(PrefabDialog, Canvas, s.Content); } } NoticeBar.OnPlay(); }); } break; case MessageID.CreateRoomRsp: if (data.CreateRoomRsp.Ret == 0) { Loom.QueueOnMainThread(() => { Common.CRoom_id = data.CreateRoomRsp.RoomId; Common.CRoom_number = data.CreateRoomRsp.RoomNumber; JoinRoomServer(Common.CRoom_number, false); }); } else if (data.CreateRoomRsp.Ret == ErrorID.CreateRoomNotEnoughDiamonds) { Loom.QueueOnMainThread(() => { Common.ErrorDialog(PrefabDialog, Canvas, Common.ErrorInsufficient); }); } else if (data.CreateRoomRsp.Ret == ErrorID.CreateRoomExceedLimitationRooms) { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas, Common.TipsCreateRoomMax); }); } else { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas, Common.TipsCreareRoom); }); } break; case MessageID.JoinRoomRsp: Loom.QueueOnMainThread(() => { Conneting.SetActive(false); }); if (data.JoinRoomRsp.Ret == 0) { Common.CRoom_id = data.JoinRoomRsp.Room.RoomId; Common.CRoom_number = data.JoinRoomRsp.Room.Number; Common.CRoom_name = data.JoinRoomRsp.Room.Name; Common.CMin_bet = data.JoinRoomRsp.Room.MinBet; Common.CMax_bet = data.JoinRoomRsp.Room.MaxBet; Common.CHands = data.JoinRoomRsp.Room.Hands; Common.CPlayed_hands = data.JoinRoomRsp.Room.PlayedHands; Common.CIs_share = data.JoinRoomRsp.Room.IsShare; Common.CCredit_points = data.JoinRoomRsp.Room.CreditPoints; Common.CState = data.JoinRoomRsp.Room.State; Common.CPokers.Clear(); Common.CPlayers.Clear(); Common.CSeatResults.Clear(); for (int i = 0; i < data.JoinRoomRsp.Room.Players.Count; i++) { PlayerInfo p = new PlayerInfo(); p.Uid = data.JoinRoomRsp.Room.Players [i].Uid; p.SeatID = data.JoinRoomRsp.Room.Players [i].SeatId; p.Name = data.JoinRoomRsp.Room.Players [i].Name; p.Bet = data.JoinRoomRsp.Room.Players [i].Bet; p.FB_avatar = data.JoinRoomRsp.Room.Players [i].Avatar; p.Score = data.JoinRoomRsp.Room.Players [i].Score; Debug.Log(p.Uid + "===" + p.SeatID + "===" + p.Name); Common.CPlayers.Add(p); } switch (Common.CState) { case Msg.GameState.Bet: Common.ConfigBetTime = (int)data.JoinRoomRsp.Room.Countdown / 1000; break; case Msg.GameState.Deal: for (int i = 0; i < data.JoinRoomRsp.Room.Cards.Count; i++) { Common.CPokers.Add((int)data.JoinRoomRsp.Room.Cards [i]); } break; case Msg.GameState.Combine: Common.ConfigSortTime = (int)data.JoinRoomRsp.Room.Countdown / 1000; for (int i = 0; i < data.JoinRoomRsp.Room.Cards.Count; i++) { Common.CPokers.Add((int)data.JoinRoomRsp.Room.Cards [i]); } foreach (Msg.SeatResult res in data.JoinRoomRsp.Room.Result) { if (res.Uid == Common.Uid) { for (int o = 0; o < res.CardGroups.Count; o++) { List <uint> t = new List <uint> (res.CardGroups[o].Cards); Common.CCPokers.Add(t); } } } break; case Msg.GameState.ConfirmCombine: Common.ConfigSortTime = (int)data.JoinRoomRsp.Room.Countdown / 1000; for (int i = 0; i < data.JoinRoomRsp.Room.Cards.Count; i++) { Common.CPokers.Add((int)data.JoinRoomRsp.Room.Cards [i]); } foreach (Msg.SeatResult res in data.JoinRoomRsp.Room.Result) { if (res.Uid == Common.Uid) { for (int o = 0; o < res.CardGroups.Count; o++) { List <uint> t = new List <uint> (res.CardGroups[o].Cards); Common.CCPokers.Add(t); } } } break; case Msg.GameState.Show: InitSeatResult(data.JoinRoomRsp.Room.Result); break; case Msg.GameState.Result: Common.ConfigFinishTime = (int)data.JoinRoomRsp.Room.Countdown / 1000; InitSeatResult(data.JoinRoomRsp.Room.Result); break; } Loom.QueueOnMainThread(() => { PlayGame(); }); } else { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas, Common.TipsJoinRoom); }); } break; case MessageID.GetProfileRsp: if (data.GetProfileRsp.Ret == 0) { Common.Uid = data.GetProfileRsp.Uid; Common.FB_name = data.GetProfileRsp.Name; Common.FB_avatar = data.GetProfileRsp.Avatar; Common.DiamondAmount = data.GetProfileRsp.Diamonds; Loom.QueueOnMainThread(() => { PrefileControl.UpdateSelfInfo(); }); } break; case MessageID.SendDiamondsRsp: if (data.SendDiamondsRsp.Ret == 0) { Loom.QueueOnMainThread(() => { PrefileControl.HideSendDiamond(); PrefileControl.UpdateDiamAmount(data.SendDiamondsRsp.Diamonds.ToString()); Common.TipsOn(PrefabTips, Canvas, Common.TipsSendSuccess); }); } else if (data.SendDiamondsRsp.Ret == ErrorID.SendDiamondsNoUser) { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas, Common.TipsInvalidUserID); }); } else if (data.SendDiamondsRsp.Ret == ErrorID.SendDiamondsCannotSelf) { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas, Common.TipsCantSendSelf); }); } else if (data.SendDiamondsRsp.Ret == ErrorID.SendDiamondsNotEnoughDiamonds) { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas, Common.TipsInsufficient); }); } break; case MessageID.DiamondsRecordsRsp: if (data.DiamondsRecordsRsp.Ret == 0) { Loom.QueueOnMainThread(() => { PrefileControl.FormentDiamondRecord(data.DiamondsRecordsRsp.Records, data.DiamondsRecordsRsp.Users); }); } break; case MessageID.CareerWinLoseDataRsp: if (data.CareerWinLoseDataRsp.Ret == 0) { Loom.QueueOnMainThread(() => { CareerControl.UpdateRecordPie(data.CareerWinLoseDataRsp.Data); }); } break; case MessageID.CareerRoomRecordsRsp: if (data.CareerRoomRecordsRsp.Ret == 0) { Loom.QueueOnMainThread(() => { CareerControl.SetCareerRecordData(data.CareerRoomRecordsRsp.Records); }); } break; case MessageID.ConsumeDiamondsNotify: break; case MessageID.KickNotify: Loom.QueueOnMainThread(() => { if (data.KickNotify.Type == Msg.KickType.StopServer) { Common.ErrorDialog(PrefabDialog, Canvas, Common.ErrorKickGame, Common.CloseServerDialog); } else { Common.CloseServerDialog(null); } }); break; case MessageID.NoticesNotify: Loom.QueueOnMainThread(() => { foreach (Msg.Notice s in data.NoticesNotify.Notices) { if (s.Type == Msg.NoticeType.HorseLamp) { NoticeMessage nm = new NoticeMessage(); nm.text = s.Content; nm.times = 3; Common.GameNotices.Add(nm); } else { Common.ErrorDialog(PrefabDialog, Canvas, s.Content); } } NoticeBar.OnPlay(); }); break; } }
public void Data(Protocol data) { Loom.QueueOnMainThread(() => { Common.Sumbiting = false; Common.EndCalling(); }); //Debug.Log (data.ToString()); if (data == null) { return; } switch (data.Msgid) { case MessageID.LeaveRoomRsp: if (data.LeaveRoomRsp.Ret == 0) { Loom.QueueOnMainThread(() => { ExitGame(); }); } else { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsCantLeave); }); } break; case MessageID.AutoBankerRsp: if (data.AutoBankerRsp.Ret == 0) { } break; case MessageID.SitDownRsp: if (data.SitDownRsp.Ret == 0) { Loom.QueueOnMainThread(() => { SetSeatID(Common.Uid, m_TatgetSeatID); UpdateOrderList(); if (m_TatgetSeatID == 0) { if (GetTablePlayersCount() > 1 && Common.CState == Msg.GameState.Ready) { m_Letplay.SetActive(true); } Common.CAutoBanker = data.SitDownRsp.Autobanker; } if (m_StateManage.GetCulState() == STATE.STATE_BETTING) { m_StateManage.m_StateBetting.SitDown(); } }); } else if (data.SitDownRsp.Ret == ErrorID.SitDownCreditPointsOut) { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsCreditMax); }); } else { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsSeatWasToken); }); } break; case MessageID.StandUpRsp: if (data.StandUpRsp.Ret == 0) { Loom.QueueOnMainThread(() => { m_StateManage.m_StateBetting.CancelBet(); SetSeatID(Common.Uid, -1); UpdateOrderList(); m_Letplay.SetActive(false); }); } else { Loom.QueueOnMainThread(() => { Common.TipsOn(PrefabTips, Canvas.gameObject, Common.TipsCantStandUp); }); } break; case MessageID.StartGameRsp: if (data.StartGameRsp.Ret == ErrorID.StartGameNotEnoughDiamonds) { Loom.QueueOnMainThread(() => { string names = ""; for (int i = 0; i < data.StartGameRsp.NomoneyUids.Count; i++) { PlayerInfo p = GetPlayerIDForUID(data.StartGameRsp.NomoneyUids[i]); if (p != null) { names += p.Name; if ((data.StartGameRsp.NomoneyUids.Count - (i + 1)) >= 2) { names += ","; } else if ((data.StartGameRsp.NomoneyUids.Count - (i + 1)) == 1) { names += " and "; } } } string str = "Insufficient diamond for " + names + " to resume the game"; Common.ErrorDialog(PrefabDialog, Canvas.gameObject, str); }); } break; case MessageID.BetRsp: if (data.BetRsp.Ret == 0) { Loom.QueueOnMainThread(() => { m_StateManage.m_StateBetting.UpdatePlayerBet(); m_StateManage.m_StateBetting.DCanBetCall(); }); } break; case MessageID.CombineRsp: if (data.CombineRsp.Ret == 0) { Loom.QueueOnMainThread(() => { List <List <uint> > cards = new List <List <uint> > (); foreach (Msg.CardGroup cardg in data.CombineRsp.CardGroups) { List <uint> duan = new List <uint> (cardg.Cards); cards.Add(duan); } m_StateManage.m_StateSorting.SynchPoker(cards); }); } break; case MessageID.GetScoreboardRsp: if (data.GetScoreboardRsp.Ret == 0) { Loom.QueueOnMainThread(() => { List <Msg.ScoreboardItem> list = new List <ScoreboardItem>(); foreach (Msg.ScoreboardItem t in data.GetScoreboardRsp.Items) { list.Add(t); } m_GameConsole.ShowPlayerList(list, m_PlayerListMode); }); } break; case MessageID.CloseResultRsp: if (data.CloseResultRsp.Ret == 0) { Loom.QueueOnMainThread(() => { }); } break; case MessageID.GetRoundHistoryRsp: if (data.GetRoundHistoryRsp.Ret == 0) { Loom.QueueOnMainThread(() => { if (data.GetRoundHistoryRsp.Results.Count <= 0) { return; } Dictionary <int, CSeatResult> LSeatResults = new Dictionary <int, CSeatResult>(); for (int i = 0; i < data.GetRoundHistoryRsp.Results.Count; i++) { Msg.PlayerRoundHistory ps = data.GetRoundHistoryRsp.Results[i]; CSeatResult info = new CSeatResult(); info.SeatID = (int)ps.Result.SeatId; info.Name = ps.Name; info.Avatar = ps.Avatar; info.autowin = ps.Result.Autowin; info.foul = ps.Result.Foul; info.Win = ps.Result.Win; info.Ranks = ps.Result.Ranks; for (int o = 0; o < ps.Result.CardGroups.Count; o++) { Msg.CardGroup cg = ps.Result.CardGroups[o]; info.Pres.Add(cg.Cards); } LSeatResults.Add(info.SeatID, info); } m_GameConsole.ShowHandReview(LSeatResults); }); } break; case MessageID.GameStateNotify: Common.CState = data.GameStateNotify.State; switch (data.GameStateNotify.State) { case Msg.GameState.Ready: Loom.QueueOnMainThread(() => { Common.CPlayed_hands = data.GameStateNotify.PlayedHands; m_StateManage.ChangeState(STATE.STATE_SEAT); if (m_SelfSeatID == 0 && GetTablePlayersCount() > 1) { m_Letplay.SetActive(true); } }); break; case Msg.GameState.Bet: Loom.QueueOnMainThread(() => { Common.CSeatResults.Clear(); Common.CPlayed_hands = data.GameStateNotify.PlayedHands; m_Letplay.SetActive(false); Common.ConfigBetTime = (int)data.GameStateNotify.Countdown / 1000; m_StateManage.ChangeState(STATE.STATE_BETTING); m_StateManage.m_StateBetting.AdjustUIChipControl(); }); break; case Msg.GameState.ConfirmBet: Loom.QueueOnMainThread(() => { m_StateManage.m_StateBetting.ShowConfimBet(); }); break; case Msg.GameState.Deal: Loom.QueueOnMainThread(() => { DealCardsEvent(data.GameStateNotify.DealCards); DealSeatEvent(data.GameStateNotify.DealSeats); m_StateManage.ChangeState(STATE.STATE_DEAL); }); break; case Msg.GameState.Combine: Loom.QueueOnMainThread(() => { if (m_SelfSeatID == 0 || GetPlayerInfoForSeatID(m_SelfSeatID).Bet > 0) { m_StateManage.m_StateBetting.RealExit(); Common.ConfigSortTime = (int)data.GameStateNotify.Countdown / 1000; m_StateManage.ChangeState(STATE.STATE_SORTING); } else { m_GameConsole.ShowWaitingAnime(); } }); break; case Msg.GameState.ConfirmCombine: Loom.QueueOnMainThread(() => { m_StateManage.m_StateSorting.AutoSortConfrm(); }); break; case Msg.GameState.Show: Loom.QueueOnMainThread(() => { m_StateManage.m_StateBetting.RealExit(); m_GameConsole.HideWaitAnime(); ResultEvent(data.GameStateNotify.Result); m_StateManage.ChangeState(STATE.STATE_SHOWHAND); }); break; case Msg.GameState.Result: Loom.QueueOnMainThread(() => { //m_StateManage.m_StateSeat.UpdateSeatScore(); Common.ConfigFinishTime = (int)data.GameStateNotify.Countdown / 1000; m_StateManage.ChangeState(STATE.STATE_FINISH); }); break; } break; case MessageID.SitDownNotify: if (data.SitDownNotify.Type == Msg.SitDownType.Sit) { Loom.QueueOnMainThread(() => { foreach (PlayerInfo p in Common.CPlayers) { if (p.Uid == data.SitDownNotify.Uid) { p.Score = data.SitDownNotify.Score; } } SetSeatID(data.SitDownNotify.Uid, (int)data.SitDownNotify.SeatId); foreach (PlayerInfo p1 in Common.CPlayers) { Debug.Log(p1.Uid + "===============" + p1.SeatID); } UpdateOrderList(); if (m_SelfSeatID == 0 && GetTablePlayersCount() > 1 && Common.CState == Msg.GameState.Ready) { m_Letplay.SetActive(true); } }); } break; case MessageID.StandUpNotify: if (data.StandUpNotify.Reason == StandUpReason.NoActionFor3Hands) { Loom.QueueOnMainThread(() => { if (m_SelfSeatID == 0) { m_FirstSetBanker = false; } if (data.StandUpNotify.Uid == Common.Uid) { Common.ErrorDialog(PrefabDialog, Canvas.gameObject, Common.ErrorOutdue); } }); } else if (data.StandUpNotify.Reason == StandUpReason.CreditPointsOut) { Loom.QueueOnMainThread(() => { Common.ErrorDialog(PrefabDialog, Canvas.gameObject, Common.ErrorGameCreditMax); }); } Loom.QueueOnMainThread(() => { m_StateManage.m_StateBetting.UpdateChipsUI(GetSeatIDForPlayerID(data.StandUpNotify.Uid), 0); SetSeatID(data.StandUpNotify.Uid, -1); UpdateOrderList(); if (GetTablePlayersCount() <= 1 && Common.CState == Msg.GameState.Ready) { m_Letplay.SetActive(false); } }); break; case MessageID.JoinRoomNotify: Loom.QueueOnMainThread(() => { PlayerInfo p = new PlayerInfo(); p.Uid = data.JoinRoomNotify.Uid; p.Name = data.JoinRoomNotify.Name; p.FB_avatar = data.JoinRoomNotify.Avatar; p.SeatID = -1; Common.CPlayers.Add(p); foreach (PlayerInfo p1 in Common.CPlayers) { Debug.Log(p1.Uid + "===============" + p1.SeatID); } }); break; case MessageID.KickNotify: Loom.QueueOnMainThread(() => { if (data.KickNotify.Type == Msg.KickType.StopServer) { Common.ErrorDialog(PrefabDialog, Canvas.gameObject, Common.ErrorKickGame, Common.CloseServerDialog); } else { Common.CloseServerDialog(null); } }); break; case MessageID.NoticesNotify: Loom.QueueOnMainThread(() => { foreach (Msg.Notice s in data.NoticesNotify.Notices) { if (s.Type == Msg.NoticeType.HorseLamp) { NoticeMessage nm = new NoticeMessage(); nm.text = s.Content; nm.times = 3; Common.GameNotices.Add(nm); } else { Common.ErrorDialog(PrefabDialog, Canvas.gameObject, s.Content); } } NoticeBar.OnPlay(); }); break; case MessageID.LeaveRoomNotify: Loom.QueueOnMainThread(() => { LeaveRoomEvent(data.LeaveRoomNotify.Uid); if (GetTablePlayersCount() <= 1 && Common.CState == Msg.GameState.Ready) { m_Letplay.SetActive(false); } }); break; case MessageID.BetNotify: Loom.QueueOnMainThread(() => { m_StateManage.m_StateBetting.UpdateChipsUI((int)data.BetNotify.SeatId, (int)data.BetNotify.Chips); }); break; } }