Esempio n. 1
0
 /// <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();
     }
 }
Esempio n. 2
0
        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];
            }
        }
Esempio n. 3
0
        /// <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();
        }
Esempio n. 4
0
        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];
            }
        }
Esempio n. 5
0
 ///<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();
 }
Esempio n. 6
0
    //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);
    }
Esempio n. 7
0
 public void setState(Coordinates coords, cellState state)
 {
     setState(coords.X, coords.Y, state);
 }
Esempio n. 8
0
 public void setState(int x, int y, cellState state)
 {
     map[x][y] = state;
 }
Esempio n. 9
0
 public HashCell()
 {
     state = cellState.vacio;
 }
Esempio n. 10
0
 public void setState(Coordinates coords, cellState state)
 {
     setState(coords.X, coords.Y, state);
 }
Esempio n. 11
0
 public void setState(int x, int y, cellState state)
 {
     map[x][y] = state;
 }