Exemplo n.º 1
0
    public GameObject GetCubeAtIndex(int col, int row)
    {
        if (col >= cubeSpread)
        {
            col = col % cubeSpread;
        }
        if (col < 0)
        {
            col = cubeSpread + col;
        }

        GameObject cube = cubeRow[col];

        while (cube != null && row > 0)
        {
            CubeScript cs = cube.GetComponent <CubeScript>();
            if (cs != null)
            {
                cube = cs.GetCubeAbove();
                row -= 1;
            }
            else
            {
                return(null);
            }
        }
        return(cube);
    }
Exemplo n.º 2
0
    public int FindCubeIndex(GameObject target)
    {
        GameObject cube    = cubeRow[target.GetComponent <CubeScript>().GetCubeIndex()];
        int        counter = 0;

        while (cube != null && cube != target)
        {
            CubeScript cubeScript = gameObject.GetComponent <CubeScript>();
            if (cubeScript == null)
            {
                break;
            }
            cube = cubeScript.GetCubeAbove();
            counter++;
        }
        return(counter);
    }