StatusEffect.ApplyEffect C# (CSharp) Method

ApplyEffect() public method

public ApplyEffect ( Combatant, user, Combatant, target ) : bool
user Combatant,
target Combatant,
return bool
    public bool ApplyEffect(Combatant user, Combatant target)
    {
        bool applied = false;
        if(target.CanApplyEffect(this.realID) &&
                (!this.hitChance ||
                DataHolder.GameSettings().GetRandom() <= DataHolder.Formulas().formula[this.hitFormula].Calculate(user, target)))
        {
            for(int i=0; i<this.condition.Length; i++)
            {
                if(this.condition[i].apply && !this.condition[i].stopChange)
                {
                    this.condition[i].InitChange(i, target);
                    if(this.condition[i].OnCast())
                    {
                        this.condition[i].SetChange(i, target);
                    }
                }
            }

            if(StatusEffectEnd.TIME.Equals(this.end)) this.endAfter = this.endValue*1000;
            else this.endAfter = this.endValue;
            this.combatant = target;
            applied = true;
            this.initialized = true;
        }
        return applied;
    }

Usage Example

Exemplo n.º 1
0
    public void ApplyEffect()
    {
        if (effect == null)
        {
            statusIcon.HideIcon();
            Debug.LogError("effect is not defined");
            return;
        }

        effect.ApplyEffect();
        duration--;

        if (statusIcon == null)
        {
            Debug.LogError("No icon setup for " + effect.name);
            //SetIcon(CBT.EnableIconDynamically(effect));
            return;
        }
        statusIcon.SetInfo(this);

        //redundant?
        if (IsFinished())
        {
            statusIcon.HideIcon();
            return;
        }
    }
All Usage Examples Of StatusEffect::ApplyEffect