Exemplo n.º 1
0
    public static void Effect(GameObject target, SpellData _spell = null, int _strength = -1)
    {
        SpellData spell    = _spell == null ? currentSpell : _spell;
        int       strength = _strength == -1 ? _currentStrength : _strength;

        switch (spell.action)
        {
        case SpellData.ActionType.Grow:
            Plant plant = target.GetComponent <Plant> ();
            if (plant != null)
            {
                plant.AccelerateGrow(.01f * spell.attributeLevel * (spell.strengthenEffect ? _currentStrength : 1));
            }
            break;

        case SpellData.ActionType.Hurt:
            IDamagable damagable = target.GetComponent <IDamagable> ();
            damagable.hit(spell.attributeLevel + spell.attributeLevel * (spell.strengthenEffect ? _currentStrength / 10 : 0), spell.attribute);
            break;

        case SpellData.ActionType.Heal:
            IDamagable toHeal = target.GetComponent <IDamagable> ();
            toHeal.heal(spell.attributeLevel + spell.attributeLevel * (spell.strengthenEffect ? _currentStrength / 10 : 0));
            break;

        default:
            break;
        }
    }