Exemple #1
0
    public static bool UpdateLine(char objType, int i, int j, int k)
    {
        GameObject drawnLine = null;

        if (objType == 'X')
        {
            drawnLine = MainGameScript.Grid_LinesX[i, j, k];
        }
        else if (objType == 'Y')
        {
            drawnLine = MainGameScript.Grid_LinesY[i, j, k];
        }
        else if (objType == 'Z')
        {
            drawnLine = MainGameScript.Grid_LinesZ[i, j, k];
        }

        if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
        {
            LineScript.Draw(objType, i, j, k);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #2
0
    //Find a line that has not yet been drawn given some parameters, draw it
    private static bool DrawAvailLine(int MinX, int MaxX, int MinY, int MaxY, int MinZ, int MaxZ)
    {
        int        i, j, k;
        int        rndSeed   = new System.Random().Next(0, 3);
        GameObject drawnLine = null;

        //Loop through X lines, then Y lines, then Z lines
        if (rndSeed == 0)
        {
            for (j = MinY; j <= MaxY; j++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesX[MinX, j, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: X" + MinX + j + k);
                        LineScript.Draw('X', MinX, j, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesY[i, MinY, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Y" + i + MinY + k);
                        LineScript.Draw('Y', i, MinY, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (j = MinY; j <= MaxY; j++)
                {
                    drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Z" + i + j + MinZ);
                        LineScript.Draw('Z', i, j, MinZ);
                        return(true);
                    }
                }
            }
        }

        //Loop through Y lines, then Z lines, then X lines
        else if (rndSeed == 1)
        {
            for (i = MinX; i <= MaxX; i++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesY[i, MinY, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Y" + i + MinY + k);
                        LineScript.Draw('Y', i, MinY, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (j = MinY; j <= MaxY; j++)
                {
                    drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Z" + i + j + MinZ);
                        LineScript.Draw('Z', i, j, MinZ);
                        return(true);
                    }
                }
            }

            for (j = MinY; j <= MaxY; j++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesX[MinX, j, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: X" + MinX + j + k);
                        LineScript.Draw('X', MinX, j, k);
                        return(true);
                    }
                }
            }
        }

        //Loop through Z lines, then X lines, then Y lines
        else
        {
            for (i = MinX; i <= MaxX; i++)
            {
                for (j = MinY; j <= MaxY; j++)
                {
                    drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Z" + i + j + MinZ);
                        LineScript.Draw('Z', i, j, MinZ);
                        return(true);
                    }
                }
            }

            for (j = MinY; j <= MaxY; j++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesX[MinX, j, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: X" + MinX + j + k);
                        LineScript.Draw('X', MinX, j, k);
                        return(true);
                    }
                }
            }

            for (i = MinX; i <= MaxX; i++)
            {
                for (k = MinZ; k <= MaxZ; k++)
                {
                    drawnLine = MainGameScript.Grid_LinesY[i, MinY, k];
                    if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false)
                    {
                        Debug.Log("CPU Drawing line: Y" + i + MinY + k);
                        LineScript.Draw('Y', i, MinY, k);
                        return(true);
                    }
                }
            }
        }

        return(false);
    }