Пример #1
0
        private void OnGameStateSyncResponse(NetworkMessage msg)
        {
            GameStateSyncMessage message = msg.ReadMessage <GameStateSyncMessage>();

            _friendlyMonsterState       = JsonConvert.DeserializeObject <Dictionary <int, int> >(message.HostMonsterState);
            _enemyMonsterState          = JsonConvert.DeserializeObject <Dictionary <int, int> >(message.GuestMonsterState);
            _monstersWithAvailableMoves = _friendlyMonsterState.Keys.ToList();
        }
Пример #2
0
        private void OnGameStateSyncResponse(NetworkMessage msg)
        {
            GameStateSyncMessage message = msg.ReadMessage <GameStateSyncMessage>();

            message.ActionNumber = AdjustActionNumber(message.ActionNumber);

            //Convert json strings to objects
            Dictionary <int, int> friendlyMonsterState = IsHost ? JsonConvert.DeserializeObject <Dictionary <int, int> >(message.HostMonsterState) : JsonConvert.DeserializeObject <Dictionary <int, int> >(message.GuestMonsterState);
            Dictionary <int, int> enemyMonsterState    = IsHost ? JsonConvert.DeserializeObject <Dictionary <int, int> >(message.GuestMonsterState) : JsonConvert.DeserializeObject <Dictionary <int, int> >(message.HostMonsterState);

            List <int> movementPathIds = message.MovementPathIds != null?JsonConvert.DeserializeObject <List <int> >(message.MovementPathIds) : null;

            IEnumerable <int> availablePushDestinationIds =
                JsonConvert.DeserializeObject <IEnumerable <int> >(message.AvailablePushDestinationIds);

            GameState.SyncGameState(friendlyMonsterState, enemyMonsterState, movementPathIds, availablePushDestinationIds, message.ActionNumber, message.SubActionNumber, message.SelectedMonsterTypeId, message.SelectedAttackNodeId, message.DestinationNodeId);
        }