Example #1
0
    public IEnumerator Intro()
    {
        // reset stats
        roundCount = 0;
        waveCount  = 0;

        // select start room
        Room startRoom = _rooms.ShowSingleRoom();

        _narrator.Intro();

        yield return(new WaitForSeconds(0.3f));

        // spawn player
        Vector3         spawnPos  = SpawnPosFromRoom(startRoom);
        PlayerCharacter character = GameObjectFactory.Instantiate <PlayerCharacter>(heroPrefab, position: spawnPos);

        character.transform.parent = transform;
        character.Spawn(startRoom);
        _playerCharacters.Add(character);
        AttachToPlayerCharacter(character);

        // spawn neighbour rooms
        List <Room> roomsToSpawn = startRoom.neighbours.Clone();

        while (roomsToSpawn.Count > 0)
        {
            yield return(new WaitForSeconds(0.3f));

            Room newRoom = roomsToSpawn.PopRandom();
            newRoom.Show();
        }

        yield return(new WaitForSeconds(10f));

        _narrator.AddMessage("Let the battle begin.");

        SpawnEnemies();
    }