Esempio n. 1
0
            public void AnimateState(SeaCellState newState)
            {
                this._value = newState;
                ColorAnimation ca = new ColorAnimation();

                ca.From     = (this._control.Background as SolidColorBrush).Color;
                ca.To       = SeaBoard.CellBackgroundColors[newState];
                ca.Duration = new Duration(TimeSpan.FromSeconds(0.5));
                this._control.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            }
Esempio n. 2
0
        public SeaCellState[,] ToRectangularArray()
        {
            SeaCellState[,] tmp = new SeaCellState[this.BoardSize, this.BoardSize];
            int i = 0;

            for (int x = 0; x < this.BoardSize; x++)
            {
                for (int y = 0; y < this.BoardSize; y++, i++)
                {
                    tmp[x, y] = this.Board.ElementAt(i);
                }
            }
            return(tmp);
        }
Esempio n. 3
0
 public SeaCellState[,] GetSimplifiedBoard()
 {
     SeaCellState[,] ret = new SeaCellState[this.BoardSize, this.BoardSize];
     lock (this.Cells)
     {
         for (int x = 0; x < this.BoardSize; x++)
         {
             for (int y = 0; y < this.BoardSize; y++)
             {
                 ret[x, y] = this.Cells[x, y].CellState;
             }
         }
     }
     return(ret);
 }
Esempio n. 4
0
        public SimpleBoard(SeaCellState[,] board)
        {
            if ((this.BoardSize = board.GetLength(0)) != board.GetLength(1))
            {
                throw new InvalidCastException();
            }
            var tmp = new SeaCellState[BoardSize * BoardSize];
            int i   = 0;

            for (int x = 0; x < this.BoardSize; x++)
            {
                for (int y = 0; y < this.BoardSize; y++, i++)
                {
                    tmp[i] = board[x, y];
                }
            }
            this.Board = tmp;
        }
Esempio n. 5
0
 public SimpleSeaCell(int x, int y, SeaCellState state)
 {
     this.X         = x;
     this.Y         = y;
     this.CellState = state;
 }
Esempio n. 6
0
 public void SetState(SeaCellState state)
 {
     this.CellState = state;
     OnCellStateChanged?.Invoke(this);
 }
Esempio n. 7
0
 public SeaCell(int x, int y, SeaCellState state = SeaCellState.SEA)
 {
     this.X         = x;
     this.Y         = y;
     this.CellState = state;
 }