Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (health <= 0)
     {
         if (!destroyed)
         {
             destroyed = true;
             StartCoroutine(DestroyEnemy());
             if (!disableWaveEffects)
             {
                 spawnController.AddKill();
             }
             scoreTracker.addScore(scoreOnKill);
         }
     }
     if (this.gameObject.transform.position.y <= -1000)
     {
         this.spawnController.SpawnNewEnemy();
         Destroy(this.gameObject);
     }
 }
 private void Boom()
 {
     GameObject[] enemyList = GameObject.FindGameObjectsWithTag("Enemy");
     for (int i = 0; i < enemyList.Length; i++)
     {
         EnemyHealth health = enemyList[i].GetComponent <EnemyHealth>();
         Transform   e      = enemyList[i].transform;
         float       d      = Vector3.Distance(transform.position, e.position);
         if (d < range)
         {
             scoreTracker.addScore(100);
             Destroy(enemyList[i]);
             if (!health.disableWaveEffects)
             {
                 spawnController.AddKill();
             }
             attacked = true;
         }
     }
     if (attacked)
     {
         Destroy(gameObject);
     }
 }