private void Die(GameObject gameObj, GameObject killer) { UnitDeathEvent unitDeath = new UnitDeathEvent(); unitDeath.expDropped = 50; unitDeath.UnitDied = gameObj; unitDeath.UnitKiller = killer; unitDeath.FireEvent(); Destroy(gameObj); }
void Die() { // I am dying for some reason. UnitDeathEvent udei = new UnitDeathEvent(); udei.Description = "Unit " + this.Name + " has died."; udei.UnitNode = (Node2D)GetParent(); udei.FireEvent(); //Remove the parent node forn the scene udei.UnitNode.QueueFree(); }
public void Die(GameObject gameObj) { //Die if (gameObject != null) { UnitDeathEvent unitDeathEvent = new UnitDeathEvent(); unitDeathEvent.UnitDied = gameObj; unitDeathEvent.expDropped = 50; unitDeathEvent.FireEvent(); Destroy(gameObj); Debug.Log(gameObj.name + " died"); } }
public void TakeDamage(int damage) { health -= damage; if (health <= 0) { // Unit is dead, so need to tell anything that cares about it before the object is destroyed UnitDeathEvent deathEvent = new UnitDeathEvent(); deathEvent.UnitGO = gameObject; deathEvent.FireEvent(); GameObject.Destroy(gameObject); } }