public void LoseHealth(int lossAmount) { currentHealth -= lossAmount; currentHealth = Mathf.Clamp(currentHealth, 0, maxHealth); if (currentHealth <= 0) { OnEntityDeath?.Invoke(); } else { OnHealthLoss?.Invoke(); } }
void SpawnEnemy(string name, Vector3Int Position, Quaternion Rotation) { try { if (FindEntityInPosition(Position) != null) { return; } var dt = GetEntityDataFromName(name); var mob = Instantiate(dt.Prefab); mob.Initialize(Position, Rotation, dt); EntitiesInScene.Add(mob); OnNewEntitySpawn?.Invoke(mob); var d = mob.GetComponent <EntityDeath>(); if (d != null) { d.OnEntityDeath += (e) => { EntitiesInScene.Remove(e); OnEntityDeath?.Invoke(e); } } ; } catch (ArgumentOutOfRangeException e) { } }
void Death() { OnEntityDeath?.Invoke(GetComponent <Entity>()); GetComponent <Entity>().IsActive = false; GetComponent <EntityAnimator>().InvokeAnimation("Death", true); }
public static void EntityDeath(Entity ent) { //DebugManager.LogToFile("[OnEntityDeath] " + ent.name + " has died"); OnEntityDeath?.Invoke(ent); }