private void Start()
    {
        OnWaveEnded?.Invoke(1);
        ChangeMoney(0);

        StartCoroutine(StartNewWave(timeBetweenSpawns));
    }
    public void InitializeLevel()
    {
        enemiesAlive       = 0;
        WaveStrength_Index = 0;

        OnWaveEnded?.Invoke();
    }
    private IEnumerator AsteroidWaveControllerCoroutine()
    {
        var spawner = FindObjectOfType <AsteroidSpawner>();

        while (true)
        {
            if (OnWaveStarted != null)
            {
                OnWaveStarted.Invoke(CurrentWaveNumber);
            }

            spawner.AsteroidTypeLevel = CurrentWaveNumber;
            spawner.Spawning          = true;

            yield return(new WaitForSeconds(WaveDuration));

            spawner.Spawning = false;

            yield return(new WaitForSeconds(CooldownDuration));

            if (OnWaveEnded != null)
            {
                OnWaveEnded.Invoke(CurrentWaveNumber);
            }

            yield return(new WaitForSeconds(BreakDuration));

            CurrentWaveNumber += 1;
        }
    }
예제 #4
0
        void HandleWaveEnded()
        {
            goldCount += CreepManager.CurrentWave.GoldBonus;

            if (OnWaveEnded != null)
            {
                OnWaveEnded.Invoke();
            }
        }
    private void HandleEnemyDeath(GameObject sender)
    {
        enemiesAlive--;

        if (enemiesAlive == 0)
        {
            OnWaveEnded?.Invoke();
            WaveStrength_Index++;
        }
    }
 private void CheckWave()
 {
     currentEnemyCount--;
     if (currentEnemyCount == 0)
     {
         Debug.Log("wave over");
         OnWaveEnded?.Invoke(Wave);
         StartCoroutine(StartNewWave(timeBetweenSpawns));
     }
 }
예제 #7
0
    public static void KillCitizen(bool hasFinished)
    {
        if (!IsAlive)
        {
            return;
        }

        instance.activeCitizenCount--;

        if (hasFinished)
        {
            instance.hitpointCount--;

            if (OnCitizenFinished != null)
            {
                OnCitizenFinished.Invoke();
            }

            if (instance.hitpointCount == 0)
            {
                instance.isPlaying = false;

                if (OnGameOver != null)
                {
                    OnGameOver.Invoke();
                }

                return;
            }
        }

        if (instance.activeCitizenCount == 0)
        {
            instance.isPlaying = false;

            instance.treeBatches[instance.currentWaveIndex - 1].FadeOut();

            instance.houseBatches[instance.currentWaveIndex - 1].SetActive(true);

            instance.pavements[instance.currentWaveIndex - 1].SetActive(true);

            if (OnWaveEnded != null)
            {
                OnWaveEnded.Invoke();
            }

            if (!HasWavesLeft)
            {
                if (OnGameOver != null)
                {
                    OnGameOver.Invoke();
                }
            }
        }
    }
예제 #8
0
 private IEnumerator SpawnEnemies()
 {
     for (int i = 0; i < NumberOfEnemiesToSpawn; i++)
     {
         var rocket = UnityEngine.Object.Instantiate(enemyPrafab);  // Create Enemy
         rocket.SetActive(false);                                   // Disable enemy to set first
         RocketReferences.Add(rocket);                              // Set enemy's path and speed
         SetRocket(rocket);
         rocket.SetActive(true);                                    // Enable enemy to start moving
         yield return(new WaitForSeconds(SpawnTimeBetweenEnemies)); // Wait a little before spawn the next enemy
     }
     if (OnWaveEnded != null)
     {
         OnWaveEnded.Invoke();
     }
 }
예제 #9
0
        public static void DespawnCreep(Creep creep)
        {
            creep.gameObject.SetActive(false);

            instance.livingCreepCount--;

            if (OnCreepDespawned != null)
            {
                OnCreepDespawned.Invoke(creep);
            }

            if (instance.livingCreepCount > 0)
            {
                return;
            }

            if (OnWaveEnded != null)
            {
                OnWaveEnded.Invoke();
            }
        }
예제 #10
0
    private IEnumerator AsteroidWaveControllerCoroutine()
    {
        var spawner = FindObjectOfType <AsteroidSpawner>();

        //  var spawningTime = FindObjectOfType<AsteroidSpawner>().AsteroidSpawningTime;



        while (true)
        {
            if (OnWaveStarted != null)
            {
                OnWaveStarted.Invoke(CurrentWaveNumber);
            }

            spawner.AsteroidTypeLevel = CurrentWaveNumber - 1;



            spawner.Spawning = true;                        //włączamy tworzenie asteroidów tzn 'Wave"

            yield return(new WaitForSeconds(WaveDuration)); //czas trwania Wave

            spawner.Spawning = false;                       //koniec fali

            yield return(new WaitForSeconds(CooldownDuration));

            if (OnWaveEnded != null)
            {
                OnWaveEnded.Invoke(CurrentWaveNumber);
            }
            yield return(new WaitForSeconds(BreakDuration)); // czas trwania przerwy

            CurrentWaveNumber++;
            //spawningTime = spawningTime + 3f;
        }
    }
예제 #11
0
 public void WaveEnded() => OnWaveEnded?.Invoke();