Example #1
0
    private void Start()
    {
        actualSession = FindObjectOfType <NightSession>();

        this.UpdateAsObservable()
        .Subscribe(_ =>
        {
            avaiableWaves = FilterWaves();
        });

        this.UpdateAsObservable()
        .Where(_ => avaiableWaves.Count > 0)
        .ThrottleFirst(TimeSpan.FromSeconds(cooldown))
        .Delay(TimeSpan.FromSeconds(cooldown))
        .Subscribe(_ =>
        {
            if (SceneManager.GetActiveScene().name == "MainGame")
            {
                //Get random avaiable Wave to get the enemies from it
                int selectedWave     = UnityEngine.Random.Range(0, avaiableWaves.Count);
                List <Enemy> enemies = avaiableWaves[selectedWave].getEnemies();

                //Update Game Session
                actualSession.AddEnemiesAlive(enemies.Count);
                actualSession.AddActualDifficulty(Waves[selectedWave].getDifficulty() * -1);

                //Spawn enemies
                SpawnEnemies(enemies);
            }
        });
    }
Example #2
0
 void Die()
 {
     nightSession.AddEnemiesAlive(-1);
     Destroy(gameObject);
 }