Пример #1
0
    //Call this when you add another effect
    public void ApplyEffect(CharacterValues caster, EffectValues effect, CharacterValues target)
    {
        bool         inUse = false; //Tarvittiin sittenkin plaah
        EffectValues clone = Object.Instantiate(effect) as EffectValues;

        clone.caster         = caster;
        clone.target         = target;
        clone.remainingTurns = clone.effectDuration;
        //Debug.Log("Applying effect " + effect.effectName);

        foreach (EffectValues eff in effectList)
        {
            if (eff.target == clone.target)
            {
                if (eff.effectName == clone.effectName)
                {
                    inUse = true;
                    if (clone.stacks == false)
                    {
                        eff.remainingTurns = clone.effectDuration;      //New spells are always better!
                    }
                    else
                    {
                        effectList.Add(clone);
                        pBehaviour.AddTabEffect(clone, target);
                    }
                }
                else
                {
                    effectList.Add(clone);
                    pBehaviour.AddTabEffect(clone, target);
                }
            }
        }
        if (!inUse)
        {
            effectList.Add(clone);
            pBehaviour.AddTabEffect(clone, target);
        }
        CalculateEffects(target);
    }