Esempio n. 1
0
        public void processEffect(Event ev)
        {
            Effect ef     = ev.data.getEffect(ev.source);
            Entity target = ev.target;

            // dead enities?
            if (ev.source.isDead || ev.target.isDead)
            {
                Log.E("Dead entities in event: " + ev);
                return;
            }

            //recompute
            if (ef.damageHeal == DamageHeal.DAMAGE && ef.type == DamageType.AD)
            {
                ef.amount -= target.stats.armor;
                ef.amount  = Math.Max(ef.amount, 1);
            }
            else if (ef.damageHeal == DamageHeal.DAMAGE && ef.type == DamageType.AP)
            {
                ef.amount -= target.stats.resist;
                ef.amount  = Math.Max(ef.amount, 1);
            }

            //apply
            double value = ef.amount * (ef.damageHeal == DamageHeal.DAMAGE ? -1 : 1);

            if (ef.target == Target.HP)
            {
                target.hp = U.Clamp(target.hp + value, 0, target.stats.maxhp);
            }
            if (ef.target == Target.MP)
            {
                target.mp = U.Clamp(target.mp + value, 0, target.stats.maxmp);
            }

            //is dead?
            if (target.hp == 0)
            {
                Log.B("Entity dies: " + target);
                target.isDead = true;
                target.game.EntityDies(target);
            }

            //add floater
            Log.D("Adding floating text for Effect: " + ef);
            target.getTexts().Add(FloatingText.FromEffect(ef));

            //reset time loader
            ev.source.TimeReset();
        }