예제 #1
0
    // Generate a new Room
    public void Generate()
    {
        GridGenerator.Rooms += 0.02f;
        if (GridGenerator.Corridors < 5)
        {
            GridGenerator.Corridors += 0.04f;
        }

        _height   = Random.Range(6, 12);
        _width    = Random.Range(6, 12);
        _corridor = GetComponent <CorridorGenerator>();
        for (int i = 0; i < _width; i++)
        {
            for (int j = 0; j < _height; j++)
            {
                if (GridGenerator.objs[Mathf.FloorToInt(i + pos.x - _width / 2)][Mathf.FloorToInt(j + pos.y - _height / 2)] != null)
                {
                    GridGenerator.objs[Mathf.FloorToInt(i + pos.x - _width / 2)][Mathf.FloorToInt(j + pos.y - _height / 2)].GetComponent <RoomGenerator>().ToFloor();
                }
            }
        }

        _corridor.CreateCorridors(pos, _width, _height);
        GetComponent <InteriorGenerator>().Fill(pos, _height, _width);
    }
예제 #2
0
    IEnumerator CreateDungeon()
    {
        GameObject loading = (GameObject)Instantiate(loadingScreen);

        yield return(StartCoroutine(rooms.CreateRooms()));

        yield return(StartCoroutine(corridors.CreateCorridors()));

        yield return(StartCoroutine(walls.CreateRoomWalls()));

        yield return(StartCoroutine(walls.CreateCorridorWalls()));

        yield return(StartCoroutine(playerAndMerchantsGenerator.CreatePlayer()));

        yield return(StartCoroutine(playerAndMerchantsGenerator.CreateTraders()));

        yield return(StartCoroutine(chests.CreateChest()));

        Pathfinder.Instance.CreateMap();

        SpawnPortal();
        CreateScroll();
        SpawnSafeZoneCampfire();
        yield return(StartCoroutine(enemiesGenerator.CreateEnemies()));

        Destroy(loading);
    }