/// <summary> /// Called if the enemy has died. /// </summary> public void Death() { EnemySpawnMgr.enemyNumberInField--; listOfEnemies.Remove(this); GoldMgr.Gold += Drop; onDeath.Invoke(this); Debug.Log("Dropped gold: " + Drop); }
private void Die() { EnemySpawnManager.enemyCount--; EnemyDeath?.Invoke(); //When an enemy dies half the timescale for 30 seconds GameManager.Instance.SlowGameForEnemyDeath(); Destroy(gameObject); }
public void OnEnemyDeath(int deathCount) { EnemyDeath?.Invoke(deathCount); }
public void OnEnemyDeath() { EnemyDeath?.Invoke(this); Destroy(gameObject); }
public void ApplyDamage(DamageMessage data) { if (currentHitPoints <= 0) {//ignore damage if already dead. TODO : may have to change that if we want to detect hit on death... return; } if (isInvulnerable) { OnHitWhileInvulnerable.Invoke(); return; } Vector3 forward = transform.forward; forward = Quaternion.AngleAxis(hitForwardRotation, transform.up) * forward; //we project the direction to damager to the plane formed by the direction of damage Vector3 positionToDamager = data.damageSource - transform.position; positionToDamager -= transform.up * Vector3.Dot(transform.up, positionToDamager); if (Vector3.Angle(forward, positionToDamager) > hitAngle * 0.5f) { return; } isInvulnerable = true; currentHitPoints -= data.amount; if (currentHitPoints <= 0) { schedule += OnDeath.Invoke; //This avoid race condition when objects kill each other. if (this.gameObject.layer == 9) //Player { if (data.damager.gameObject.name == "BodyDamager") { PlayerDeathEvent?.Invoke(ENEMY_TYPE.CHOMPER); } else if (data.damager.gameObject.name == "Spit(Clone)") { PlayerDeathEvent?.Invoke(ENEMY_TYPE.SPITTER); } } else if (this.gameObject.layer == 23) // Enemy { if (gameObject.name == "Chomper") { EnemyDeathEvent?.Invoke(gameObject, ENEMY_TYPE.CHOMPER); } else if (gameObject.name == "Spitter") { EnemyDeathEvent?.Invoke(gameObject, ENEMY_TYPE.SPITTER); } } } else { if (data.damager.gameObject.name == "BodyDamager") { PlayerHurtEvent?.Invoke(ENEMY_TYPE.CHOMPER); } else if (data.damager.gameObject.name == "Spit(Clone)") { PlayerHurtEvent?.Invoke(ENEMY_TYPE.SPITTER); } OnReceiveDamage.Invoke(); } var messageType = currentHitPoints <= 0 ? MessageType.DEAD : MessageType.DAMAGED; for (var i = 0; i < onDamageMessageReceivers.Count; ++i) { var receiver = onDamageMessageReceivers[i] as IMessageReceiver; receiver.OnReceiveMessage(messageType, this, data); } }
public void EnemyDeathEvent() { EnemyDeath?.Invoke(); }
// 击杀怪物 public void OnEnemyDeath(User user, Enemy enemy, string groupPath, CqGroupMessageEventArgs e) { EnemyDeath?.Invoke(user, enemy, groupPath, e); }