Exemplo n.º 1
0
    void UpdateMatrixGrid()
    {
        for (int x = MatrixScript.start_point; x < MatrixScript.length_of_playground; ++x)
        {
            for (int z = MatrixScript.start_point; z < MatrixScript.length_of_playground; ++z)
            {
                for (int y = 0; y < MatrixScript.column; ++y)
                {
                    if (MatrixScript.grid[x, y, z] != null)
                    {
                        if (MatrixScript.grid[x, y, z].parent == transform)
                        {
                            MatrixScript.grid[x, y, z] = null;
                        }
                    }
                }
            }
        }

        foreach (Transform child in transform)
        {
            Vector3 vector3 = MatrixScript.RoundVector(child.position);
            MatrixScript.grid[(int)vector3.x, (int)vector3.y, (int)vector3.z] = child;
        }
    }
Exemplo n.º 2
0
    public bool IsValidGridPosition()
    {
        foreach (Transform child in transform)
        {
            Vector3 vector3 = MatrixScript.RoundVector(child.position);

            if (!MatrixScript.IsInsideBorders(vector3))
            {
                return(false);
            }

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