Beispiel #1
0
    void updateGrid()
    {
        // Remove old children from grid
        for (int y = 0; y < Grid3d.h; ++y)
        {
            for (int x = 0; x < Grid3d.w; ++x)
            {
                for (int z = 0; z < Grid3d.d; ++z)
                {
                    if (Grid3d.grid[x, y, z] != null)
                    {
                        if (Grid3d.grid[x, y, z].parent == transform)
                        {
                            Grid3d.grid[x, y, z] = null;
                        }
                    }
                }
            }
        }

        // Add new children to grid
        foreach (Transform child in transform)
        {
            Vector3 v = Grid3d.roundVec3(child.position);
            Grid3d.grid[(int)v.x, (int)v.y, (int)v.z] = child;
        }
    }
Beispiel #2
0
    public static void setFallPoint(Transform tf)
    {
        resetFallPoint();

        foreach (Transform child in tf)
        {
            Vector3 v = Grid3d.roundVec3(child.position);


            if ((int)v.y != 0 && Grid3d.grid[(int)v.x, (int)v.y - 1, (int)v.z] == null)
            {
                fallPosition.Add(calcPutFallPoint(child.position));
            }
        }

        isUpdateFallpoint = false;
    }
Beispiel #3
0
    bool isValidGridPos()
    {
        foreach (Transform child in transform)
        {
            Vector3 v = Grid3d.roundVec3(child.position);

            // Not inside Border?
            if (!Grid3d.insideBorder(v))
            {
                return(false);
            }

            // Block in grid cell (and not part of same group)?

            if (Grid3d.grid[(int)v.x, (int)v.y, (int)v.z] != null &&
                Grid3d.grid[(int)v.x, (int)v.y, (int)v.z].parent != transform)
            {
                return(false);
            }
        }
        return(true);
    }