void OnEnemyDeath(Unit unit) { var enemy = unit as Enemy; EnemyKilled?.Invoke(enemy); RemoveEnemy(enemy); }
public void Die() { PlayDeathSound(); switch (enemy.enemyData.enemyType) { case "Imp": EnemyKilled?.Invoke(enemy.Element, 1); break; case "Gargoyle": EnemyKilled?.Invoke(enemy.Element, 3); break; case "Berserker": EnemyKilled?.Invoke(enemy.Element, 5); break; case "Ethereal": EnemyKilled?.Invoke(enemy.Element, 10); EtherealKilled?.Invoke(enemy.Element); break; } Destroy(gameObject); }
private void DestroyEnemy(GameObject enemy) { DestroyImmediate(enemy); if (EnemyKilled != null) { EnemyKilled.Invoke(); } }
private void onEnemyKilled(ICollidable i_Collidable) { if (EnemyKilled != null) { EnemyHitEventArgs enemyHitEventArgs = new EnemyHitEventArgs(i_Collidable); EnemyKilled.Invoke(this, enemyHitEventArgs); } }
public void Kill(float waitTime) { // We don't care about other animations, so kill them if (animationCR != null) { StopCoroutine(animationCR); } Activate(false); animationCR = StartCoroutine(AnimatorWaiter(waitTime, "die", true)); animator.SetBool("dead", true); enemyKilledEvent.Invoke(this); }
/// <summary> /// Deals damage to the enemy. If the health reaches 0, the enemy invoke the killed event and disable itself. /// </summary> /// <returns>The remaining health of the enemy.</returns> public float DealDamage(float damage) { m_Health -= damage; if (m_Health < 0) { EnemyKilled?.Invoke(false, 0); gameObject.SetActive(false); return(0); } return(m_Health); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.TryGetComponent(out EnemyMover enemyMover)) { enemyMover.gameObject.SetActive(false); EnemyKilled?.Invoke(); } if (collision.TryGetComponent(out Booster booster)) { _playerMover.StartBoosting(booster.BonusSpeed, booster.Duration); booster.gameObject.SetActive(false); } }
private void PlayerAttack(int index) { enemyHealthBars[index].Progress -= (int)(AccountManager.CurrentUser.Attack / (float)enemy.Health * 100); Animation?.Invoke(EAnimationTarget.Player, index); if (enemyHealthBars[index].Progress <= 0) { KillEnemy(index); EnemyKilled?.Invoke(index); } if (EnemiesAreDead) { BattleEnd?.Invoke(BattleCore.EBattleEndType.Won); } }
/// <summary> /// Once there is no more tiles to travel to in the path the enemy invoke the killed event and disable itself. /// </summary> private void ReachEnd() { int damageToDealEnemy = 0; switch (m_Type) { case UnitType.Standard: damageToDealEnemy = m_StandardUnitDamage; break; case UnitType.Big: damageToDealEnemy = m_LargeUnitDamage; break; } if (EnemyKilled != null) { EnemyKilled.Invoke(false, damageToDealEnemy); } gameObject.SetActive(false); }
private void OnEnemyKilled() { EnemyKilled?.Invoke(); }
private void PublishEnemyKilledEvent() { EnemyKilledEvent?.Invoke(this); }
void OnEnemyKilled(Enemy enemy) { EnemyKilled?.Invoke(enemy); }
internal void PublishEnemyKilledEvent() { EnemyKilledEvent?.Invoke(this); }
private void OnCollisionEnter2D(Collision2D other) { EnemyKilled?.Invoke(10); Destroy(other.gameObject); Destroy(gameObject); }
public void Kill() { OnEnemyKilled.Invoke(this); }