Exemplo n.º 1
0
    /// <summary>
    /// Generates the floor, this works between frames
    /// </summary>
    /// <returns></returns>
    private IEnumerator CoroutineGenerateFloor()
    {
        currentFloorParent = Instantiate(floorParentPrefab.gameObject).GetComponent <Floor>();

        currentFloorParent.floorNumber = PlayerProgress.currentFloor;

        if (OnBeginGeneration != null)
        {
            OnBeginGeneration(currentFloorParent, _rand);
        }

        yield return(GenerateRoomEntries(maxFloorRadius));

        // pick a room to be the entrance
        RoomEntry entrance = GetRandomRoomEntry();

        entrance.type               = RoomEntry.RoomType.ENTRANCE;
        entrance.gameObject.name    = "Entrance Room Entry";
        currentFloorParent.entrance = entrance;

        // pick a room to be the exit
        RoomEntry exit = GetRandomRoomEntry();

        exit.type               = RoomEntry.RoomType.EXIT;
        exit.gameObject.name    = "Exit Room Entry";
        currentFloorParent.exit = exit;

        // place exit stairs
        FloorExitTrigger fet = Instantiate(exitPrefab, exit.transform).GetComponent <FloorExitTrigger>();

        fet.TargetGenerator = this;
        yield return(CreateRoomPieces());

        currentFloorParent.GetComponent <NavMeshSurface>().BuildNavMesh();

        if (FloorTheme.IsCurrentlyCave())
        {
            SoundManager.instance.PlayMusic(3);
        }
        else if (FloorTheme.IsCurrentlyForest())
        {
            SoundManager.instance.PlayMusic(4);
        }
        else if (FloorTheme.IsCurrentlyFire())
        {
            SoundManager.instance.PlayMusic(5);
        }
        else
        {
            SoundManager.instance.PlayMusic(3);
        }

        // trigger event if anything is listening to it
        if (OnFloorGenerated != null)
        {
            OnFloorGenerated(currentFloorParent, _rand);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// EnemyGroups handles getting references to the an enemy.
    /// This function also handles spawning a group of enemies.
    /// Lots of code duplication unfortunately.
    /// </summary>
    /// <param name="floor">Current floor number.</param>
    /// <param name="roomPos">position of the room</param>
    /// <param name="rand">Random used to spawn randomly.</param>
    void EnemyGroups(int floor, Vector3 roomPos, System.Random rand)
    {
        int groupSize = rand.Next(minGroupSize, maxGroupSize);

        GameObject[] enemyPrefabs = null;

        // Select enemy prefab list based on floor level
        if (FloorTheme.IsCurrentlyCave())
        {
            enemyPrefabs = caveEnemyPrefabs; // Cave
        }
        else if (FloorTheme.IsCurrentlyForest())
        {
            enemyPrefabs = forestEnemyPrefabs; // Forest
        }
        else if (FloorTheme.IsCurrentlyFire())
        {
            enemyPrefabs = fireEnemyPrefabs; // Fire
        }

        // Spawn enemies
        for (int i = 0; i < groupSize; i++)
        {
            Vector3    enemyPos = RandomRoomPos(roomPos, rand);
            GameObject spawned  = Instantiate(enemyPrefabs[rand.Next(0, enemyPrefabs.Length)], enemyPos, Quaternion.identity);

            // Scale the enemy stats based on floor level
            if (floor > 1)
            {
                ScaleEnemy(spawned, floor);
            }
            enemies.Add(spawned);
        }

        if (EventManager.instance.spawnDebtCollectors)
        {
            for (int i = 0; i < groupSize; i++)
            {
                Vector3    enemyPos = RandomRoomPos(roomPos, rand);
                GameObject spawned  = Instantiate(debtCollector, enemyPos, Quaternion.identity);
                enemies.Add(spawned);
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Gets the current floor set based on the floor number
    /// </summary>
    /// <returns></returns>
    private FloorPieceSet GetCurrentSet()
    {
        FloorTheme.Type theme = FloorTheme.GetCurrentTheme();

        switch (theme)
        {
        case FloorTheme.Type.CAVE:
            return(pieceSets[0]);

        case FloorTheme.Type.FOREST:
            return(pieceSets[1]);

        case FloorTheme.Type.FIRE:
            return(pieceSets[2]);

        default:
            return(pieceSets[2]);
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Increments the floor number and generates a new floor
    /// </summary>
    public void NextFloor()
    {
        PlayerProgress.currentFloor++;

        if (PlayerProgress.currentFloor > PlayerProgress.floorReached)
        {
            PlayerProgress.floorReached = PlayerProgress.currentFloor;
        }

        if (FloorTheme.IsCurrentlySafeZone())
        {
            Debug.Log("Generating Safe at floor " + PlayerProgress.currentFloor);
            StartCoroutine(GenerateSafeZone());
        }
        else
        {
            Debug.Log("Generating normal at floor " + PlayerProgress.currentFloor);
            GenerateNewFloor(true);
        }
    }