示例#1
0
    public void UseAbility(int index, HashSet <GridCell> cells, GridCell target, bool crit)
    {
        AbilityInfo info = abilityInfo [index];

        foreach (GridCell c in cells)
        {
            if (crit)
            {
                foreach (DamageProperty prop in info.ability.critDamageEffects)
                {
                    EffectHandler.ApplyDamage(prop, unit, c, info.level);
                }
            }

            else
            {
                foreach (DamageProperty prop in info.ability.damageEffects)
                {
                    EffectHandler.ApplyDamage(prop, unit, c, info.level);
                }
            }

            if (c.currentUnit != null)
            {
                if (info.hitThisTurn.ContainsKey(c.currentUnit))
                {
                    info.hitThisTurn [c.currentUnit]++;
                }
                else
                {
                    info.hitThisTurn.Add(c.currentUnit, 1);
                }
            }
        }

        unit.unitController.UseAbility(info.ability.animationTrigger, target);
        unit.stats.SetAp(-info.ability.apCostPerLvl [info.level - 1]);
        info.castsThisTurn++;
        info.remainingCooldown = info.ability.cooldownPerLvl [info.level - 1];
        unit.OutsideUpdateUnitState();
        unit.floatingText.DisplayApChange(-info.ability.apCostPerLvl [info.level - 1]);

        if (info.ability.castsPerTargetPerLvl [info.level - 1] != 0 && target.currentUnit != null)
        {
            if (info.hitThisTurn.ContainsKey(target.currentUnit))
            {
                info.hitThisTurn [target.currentUnit]++;
            }
            else
            {
                info.hitThisTurn.Add(target.currentUnit, 1);
            }
        }
    }