public CellData [] Expand() { CellData[] toReturn = new CellData[8]; BoardData boardData = BoardData.Get(); int columns = boardData.GetColumns(); int rows = boardData.GetRows(); //Up toReturn[0] = this.GetX() < (columns - 1) ? boardData.GetCellDataAt(this.GetX() + 1, this.GetY()) : null; //Right toReturn[1] = this.GetY() < (rows - 1) ? boardData.GetCellDataAt(this.GetX(), this.GetY() + 1) : null; //Down toReturn[2] = this.GetX() > 0 ? boardData.GetCellDataAt(this.GetX() - 1, this.GetY()) : null; //Left toReturn[3] = this.GetY() > 0 ? boardData.GetCellDataAt(this.GetX(), this.GetY() - 1) : null; //UpRight toReturn[4] = !(toReturn[0] is null) && !(toReturn[1] is null) ? boardData.GetCellDataAt(this.GetX() + 1, this.GetY() + 1) : null; //RightDown toReturn[5] = !(toReturn[1] is null) && !(toReturn[2] is null) ? boardData.GetCellDataAt(this.GetX() - 1, this.GetY() + 1) : null; //LeftDown toReturn[6] = !(toReturn[2] is null) && !(toReturn[3] is null) ? boardData.GetCellDataAt(this.GetX() - 1, this.GetY() - 1) : null; //UpLeft toReturn[7] = !(toReturn[0] is null) && !(toReturn[3] is null) ? boardData.GetCellDataAt(this.GetX() + 1, this.GetY() - 1) : null; return(toReturn); }
public static CellData operator --(CellData thisCell) { BoardData boardData = BoardData.Get(); int columns = boardData.GetColumns(); int rows = boardData.GetRows(); int newX = thisCell.GetX(); int newY = thisCell.GetY(); --newY; if (newY < 0) { newY = rows - 1; --newX; } return(boardData.GetCellDataAt(newX, newY)); }
private void HideCells() { BoardData boardData = BoardData.Get(); int maxColumns = boardData.GetColumns(); int maxRows = boardData.GetRows(); CellData firstNonPlayerCell = boardData.GetBoardCenterCell(); CellData lastCellOnBoard = boardData.GetCellDataAt(maxColumns - 1, maxRows - 1); --firstNonPlayerCell; while (firstNonPlayerCell != lastCellOnBoard) { firstNonPlayerCell.GetVisibleItem().Hide(); ++firstNonPlayerCell; } lastCellOnBoard.GetVisibleItem().Hide(); }