/// <summary> /// <para>Sweeps the cell for mines</para> /// <para>If there are mines, the game is over</para> /// <para>If there are no mines, the number of adjacent mines is displayed</para> /// <para>If there are no adjacent mines, adjacent cells are activated</para> /// </summary> internal void activate() { if (state == cellState.normal) { if (mined) { state = cellState.exploded; parent.gameEnd(false); } else { List <GridCell> adjacentCells = parent.getAdjacentCells(position); if (adjacentCells.Count == 0) { state = cellState.empty; adjacentCells = parent.getAdjacentCells(position, false); for (int i = 0; i < adjacentCells.Count; i++) { adjacentCells[i].activate(); } } else { state = cellState.numbered; } } cellStateUpdate(); parent.checkVictory(); } }
public CellStateMap(int size) { this.size = size; this.map = new cellState[size][]; for (int i = 0; i < map.Length; i++) { map[i] = new cellState[size]; } }
/// <summary> /// Sets the basic information about the cell. Much of the rest of the work is handled automatically. /// </summary> /// <param name="parentGrid"></param> /// <param name="gridLocation"></param> internal GridCell(GameGrid parentGrid, Coordinate gridLocation) { parent = parentGrid; state = cellState.normal; mined = false; position = gridLocation; cellButton = createButton(); cellStateUpdate(); }
///<summary> ///Cycles between the three possible states of the button before it's pushed ///Normal -> Flagged -> Unsure -> ... ///</summary> private void flagStateToggle() { //Only toggle if we've not been clicked already if (state > cellState.unsure) { return; } //Toggle state between the three possibilities state = state + 1; if (state > cellState.unsure) { state = cellState.normal; } cellStateUpdate(); }
//it recieves the tile it need to change and changes it based off whos turn it currently is public void SpawnPiece(GameObject clickedCell) { if (playerTurn == cellState.cross) { PlaySound(0); cross = Instantiate(cross, clickedCell.transform.position, Quaternion.identity); cross.transform.parent = GameObject.Find("Game").transform; playerTurn = cellState.naught; } else { PlaySound(1); naught = Instantiate(naught, clickedCell.transform.position, Quaternion.identity); naught.transform.parent = GameObject.Find("Game").transform; playerTurn = cellState.cross; } turn.text = playerTurn.ToString(); Destroy(clickedCell.gameObject); }
public void setState(Coordinates coords, cellState state) { setState(coords.X, coords.Y, state); }
public void setState(int x, int y, cellState state) { map[x][y] = state; }
public HashCell() { state = cellState.vacio; }