public GamePlayerModel GetGamePlayerByUserIndex(long userIndex) { GamePlayerModel gamePlayer = null; if (Room == null) { return(null); } for (int i = 0; i < Room.gamePlayers.Count; i++) { if (Room.gamePlayers[i].userIndex == userIndex) { gamePlayer = new GamePlayerModel(); gamePlayer.SetGamePlayer(Room.gamePlayers[i], Room); break; } } return(gamePlayer); }
private void OnGetRoomHandler(PacketData data) { room = JsonConverter.GetObject <Room>((Dictionary <string, object>)data.data["Room"]); if (data.data["GamePlayers"] != null) { object[] temp = (object[])data.data["GamePlayers"]; if (temp.Length > 0) { List <GamePlayer> gamePlayers = JsonConverter.GetObjectList <GamePlayer>((Dictionary <string, object>[])temp); room.gamePlayers = gamePlayers; } } currentState = room.state; if (currentState != RoomState.Playing) { room.currentOrderNo = -1; room.currentUserIndex = 0; } for (int i = 0; i < room.gamePlayers.Count; i++) { if (room.gamePlayers[i].userIndex == room.currentUserIndex) { currentGamePlayer = room.gamePlayers[i]; } gamePlayerUpdateModel.SetGamePlayer(room.gamePlayers[i], Room); gameEvent.InvokeGamePlayerEvent(gamePlayerUpdateModel); } roomModel.SetRoomData(room); if (roomModel.stage < 17) { gameEvent.InvokeRoomEvent(roomModel); } }
private void OnLoginCompleteHandler(object obj) { roomModel.ObserveEveryValueChanged(x => x.currentUserIndex).Subscribe(x => { if (x == 0 || currentGamePlayer == null) { return; } if (CheckPreFlopBlind(currentGamePlayer) == false) { gamePlayerModel.SetGamePlayer(currentGamePlayer, Room); gameEvent.InvokePlayerTurnEvent(gamePlayerModel); } }).AddTo(this); roomModel.ObserveEveryValueChanged(x => x.stage).Where(x => x == 17).Subscribe(x => { gameEvent.InvokeClearEvent(); }); InvokeRepeating("Thread", 0, 0.5f); }