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; } }
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(); } } }
protected virtual void OnEnemyExploded(EnemyDeathEventArgs enemyDeath) { if (EnemyExploded != null) { EnemyExploded(this, enemyDeath); } }
protected virtual void OnDied(EnemyDeathEventArgs edeargs) { if (!this.Dead) { this.Dead = true; EnemyDied?.Invoke(this, edeargs); } }
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"); } }
void gamechar_OnDeath(Object sender,EnemyDeathEventArgs e) { //reset the music. if (!String.IsNullOrEmpty(_AbilityMusic)) //BCBlockGameState.Soundman.PopMusic(_AbilityMusic); BCBlockGameState.Soundman.StopTemporaryMusic(_AbilityMusic); }
public void Musicreverter(Object sender,EnemyDeathEventArgs e) { if (!String.IsNullOrEmpty(ChangeMusicTo)) //BCBlockGameState.Soundman.PopMusic(ChangeMusicTo); BCBlockGameState.Soundman.StopTemporaryMusic(ChangeMusicTo); }
public void OnEnemyExploded(object source, EnemyDeathEventArgs enemyDeath) { ToSpawnCoin(); }