Пример #1
0
    void SetPlayableArray()
    {
        playableCubes = new ArrayCubes[create.widthX, create.heightY];
        for (int i = 0; i < create.widthX; i++)
        {
            for (int j = 0; j < create.heightY; j++)
            {
                int k = 0;

                Vector3 V = ReOrderijk(i, j, k);
                //print(V);
                int vX = (int)V.x;
                int vY = (int)V.y;
                int vZ = (int)V.z;

                ArrayCubes c = create.cubeArray[vX, vY, vZ];

                while (!(playableCubes [i, j] == c || playableCubes [i, j] == deadCube))
                {
                    c = create.cubeArray[vX, vY, vZ];

                    if (c.active)
                    {
                        playableCubes [i, j] = c;
                    }
                    else if (vZ < create.depthZ)
                    {
                        vZ += cFace.ZDirection();
                        print(vZ);
                    }
                    if (vZ >= create.depthZ || vZ < 0)
                    {
                        // Dead square
                        playableCubes [i, j] = deadCube;
                    }
                }
            }
        }
        print(playableCubes[0, 0].x + ", " + playableCubes[0, 0].y + ", " + playableCubes[0, 0].z);
    }
Пример #2
0
    void Awake()
    {
        cubePositions = new Vector3[widthX * heightY * depthZ];
        cubeArray     = new ArrayCubes[widthX, heightY, depthZ];

        for (int x = 0; x < widthX; x++)
        {
            for (int y = 0; y < heightY; y++)
            {
                for (int z = 0; z < depthZ; z++)
                {
                    cubePositions[z] = new Vector3(x, y, z);
                    ArrayCubes cube = Instantiate(cubePrefab, new Vector3(x - widthX / 2 + 0.5f, y - heightY / 2 + 0.5f, z - depthZ / 2 + 0.5f), Quaternion.identity);
                    cube.gameObject.transform.parent = gameObject.transform;
                    cube.x             = x;
                    cube.y             = y;
                    cube.z             = z;
                    cubeArray[x, y, z] = cube;
                }
            }
        }
    }