Esempio n. 1
0
 void Awake()
 {
     spike       = GetComponentInChildren <Spike>();
     spikeRb     = spike.GetComponent <Rigidbody>();
     spikeTarget = spike.transform.parent;
     spike.transform.localPosition = spikeRb.centerOfMass;
 }
Esempio n. 2
0
    public void WaveSpawner()
    {
        // Spawn a drop
        CurrentDropTime += Time.deltaTime;
        if (CurrentDropTime > DropTime && Wave.DropsSpawnAmount != Wave.DropsAmount)
        {
            EnemyManager.AddObserver(Drop.GetComponent <JuiceDrop>());
            CurrentDropTime = 0f;
            DropTime        = RandomHelper.NextRandom(3, 5);
        }

        // Spawn a spike
        CurrentSpikeTime += Time.deltaTime;
        if (CurrentSpikeTime > SpikeTime && Wave.SpikesSpawnAmount != Wave.SpikesAmount)
        {
            EnemyManager.AddObserver(Spike.GetComponent <Spike>());
            CurrentSpikeTime = 0;
            SpikeTime        = RandomHelper.NextRandom(3, 5);
        }

        // Spawn a fire
        CurrentFireTime += Time.deltaTime;
        if (CurrentFireTime > FireTime && Wave.FiresSpawnAmount != Wave.FireAmount)
        {
            EnemyManager.AddObserver(Fire.GetComponent <Fire>());
            CurrentFireTime = 0f;
            FireTime        = RandomHelper.NextRandom(3, 5);
        }

        // Spawn the boss
        if (Wave.DropsSpawnAmount == Wave.DropsAmount && Wave.SpikesSpawnAmount == Wave.SpikesAmount && Wave.FiresSpawnAmount == Wave.FireAmount && Wave.WaveLevel == Wave.FinalWaveLevel)
        {
            LevelState = LevelState.Boss;
            // Or Spawn another wave
        }
        else if (Wave.DropsSpawnAmount == Wave.DropsAmount && Wave.SpikesSpawnAmount == Wave.SpikesAmount && Wave.FiresSpawnAmount == Wave.FireAmount)
        {
            GameObject.FindWithTag("GameController").GetComponent <GameController>().Restart();
        }

        // Notify all enemies
        //EnemyManager.Notify(Player);
    }