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