public void InitDataWhenGetTableInfo(MessageReceiving _mess) { InitListOtherUserDataInGame(_mess); InitListOnChair(_mess); totalBet = 0; sumCardGet = 0; betDefault = _mess.readLong(); currentBet = _mess.readLong(); timeDurringChangeCircle = _mess.readInt(); timeDurringPlayGame = _mess.readInt(); currentGameState = (GameState)_mess.readByte(); indexCircleBeSkipped = -1; if (currentGameState == GameState.STATUS_WAIT_FOR_PLAYER) { long _timeLeftToStartGame = _mess.readLong(); // thời gian đếm ngược để start game (nếu dương) if (_timeLeftToStartGame > 0) { nextTimeToStartGame = System.DateTime.Now.AddMilliseconds(_timeLeftToStartGame); } else { nextTimeToStartGame = System.DateTime.Now; } lastCardPut = -1; currentColor = GetBackgroundColor(lastCardPut); nextTimeToStopGame = System.DateTime.MinValue; } else { nextTimeToStartGame = System.DateTime.Now; long _timeLeftToStopGame = _mess.readLong(); nextTimeToStopGame = System.DateTime.Now.AddMilliseconds(_timeLeftToStopGame); lastCardPut = _mess.readByte(); globalCards.Add(lastCardPut); bool _direction = _mess.readBoolean(); turnDirection = _direction ? TurnDirection.ClockWise : TurnDirection.CounterClockWise; currentCircle = _mess.readByte(); sbyte _circleLength = _mess.readByte(); for (int i = 0; i < _circleLength; i++) { Uno_PlayerPlayingData _tmpData = new Uno_PlayerPlayingData(_mess, listSessionIdGlobalPlayer); _tmpData.totalBet = currentBet; listPlayerPlayingData.Add(_tmpData); listSessionIdPlaying.Add(_tmpData.userData.sessionId); totalBet += currentBet; } long _timeLeftToChangeCircle = _mess.readLong(); nextTimeToChangeCircle = System.DateTime.Now.AddMilliseconds(_timeLeftToChangeCircle); currentColor = GetBackgroundColor(lastCardPut); } hasLoadTableInfo = true; }
public Uno_StartGame_Data(MessageReceiving _mess, UnoGamePlayData _unoGamePlayData) { turnDirection = TurnDirection.ClockWise; sbyte _numCard = 7; sbyte[] _myCards = new sbyte[_numCard]; for (int i = 0; i < _myCards.Length; i++) { _myCards[i] = _mess.readByte(); } currentBet = _mess.readLong(); sbyte _circleLength = _mess.readByte(); totalBet = 0; listPlayerPlaying = new List <Uno_PlayerPlayingData>(); listSessionIdPlaying = new List <short>(); Uno_PlayerPlayingData _tmpPlayerPlaying = null; for (int i = 0; i < _circleLength; i++) { _tmpPlayerPlaying = new Uno_PlayerPlayingData(); short _sessionId = _mess.readShort(); _tmpPlayerPlaying.indexChair = _mess.readByte(); _tmpPlayerPlaying.userData = new UserDataInGame(_mess, _sessionId, -1); if (_unoGamePlayData.CheckIfIsMe(_sessionId)) { _tmpPlayerPlaying.isMe = true; for (int j = 0; j < _numCard; j++) { _tmpPlayerPlaying.ownCards.Add(_myCards[j]); } } else { _tmpPlayerPlaying.isMe = false; for (int j = 0; j < _numCard; j++) { _tmpPlayerPlaying.ownCards.Add(-1); } } _tmpPlayerPlaying.totalBet = currentBet; totalBet += currentBet; listPlayerPlaying.Add(_tmpPlayerPlaying); listSessionIdPlaying.Add(_sessionId); } long _timeLeftToChangeCircle = _unoGamePlayData.timeDurringChangeCircle; nextTimeToChangeCircle = System.DateTime.Now.AddMilliseconds(_timeLeftToChangeCircle); long _timeLeftToStopGame = _unoGamePlayData.timeDurringPlayGame; nextTimeToStopGame = System.DateTime.Now.AddMilliseconds(_timeLeftToStopGame); // Debug.Log(">>> " + timeLeftToChangeCircle + " -- " + nextTimeToChangeCircle); }