Ejemplo n.º 1
0
    public void ApplyDamage(float dmg, int dmgType)
    {
        HPAttribute.ApplyDamage(dmg);

        if (subClass == _UnitSubClass.Creep && !dead)
        {
            unitC.PlayHit();
        }

        if (HPAttribute.HP <= 0 && !dead)
        {
            HPAttribute.HP = 0;
            dead           = true;

            if (subClass == _UnitSubClass.Creep)
            {
                unitC.Dead();
                if (onDeadE != null)
                {
                    onDeadE(unitC.waveID);
                }
            }
            else if (subClass == _UnitSubClass.Tower)
            {
                unitT.Dead();
            }
            else
            {
                ObjectPoolManager.Unspawn(thisObj);
            }
        }
    }
Ejemplo n.º 2
0
    public void ApplyDamage(float dmg, int dmgType)
    {
        if (immunity)
        {
            return;
        }

        float globalModifier = 1;

        if (subClass == _UnitSubClass.Tower)
        {
            globalModifier = GlobalStatsModifier.CreepToTowerDmg;
        }
        else if (subClass == _UnitSubClass.Creep)
        {
            globalModifier = GlobalStatsModifier.TowerToCreepDmg;
        }

        dmg = CalculateDamage(dmg, dmgType) * globalModifier;

        HPAttribute.ApplyDamage(dmg);

        //Debug.Log(dmg +"  "+HPAttribute.HP);

        if (tieToPlayerLife)
        {
            if (onLifeUnitAttackedE != null)
            {
                onLifeUnitAttackedE(this);
            }
        }

        if (subClass == _UnitSubClass.Tower)
        {
            //Debug.Log(CalculateDamage(dmg, dmgType)+"   "+HPAttribute.HP);
        }

        if (subClass == _UnitSubClass.Creep && !dead)
        {
            unitC.PlayHit();
        }

        if (HPAttribute.HP <= 0 && !dead)
        {
            HPAttribute.HP = 0;
            dead           = true;

            if (subClass == _UnitSubClass.Creep)
            {
                unitC.Dead();
                if (onDeadE != null)
                {
                    onDeadE(unitC.waveID);
                }
            }
            else if (subClass == _UnitSubClass.Tower)
            {
                unitT.Dead();
            }
            else
            {
                ObjectPoolManager.Unspawn(thisObj);
            }
        }

        //UpdateOverlay();
        //HPAttribute.UpdateOverlayRenderer();
    }