Example #1
0
        public void Clear(int x, int y)
        {
            if (x < 0 || x > Board.Width)
            {
                throw new ArgumentException("Value is out of range", nameof(x));
            }

            if (y < 0 || y > Board.Height)
            {
                throw new ArgumentException("Value is out of range", nameof(y));
            }

            TileVM tileVM = this[x, y];

            tileVM.Piece = (Piece)Pieces.None;
            HighlightedTiles.Remove(tileVM);
        }
Example #2
0
        public void Set(int x, int y, Piece piece)
        {
            if (x < 0 || x > Board.Width)
            {
                throw new ArgumentException("Value is out of range", nameof(x));
            }

            if (y < 0 || y > Board.Height)
            {
                throw new ArgumentException("Value is out of range", nameof(y));
            }

            TileVM tileVM = this[x, y];

            tileVM.Piece = piece;
            HighlightedTiles.Add(tileVM);
        }
Example #3
0
        public BoardVM(Game game)
        {
            Board = game.Board;

            TileVMs = new TileVM[Board.Width, Board.Height];
            for (var i = 0; i < Board.Width; i++)
            {
                for (var j = 0; j < Board.Height; j++)
                {
                    TileVMs[i, j] = new TileVM(Board[i, j]);
                }
            }

            HighlightedTiles = new ObservableCollection <TileVM>();
            HighlightedTiles.CollectionChanged += HighlightedTiles_CollectionChanged;
            game.BoardChanged += Game_BoardChanged;
            game.GameOver     += Game_GameOver;
        }