Beispiel #1
0
    public void CheckNeighbors(int col, int row, int color)
    {
        BoardSpot p = boardSpots [col, row];        // recusively check the neighbors

        CheckWestNeighbor(p.col - 1, p.row, p.myPiece.Color);
        CheckEastNeighbor(p.col + 1, p.row, p.myPiece.Color);
        CheckNorthNeighbor(p.col, p.row + 1, p.myPiece.Color);
        CheckSouthNeighbor(p.col, p.row - 1, p.myPiece.Color);
        // if the row count > matchSize
        if (rows.Count >= matchSize - 1)
        {
            rows.Add(p);
            Debug.Log("Found a Match" + rows.ToString());
            foreach (BoardSpot spot in rows)
            {
                spot.DestroyPiece();
            }
        }
        if (cols.Count >= matchSize - 1)
        {
            if (rows.Count < matchSize)
            {
                cols.Add(p);
            }
            Debug.Log("Found a Match" + cols.ToString());
            foreach (BoardSpot spot in cols)
            {
                spot.DestroyPiece();
            }
        }
    }
 public GameStateData()
 {
     score          = 0;
     gridSize       = 4;
     undosRemaining = 0;
     isGameOver     = false;
     isGameWon      = false;
     allowUndo      = true;
     undoStored     = false;
     lastTurnValues = new Stack <int[, ]>();
     bs             = new BoardSpot(0.1f);
 }
Beispiel #3
0
    public void CheckNorthNeighbor(int col, int row, int color)
    {
        if (row >= maxRows)
        {
            return;
        }
        BoardSpot p = boardSpots [col, row];        // recusively check the neighbors

        if (p.myPiece != null && p.myPiece.Color != color)
        {
            return;
        }
        cols.Add(p);
        CheckNorthNeighbor(p.col, row + 1, color);
    }
Beispiel #4
0
    public void CheckEastNeighbor(int col, int row, int color)
    {
        if (col >= maxCols)
        {
            return;
        }
        BoardSpot p = boardSpots [col, row];         // recusively check the neighbors

        if (p.myPiece != null && p.myPiece.Color != color)
        {
            return;
        }
        rows.Add(p);
        CheckEastNeighbor(col + 1, p.row, color);
    }
Beispiel #5
0
    public void CheckWestNeighbor(int col, int row, int color)
    {
        // check boundary
        if (col < 0)
        {
            return;
        }
        BoardSpot p = boardSpots [col, row];         // recusively check the neighbors

        if (p.myPiece != null && p.myPiece.Color != color)
        {
            return;           // mark as checked
        }
        rows.Add(p);          // continue checking
        CheckWestNeighbor(col - 1, p.row, color);
    }
Beispiel #6
0
 public void DestroyPiece()
 {
     mySpot = null;
     board  = null;
     Destroy(this.gameObject);
 }
Beispiel #7
0
 public void CheckMatches(BoardSpot spot)
 {
     rows = new List <BoardSpot> ();
     cols = new List <BoardSpot> ();
     CheckNeighbors(spot.col, spot.row, spot.myPiece.Color);
 }