Ejemplo n.º 1
0
 public boardCell(StoryCube _cube)
 {
     cellCubeId = _cube.ID;
     x = _cube.cPosX;
     y = _cube.cPosY;
     if (_cube.isGreen) {
         side = 2; // green cube
     } else {
         side = 1; // red cube
     }
     cube = _cube;
 }
Ejemplo n.º 2
0
    // ### add a cube to the onboard list
    // param: cube data + tile data
    public void AddToBoard(StoryCube _cube)
    {
        Debug.Log ("Add Cube info to current board!!");
        //boardCell ncell = new boardCell (_tile.posX, _tile.posY, _cube);
        // First check if the item is in the bp already
        if (CheckExisted (_cube)) {
            Debug.Log ("ERROR!! Cube already existed!!");
        } else {
            Debug.Log ("Adding cube " + _cube.ID);
            CubesOnBoard.Add(_cube);
            RefreshCell();

        }
    }
Ejemplo n.º 3
0
 // ## delete a cube from the onboard list
 public void RemoveFromBoard(StoryCube _cube)
 {
     Debug.Log ("Deleting cube " + _cube.ID);
     //CubesOnBoard.Remove (_cube);
 }
Ejemplo n.º 4
0
    // search the cubes on the board for Flipping
    public void SearchForReverse(StoryCube _cube)
    {
        Debug.Log("Search for flip");
        // clear the reverse cube array

        // -- search the current position -- //
        // ## search for different color
        // ## search for same color
        // ## all the cubes in between are added to the flip array
        int _posX = _cube.cPosX;
        int _posY = _cube.cPosY;
        // -- 1. search horizontally
        // searching along +x
        for (int i = _posX + 1; i < SizeW; i++) {
            if(cells[i][_posY] == null)
            {
                Debug.Log("+x is null");
                break;
            }

            if(cells[i][_posY] != null && cells[_posX][_posY].side == cells[i][_posY].side)
            {
                if(i-_posX > 1)
                {
                    for(int j = i-1; j>_posX; j--)
                    {
                        CubesToFlip.Add(cells[j][_posY].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        // searching along -x
        for (int i = _posX - 1; i >=0; i--) {
            if(cells[i][_posY] == null)
            {
                Debug.Log("-x is null");
                break;
            }

            if(cells[i][_posY] != null && cells[_posX][_posY].side == cells[i][_posY].side)
            {
                if(_posX-i > 1)
                {
                    for(int j = i+1; j<_posX; j++)
                    {
                        CubesToFlip.Add(cells[j][_posY].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        // -- 2. search vertically
        // search along +y
        for (int j = _posY + 1; j < SizeH; j++) {
            if(cells[_posX][j] == null)
            {
                Debug.Log("+y is null");
                break;
            }

            if(cells[_posX][j] != null && cells[_posX][_posY].side == cells[_posX][j].side)
            {
                if(j-_posY > 1)
                {
                    for(int i = j-1; i>_posY; i--)
                    {
                        CubesToFlip.Add(cells[_posX][i].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        // search along -y
        for (int j = _posY - 1; j >= 0; j--) {
            if(cells[_posX][j] == null)
            {
                Debug.Log("-y is null");
                break;
            }

            if(cells[_posX][j] != null && cells[_posX][_posY].side == cells[_posX][j].side)
            {
                if(_posY - j > 1)
                {
                    for(int i = j+1; i<_posY; i++)
                    {
                        CubesToFlip.Add(cells[_posX][i].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        // -- 3. search diagnally
        // searching along +x, +y
        int offset = _posY - _posX;
        for (int i = _posX + 1; i < SizeW && i+offset < SizeH; i++) {
            if(cells[i][i+offset] == null)
            {
                Debug.Log("+x +y is null");
                break;
            }

            if(cells[i][i+offset] != null && cells[_posX][_posY].side == cells[i][i+offset].side)
            {
                if(i-_posX > 1)
                {
                    for(int j = i-1; j>_posX; j--)
                    {
                        CubesToFlip.Add(cells[j][j+offset].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        // searching along -x, -y
        for (int i = _posX - 1; i >= 0 && i+offset >= 0; i--) {
            if(cells[i][i+offset] == null)
            {
                Debug.Log("-x -y is null");
                break;
            }

            if(cells[i][i+offset] != null && cells[_posX][_posY].side == cells[i][i+offset].side)
            {
                if(_posX-i > 1)
                {
                    for(int j = i+1; j<_posX; j++)
                    {
                        CubesToFlip.Add(cells[j][j+offset].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        offset = _posX + _posY;
        // searching along +x, -y
        for (int i = _posX + 1; i < SizeW && offset-i >= 0; i++) {
            if(cells[i][offset-i] == null)
            {
                Debug.Log("+x -y is null");
                break;
            }

            if(cells[i][offset-i] != null && cells[_posX][_posY].side == cells[i][offset-i].side)
            {
                if(i-_posX > 1)
                {
                    for(int j = i-1; j>_posX; j--)
                    {
                        CubesToFlip.Add(cells[j][offset-j].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        // searching along -x, +y
        for (int i = _posX - 1; i >= 0 && offset - i < SizeH; i--) {
            if(cells[i][offset-i] == null)
            {
                Debug.Log("-x +y is null");
                break;
            }

            if(cells[i][offset-i] != null && cells[_posX][_posY].side == cells[i][offset-i].side)
            {
                if(_posX-i > 1)
                {
                    for(int j = i+1; j<_posX; j++)
                    {
                        CubesToFlip.Add(cells[j][offset-j].cube);
                    }
                    break;

                }else{
                    break;
                }

            }

        }

        FlipCubes ();
        FlipText ();
    }
Ejemplo n.º 5
0
 public bool CheckExisted(StoryCube _cube)
 {
     return false;
 }