Exemplo n.º 1
0
    public static ActiveSkill UseAttack(Unit attacker, Attack attack)
    {
        bool atLeastOneTargetInRange = false;

        IEnumerable <Attackable> targets = TargetingFunction.DetectSurroundings(attacker, attack.IsValidTarget).Cast <Attackable>();

        foreach (Attackable target in targets)
        {
            bool targetInRange = attack.IsUsable(attacker, target);
            atLeastOneTargetInRange = atLeastOneTargetInRange || targetInRange;
            if (targetInRange)
            {
                if (attack.Cooldown <= 0)
                {
                    attack.ApplyOnTarget(target);
                    attack.Cooldown = 1.0f;
                    return(attack);
                }
            }
        }

        return(null);
    }
Exemplo n.º 2
0
    public static bool UseAttack(Unit attacker, Attack attack)
    {
        bool atLeastOneTargetInRange = false;

        List <Attackable> targets = TargetingFunction.DetectSurroundings(attacker, attack.isValidTarget);

        foreach (Attackable target in targets)
        {
            bool targetInRange = attack.IsUsable(attacker, target);
            atLeastOneTargetInRange = atLeastOneTargetInRange || targetInRange;
            if (targetInRange)
            {
                if (attack.cooldown <= 0)
                {
                    attack.ApplyOnTarget(target);
                    attack.cooldown = 1.0f;
                    return(true);
                }
            }
        }

        return(atLeastOneTargetInRange);
    }