Beispiel #1
0
    private PosScalePair GetWestWallTf(int row, int col)
    {
        float xPos = xStart + col * wallLength;
        float zPos = zStart + row * wallLength;
        float yPos = wallHeight / 2f;

        PosScalePair psp = new PosScalePair()
        {
            pos   = new Vector3(xPos - wallLength / 2, yPos, zPos),
            scale = new Vector3(wallWidth, wallHeight, wallLength)
        };

        // West wall is only placed when col == 0
        if (mazeGen.Maze[row, col].northWall)
        {
            psp.scale += Vector3.back * wallWidth / 2;
            psp.pos   += Vector3.back * wallWidth / 4;
        }
        if (mazeGen.Maze[row, col].southWall)
        {
            psp.scale += Vector3.back * wallWidth / 2;
            psp.pos   += Vector3.forward * wallWidth / 4;
        }

        return(psp);
    }
Beispiel #2
0
    private void PlaceNewWall(PosScalePair psp)
    {
        GameObject newWall = Object.Instantiate(mazeWallRef, mazeParent);

        newWall.transform.position   = psp.pos;
        newWall.transform.localScale = psp.scale;
    }
Beispiel #3
0
    private void PlaceCell(int row, int col)
    {
        if (mazeGen.Maze[row, col].northWall)
        {
            PosScalePair psp = GetNorthWallTf(row, col);
            PlaceNewWall(psp);
        }

        if (mazeGen.Maze[row, col].eastWall)
        {
            PosScalePair psp = GetEastWallTf(row, col);
            PlaceNewWall(psp);
        }

        if (col == 0 && mazeGen.Maze[row, col].westWall)
        {
            PosScalePair psp = GetWestWallTf(row, col);
            PlaceNewWall(psp);
        }

        if (row == 0 && mazeGen.Maze[row, col].southWall)
        {
            PosScalePair psp = GetSouthWallTf(row, col);
            PlaceNewWall(psp);
        }
    }
Beispiel #4
0
    private PosScalePair GetEastWallTf(int row, int col)
    {
        float xPos = xStart + col * wallLength;
        float zPos = zStart + row * wallLength;
        float yPos = wallHeight / 2f;

        PosScalePair psp = new PosScalePair()
        {
            pos   = new Vector3(xPos + wallLength / 2f, yPos, zPos),
            scale = new Vector3(wallWidth, wallHeight, wallLength)
        };

        if (mazeGen.Maze[row, col].northWall || (col < mazeScript.cols - 1 && mazeGen.Maze[row, col + 1].northWall))
        {
            psp.scale += Vector3.back * wallWidth / 2;
            psp.pos   += Vector3.back * wallWidth / 4;
        }
        if (mazeGen.Maze[row, col].southWall || (col < mazeScript.cols - 1 && mazeGen.Maze[row, col + 1].southWall))
        {
            psp.scale += Vector3.back * wallWidth / 2;
            psp.pos   += Vector3.forward * wallWidth / 4;
        }

        return(psp);
    }
Beispiel #5
0
    private PosScalePair GetSouthWallTf(int row, int col)
    {
        float xPos = xStart + col * wallLength;
        float zPos = zStart + row * wallLength;
        float yPos = wallHeight / 2f;

        PosScalePair psp = new PosScalePair()
        {
            pos   = new Vector3(xPos, yPos, zPos - wallLength / 2f),
            scale = new Vector3(wallLength, wallHeight, wallWidth)
        };

        // South walls are only placed when row == 0
        if (col == 0)
        {
            psp.scale += Vector3.right * wallWidth / 2;
            psp.pos   += Vector3.left * wallWidth / 4;
        }
        else if (col == mazeScript.cols - 1)
        {
            psp.scale += Vector3.right * wallWidth / 2;
            psp.pos   += Vector3.right * wallWidth / 4;
        }
        else
        {
            if (mazeGen.Maze[row, col].westWall && !(col > 0 && mazeGen.Maze[row, col - 1].southWall))
            {
                psp.scale += Vector3.right * wallWidth / 2;
                psp.pos   += Vector3.left * wallWidth / 4;
            }
            if (mazeGen.Maze[row, col].eastWall && !(col < mazeScript.cols - 1 && mazeGen.Maze[row, col + 1].southWall))
            {
                psp.scale += Vector3.right * wallWidth / 2;
                psp.pos   += Vector3.right * wallWidth / 4;
            }
        }

        return(psp);
    }