Exemplo n.º 1
0
    private IEnumerator CreateDungeon()
    {
        //Creating dungeon grid
        _grid.CreateGrid();
        yield return(new WaitForFixedUpdate());

        //Creating forest level
        _text.text = _forestGenerationTexts[Random.Range(0, _forestGenerationTexts.Count)];
        CreateForestLevel();
        yield return(new WaitUntil(() => _forestLevelGenerated));

        yield return(new WaitForSeconds(0.5f));

        //Creating temple level
        _text.text = _templeGenerationTexts[Random.Range(0, _templeGenerationTexts.Count)];
        CreateTempleLevel();
        yield return(new WaitUntil(() => _templeLevelGenerated));

        yield return(new WaitForSeconds(0.5f));

        //Creating graveyard level
        _text.text = _graveyardGenerationTexts[Random.Range(0, _graveyardGenerationTexts.Count)];
        _availablePlaces.Shuffle();
        Vector2Int cavernGeneration = RecoverCavernGenerationPoint();

        CreateGraveyardLevel(RecoverGraveyardGenerationPoint());
        yield return(new WaitUntil(() => _graveyardLevelGenerated));

        yield return(new WaitForSeconds(0.5f));

        //Creating cavern level
        _text.text = _cavernGenerationTexts[Random.Range(0, _cavernGenerationTexts.Count)];
        CreateCavernLevel(cavernGeneration);
        yield return(new WaitUntil(() => _caverLevelGenerated));

        yield return(new WaitForSeconds(0.5f));

        //Initializing level
        _text.text = _endGenerationTexts[Random.Range(0, _endGenerationTexts.Count)];
        foreach (Room current in _levelCreated)
        {
            current.InitializeRoom();
        }
        _grid.GenerateMiniMap();
        _grid.MoveMiniMap(_levelCreated[0]);
        yield return(new WaitForSeconds(0.5f));

        //Initializing player
        _generationUI.SetActive(false);
        SpawnPlayer();
    }