Exemplo n.º 1
0
    public static MazeSector Generate(GridPosition Origin, int Width, int Height, EMazeAlgorithm Algorithm)
    {
        MazeSector Sector = new MazeSector(Origin, Width, Height, Algorithm);

        Sector.Generate();
        return(Sector);
    }
Exemplo n.º 2
0
    public void GenerateSimpleFloor(int Size, EMazeAlgorithm Algorithm)
    {
        m_Sectors.Clear();

        MazeSector Sector = MazeSector.Generate(new GridPosition(0, 0, 0), Size, Size, Algorithm);

        AddSector(Sector);
    }
Exemplo n.º 3
0
    public void GenerateComplexFloor(int SectorCount, int SectorSpacing)
    {
        m_Sectors.Clear();

        List <MazeSector> SectorList = new List <MazeSector>();


        // The first sector defaults to a 5x5 room so we have a consistent starting point
        int            SectorWidth  = 5;
        int            SectorHeight = 5;
        GridPosition   SectorOrigin = GridPosition.zero;
        EMazeAlgorithm Algorithm    = EMazeAlgorithm.SIMPLE;
        MazeSector     LastSector   = MazeSector.Generate(SectorOrigin, SectorWidth, SectorHeight, Algorithm);

        SectorList.Add(LastSector);

        // The rest of the sectors will be semi-randomly generated and placed towards the left or up
        // and have simple connectors for now
        GridPosition ConnectorOrigin = GridPosition.zero;
        int          ConnectorWidth  = 0;
        int          ConnectorHeight = 0;

        for (int x = 1; x < SectorCount; x++)
        {
            // Set up our parms for the next sector
            SectorWidth  = Random.Range(SectorSpacing - 10, SectorSpacing - 5);
            SectorHeight = Random.Range(SectorSpacing - 10, SectorSpacing - 5);

            if ((x % 2) == 1)
            {
                ConnectorOrigin = new GridPosition(SectorOrigin.x - Mathf.FloorToInt(SectorSpacing / 2), SectorOrigin.y, 0);
                ConnectorHeight = 3;
                ConnectorWidth  = SectorSpacing;

                SectorOrigin = new GridPosition(SectorOrigin.x - SectorSpacing, SectorOrigin.y, 0);
            }
            else
            {
                ConnectorOrigin = new GridPosition(SectorOrigin.x, SectorOrigin.y + Mathf.FloorToInt(SectorSpacing / 2), 0);
                ConnectorHeight = SectorSpacing;
                ConnectorWidth  = 3;

                SectorOrigin = new GridPosition(SectorOrigin.x, SectorOrigin.y + SectorSpacing, 0);
            }

            switch (x % 3)
            {
            case 0:
                Algorithm = EMazeAlgorithm.SIMPLE;
                break;

            case 1:
                Algorithm = EMazeAlgorithm.CELLULAR_AUTOMATA;
                break;

            case 2:
                Algorithm = EMazeAlgorithm.GROWING_TREE;
                break;
            }

            MazeSector NextSector = MazeSector.Generate(SectorOrigin, SectorWidth, SectorHeight, Algorithm);
            SectorList.Add(NextSector);

            //Add a connector between the two sectors and update our lastsector
            SectorList.Add(MazeSector.Generate(ConnectorOrigin, ConnectorWidth, ConnectorHeight, EMazeAlgorithm.SIMPLE));
            LastSector = NextSector;
        }

        AddSectors(SectorList);
    }