private void Die(GameObject gameObj, GameObject killer)
    {
        UnitDeathEvent unitDeath = new UnitDeathEvent();

        unitDeath.expDropped = 50;
        unitDeath.UnitDied   = gameObj;
        unitDeath.UnitKiller = killer;
        unitDeath.FireEvent();

        Destroy(gameObj);
    }
Exemple #2
0
        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();
        }
Exemple #3
0
    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);
        }
    }