예제 #1
0
    public void OnEnemyExploded(object source, EnemyDeathEventArgs enemyDeath)
    {
        switch (enemyDeath.enemyType)
        {
        case "Basic":
            basicSpawner.OnEnemyDeath();
            break;

        case "Sprinter":
            sprinterSpawner.OnEnemyDeath();
            break;

        case "Dodger":
            dodgerSpawner.OnEnemyDeath();
            break;

        case "Jumper":
            jumperSpawner.OnEnemyDeath();
            break;

        case "Tank":
            tankSpawner.OnEnemyDeath();
            break;

        default:
            break;
        }
    }
예제 #2
0
    private void HandleEnemyDeath(object sender, EnemyDeathEventArgs e)
    {
        var enemy = enemiesInWave[e.EnemyId];

        enemy.EnemyDeath -= HandleEnemyDeath;

        enemiesInWave.Remove(e.EnemyId);
        enemyInRoundCount--;

        if (enemyInRoundCount == 0)
        {
            Debug.Log("Round End");
            currentRound++;
            if (currentRound < WaveRounds.Count)
            {
                StartEnemies(WaveRounds[currentRound]);
                enemyIdCounter = 0;
                enemiesInWave.Clear();
            }
            else
            {
                StartGame.StartTheGame();
            }
        }
    }
예제 #3
0
 protected virtual void OnEnemyExploded(EnemyDeathEventArgs enemyDeath)
 {
     if (EnemyExploded != null)
     {
         EnemyExploded(this, enemyDeath);
     }
 }
예제 #4
0
 protected virtual void OnDied(EnemyDeathEventArgs edeargs)
 {
     if (!this.Dead)
     {
         this.Dead = true;
         EnemyDied?.Invoke(this, edeargs);
     }
 }
예제 #5
0
 public void TakeExplosion(float power, Vector3 explosionPoint, float radius, float upwardForce, float directHitDamage)
 {
     /*
      * Vector3 endPos = Vector3.zero;
      * switch(enemyType){
      *  case "Basic":
      *      endPos = transform.position + Vector3.up*1.15f; break;
      *  case "Sprinter":
      *      endPos = transform.position + Vector3.up*2f; break;
      *  case "Jumper":
      *      endPos = transform.position + Vector3.up*2f; break;
      *  case "Dodger":
      *      endPos = transform.position + Vector3.up*2.3f; break;
      *  case "Tank":
      *      endPos = transform.position + Vector3.up*3.2f; break;
      *  default:
      *      break;
      * }
      * float hitDamage = Mathf.Max(0f, directHitDamage * ( 1f - ((explosionPoint - endPos).magnitude)/radius ));*/
     if (health - directHitDamage > 0f)
     {
         TakeHit(directHitDamage, transform.position);
     }
     else
     {
         health -= directHitDamage;
     }
     if (health <= 0)
     {
         if (anim != null)
         {
             anim.enabled = false;
         }
         healthBar.enabled = false;
         FindObjectOfType <CoinSpawner>().deathPos = transform.position; //spawn coin
         EnemyDeathEventArgs ed = new EnemyDeathEventArgs(enemyType);    //explosion event
         OnEnemyExploded(ed);                                            //call the event
         exploded = true;
         dead     = true;
         Rigidbody rb = gameObject.AddComponent <Rigidbody>() as Rigidbody;
         rb.AddExplosionForce(power, explosionPoint, radius, upwardForce);
         StartCoroutine("DieOfExplosion");
     }
 }
예제 #6
0
 void gamechar_OnDeath(Object sender,EnemyDeathEventArgs e)
 {
     //reset the music.
     if (!String.IsNullOrEmpty(_AbilityMusic))
         //BCBlockGameState.Soundman.PopMusic(_AbilityMusic);
         BCBlockGameState.Soundman.StopTemporaryMusic(_AbilityMusic);
 }
예제 #7
0
 public void Musicreverter(Object sender,EnemyDeathEventArgs e)
 {
     if (!String.IsNullOrEmpty(ChangeMusicTo))
         //BCBlockGameState.Soundman.PopMusic(ChangeMusicTo);
         BCBlockGameState.Soundman.StopTemporaryMusic(ChangeMusicTo);
 }
예제 #8
0
 public void OnEnemyExploded(object source, EnemyDeathEventArgs enemyDeath)
 {
     ToSpawnCoin();
 }