Beispiel #1
0
    void OnHealthChanged()
    {
        Debug.Log(CurHealth);

        if (CurHealth <= 0)
        {
            if (ExplosionPrefab != null)
            {
                OrdnanceCommon.Explode(gameObject, gameObject, ExplosionPrefab);
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
Beispiel #2
0
    void DoDamage(GameObject victim)
    {
        Health healthComponent = victim.GetComponent <Health>();

        if (healthComponent != null)
        {
            healthComponent.AddHealth(-Damage);
        }

        if (ExplosionPrefab != null)
        {
            OrdnanceCommon.Explode(gameObject, owner, ExplosionPrefab);
        }
        else
        {
            Destroy(gameObject);
        }
    }