Beispiel #1
0
        /// Clears the current state and displays the given state.
        public void Reset(GameState state)
        {
            if (state.BoardSize == BoardSize)
            {
                ResetDifferential(state);
                return;
            }

            Tiles.Clear();
            CurrentState = state;
            BoardSize    = state.BoardSize;
            var range = Enumerable.Range(0, BoardSize).ToList();
            var tiles
                = range.SelectMany(x => range.Select(y => new TileViewModel(MessengerInstance, Position2D.New(x, y))))
                  .Cast <ITilePresenter>();

            foreach (var tile in tiles)
            {
                tile.Update(state.PlayerOn(tile.Position), state.HasBall(tile.Position));
                Tiles.Add(tile);
            }

            UnlockedPlayer = null;
        }