Пример #1
0
        /// <summary>Updates the state.</summary>
        public State Update(Serialization.Game game)
        {
            var state = new State()
            {
                hero1     = Hero.Create(game.heroes[0]),
                hero2     = Hero.Create(game.heroes[1]),
                hero3     = Hero.Create(game.heroes[2]),
                hero4     = Hero.Create(game.heroes[3]),
                ownership = ownership.UpdateFromTiles(game.board.tiles),
            };

            state.hash = GetHash(game.turn, state.hero1, state.hero2, state.hero3, state.hero4);
            return(state);
        }
Пример #2
0
        /// <summary>Updates the games based on the response of the request.</summary>
        public void Update(Serialization.Game game)
        {
            foreach (var hero in game.heroes)
            {
                var player = (PlayerType)hero.id;
                if (hero.crashed && !m_IsCrashed[player])
                {
                    var spawn   = GetSpawn(player);
                    var current = this[hero.pos.y, hero.pos.x];
                    if (spawn.IsPassable && current == spawn)
                    {
                        spawn.IsPassable = false;
                    }
                    // maybe a Tavern is not longer available.
                    this.DistanceToTavern = GetDistances(this.Taverns);

                    // maybe the paths are not longer equal.
                    ClearDistances();

                    m_IsCrashed[player] = true;
                }
            }
        }