Ejemplo 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);
            }
Ejemplo 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);
        }
Ejemplo 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);
 }
Ejemplo 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;
        }
Ejemplo n.º 5
0
 public SimpleSeaCell(int x, int y, SeaCellState state)
 {
     this.X         = x;
     this.Y         = y;
     this.CellState = state;
 }
Ejemplo n.º 6
0
 public void SetState(SeaCellState state)
 {
     this.CellState = state;
     OnCellStateChanged?.Invoke(this);
 }
Ejemplo n.º 7
0
 public SeaCell(int x, int y, SeaCellState state = SeaCellState.SEA)
 {
     this.X         = x;
     this.Y         = y;
     this.CellState = state;
 }