void Die() { OnEnemyDeath?.Invoke(this, new OnEnemyDeathEventArgs { enemyMovement = gameObject.GetComponent <EnemyMovement>() }); Destroy(gameObject); }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("StompBox")) { OnEnemyDeath?.Invoke(); } }
/// <summary> /// Called on death of one of passengers /// </summary> void PassengerDied(EnemyData passengerData, Transform enemyPosition, GameObject initiator) { // check for incorrect states; // must be 'Active' or 'DeadDriver' if (State == EnemyVehicleState.DeadPassengers || (State == EnemyVehicleState.DeadDriver && passengerData.IsDriver) || State == EnemyVehicleState.Nothing) { Debug.Log("Called from wrong state", this); return; } // decrement alivePassengersAmount--; // call event OnEnemyDeath?.Invoke(passengerData, enemyPosition, initiator); // if there are passengers, but driver died if (passengerData.IsDriver) { State = EnemyVehicleState.DeadDriver; DoDriverDeath(); } // if there are no alive passengers if (alivePassengersAmount <= 0) { alivePassengersAmount = 0; State = EnemyVehicleState.DeadPassengers; DoPassengerDeath(); } }
public void KillEnemy() { Destroy(gameObject); OnEnemyDeath?.Invoke(this, new OnEnemyDeathEventArgs { enemy = enemy }); }
public void ReachedGoal() { OnEnemyDeath?.Invoke(this, new OnEnemyDeathEventArgs { enemyMovement = gameObject.GetComponent <EnemyMovement>() }); OnEnemyScored?.Invoke(this, EventArgs.Empty); Destroy(gameObject); }
void StartDeath() { gameObject.GetComponent <DramaticDeath>().StartDeath(); //CameraShaker.Instance.ShakeOnce(1, 1, 1, 1); OnEnemyDeath?.Invoke(10); UnSubscribe(); }
/* * Destroyes the game object after a few seconds and notifies the * subscribers of the `onEnemyDeath` event */ private IEnumerator DestroyAfter(float seconds) { yield return(new WaitForSeconds(seconds)); Destroy(gameObject); OnEnemyDeath?.Invoke(gameObject); }
public override void Death() { isDead = true; capsuleCollider.isTrigger = true; anim.SetTrigger("Dead"); enemyAudio.clip = deathClip; enemyAudio.Play(); OnEnemyDeath?.Invoke(); }
protected void EnemyTakeDamage() { base.TakeDamage(); if (health <= 0 && !enemyDeathInvoked) { OnEnemyDeath?.Invoke(transform.position); OnEnemyDeathPoints?.Invoke(); enemyDeathInvoked = true; } }
private void CheckIfEnemyIsDead() { if (rb.position.y < 0.5f) { targetTransforms.Clear(); targetDistances.Clear(); OnEnemyDeath?.Invoke(); isAlive = false; } }
public void TakeDamage() { hitTarget -= 1; animator.SetTrigger("TookDamage"); if (hitTarget <= 0) { PlayHitSound(); OnEnemyDeath?.Invoke(); animator.SetBool("IsDying", true); } }
public virtual void Die(bool scorePoints = false) { ObjectPool.Instance.ReturnObject(this.gameObject); // Increase combo by 1 if (scorePoints) { OnEnemyDeath?.Invoke(1); OnEnemyDeathScore?.Invoke(scoreValue); AudioManager.PlaySFX(deathSound, true); } }
protected override void HandleDeath(GameObject attacker) { var dungeon = Dungeon.Singleton; var loot = transform.GetChild(0); loot.transform.SetParent(dungeon.GetRoomObject(dungeon.CurrentRoom.RoomID).transform); loot.GetComponent <Loot>().Drop(attacker, transform.position); attacker.GetComponent <BlackBoard>().RemoveTypePOI(GetType(), gameObject); OnEnemyDeath.Invoke(); base.HandleDeath(attacker); }
// When an enemy died public void EnemyDeath(AbstractEnemy enemy) { OnEnemyDeath?.Invoke(enemy); EnemyKillCount++; LevelsScript.Instance.CurrentQuestion.killedEnemies++; if (EnemyKillCount >= EnemiesInGame) { LevelsScript.Instance.EndQuestion(); //InvokeOnLevelCompleted(); } Debug.Log($"we killed {enemy.Name}, we have now slain {EnemyKillCount} enemies"); Destroy(enemy.gameObject); }
public void UpdateHealth(int changeInHealth) { _currentHealth = ChangeHealth(changeInHealth); if (_currentHealth <= 0) { OnEnemyDeath?.Invoke(this); _animator.SetTrigger("Die"); _enemy.enabled = false; Destroy(gameObject, 5); } else { StartCoroutine(DamageCooldown()); } }
public void KillEntity(IDamageable entity) { if (entity is Enemy) { OnEnemyDeath?.Invoke((Enemy)entity); } else if (entity is Player) { Debug.Log("Player died"); OnPlayerDeath?.Invoke((Player)entity); } RemoveEntity(entity); entity.OnDeath(); //print($"Enemies remaining: {DamageableEntities.Count}"); }
public void ModifyHealth(int value) { Health = Health + value; if (Health <= 0) { OnEnemyDeath?.Invoke(this, null); } if (Health > maxHealth) { maxHealth = Health; } var damageText = Instantiate(DamageText, gameObject.transform.position, Quaternion.identity); var floatingNumber = damageText.GetComponent <FloatingNumber>(); floatingNumber.UIText.text = Math.Abs(value).ToString(); healthFill.sizeDelta = new Vector2(Math.Min((float)Health / maxHealth, 1f), healthFill.sizeDelta.y); }
////////////// public override void TakeDamage(int damage) { int calculatedDamage = damage; // // NOTE: сначала обработка входящего дамага, потом базовое применение // if (calculatedDamage > 0) { Health -= calculatedDamage; } if (Health < 0) { Health = 0; } m_EnemyHealthText.text = Health.ToString(); // после применения урона проверяем, не погиб ли персонаж if (Health <= 0) { Debug.Log(m_EnemyData.Name + " is dead"); if (m_AbilityCastingProcess != null) { StopCoroutine(m_AbilityCastingProcess); m_AbilityCastingProcess = null; } // дропаем предмет игроку MaterialData droppedItem = m_EnemyData.TryDropItem(); if (droppedItem != null) { InventoryContent.Instance.AddMaterial(droppedItem); Debug.Log("Dropped item " + droppedItem.Name); } OnEnemyDeath?.Invoke(); Destroy(gameObject); } }
/// <summary> /// This method destroys the enemy gameobject this script is attached to. Called when the corresponding stats Script calls OnDeath. /// </summary> protected virtual void Die() { agent.isStopped = true; dead = true; GetComponent <Collider>().enabled = false; if (anim != default(Animator)) { anim.SetBool("Dead", true); } stats.OnDeath -= Die; OnEnemyDeath?.Invoke(this); //Tell further listners that it was an enemy that died. if (Random.Range(0, 100) <= dropChance && AmmoCrate != null) { Instantiate(AmmoCrate, new Vector3(transform.position.x, 2, transform.position.z), transform.rotation); } Destroy(gameObject, deathAnimationLength + 0.1f); }
public void TakeDamage(float damage) { CurrentHealth = (CurrentHealth - damage > 0) ? CurrentHealth - damage : 0; OnDamageTaken?.Invoke(damage); _damageHighlight.HighLight(); if (CurrentHealth <= 0) { OnEnemyDeath?.Invoke(this); Destroy(gameObject); GameObject deathParticles = Instantiate(_deathParticles, transform.position + new Vector3(0, 0.5f, 0), Quaternion.identity); deathParticles.GetComponent <DestroyAfterTime>().StartTimer(0.5f); } }
//responsible for the movemnt of the enemy and makes it move towarads the current pathpoint and if it gets close enough changes target to the next. It also checks if the enemy has reached the last pathpoint and in that case invokes the OnEnemyDeath event. protected override void Movment() { if (i == 0) { currentPath = pathPoints[0]; i++; } else { if (Distance(new Vector2(this.X, this.Y)) < distanceToChange) { if (currentPath == pathPoints[pathPoints.Length - 1] && !WaveController.DeadEnemies.Contains(this)) { OnEnemyDeath.Invoke(); } else if (!WaveController.DeadEnemies.Contains(this)) { currentPath = pathPoints[i]; i++; } } } if (!WaveController.DeadEnemies.Contains(this)) { if (this.X > currentPath.X) { this.X -= movementSpeed; } else if (this.X < currentPath.X) { this.X += movementSpeed; } else if (this.Y > currentPath.Y) { this.Y -= movementSpeed; } else if (this.Y < currentPath.Y) { this.Y += movementSpeed; } } }
/// <summary> /// Actually destroys the object. Should only be called by an animation event. /// Also gives xp to the ally who killed this enemy /// </summary> protected override void Ascend() { // Give xp to the killer EnemyStats myStats = this.GetComponent <EnemyStats>(); _myKiller.GainExperience(myStats.KillReward()); //Give reduced xp to other allies foreach (AllyStats _helper in _helpers) { _helper.GainReducedExperience(myStats.SharedKillReward(_helper)); // Debug.Log(_helper); } // Call the enemy death event OnEnemyDeath?.Invoke(); // Call the base's version // (make sure to do this last, since the object is destroyed by this call) base.Ascend(); }
public void EnemyDied() { OnEnemyDeath?.Invoke(); }
public static void EnemyDied(int i) { OnEnemyDeath?.Invoke(i); }
public static void EnemyDiedShake() { OnEnemyDeath?.Invoke(); }
public void OnEnemyDeathInvoke() { OnEnemyDeath?.Invoke(); }
public static void EnemyDied(Enemy enemy) { OnEnemyDeath?.Invoke(enemy); }
private void OnDestroy() { OnEnemyDeath?.Invoke(); }