示例#1
0
 public bool StartCasting(TargetingAI aiTargeting = null)
 {
     if (Template.Targeting.IsAutoTarget)
     {
         AutoTarget(currentCast);
         if (!currentCast.CheckTargets())
         {
             currentCast.Cancel();
             return(false);
         }
         currentCast.Execute();
     }
     else
     {
         if (currentCast.Caster.AIHandler.IsAI)
         {
             UseAITargets(currentCast, aiTargeting);
             if (!currentCast.CheckTargets())
             {
                 currentCast.Cancel();
                 return(false);
             }
             currentCast.Execute();
         }
         else
         {
             ManualTarget(currentCast);
         }
     }
     return(true);
 }
示例#2
0
    void UseAITargets(AbilityInstance abilityInstance, TargetingAI aiTargeting = null)
    {
        if (aiTargeting == null)
        {
            return;
        }
        List <Character> targets = aiTargeting.GetAITargets(abilityInstance);

        if (targets != null)
        {
            abilityInstance.Targets.AddRange(targets);
        }
    }
示例#3
0
    public bool CastAbility(AbilityType abilityType, TargetingAI aiTargeting = null)
    {
        if (!Character.Available)
        {
            Debug.Log("Character busy, not active, or incapacitated");
            return(false);
        }
        if (casting.Value)
        {
            Debug.Log("Already casting a spell");
            return(false);
        }

        Ability ability = GetAbility(abilityType);

        if (ability == null)
        {
            Debug.LogError("Ability doesn't exist");
            return(false);
        }
        if (!ability.CanCast)
        {
            Debug.Log("Ability can't cast");
            return(false);
        }

        AbilityInstance abInst = ability.GetNewInstance(Character);

        abInst.OnStart.AddListener(() =>
        {
            casting.Value = true;
            Character.ActionPointHandler.UseActionPoints(ability.Template.ActionPointCost);
        });

        abInst.OnComplete.AddListener(() =>
        {
            casting.Value = false;
            Character.Mover.DoneInMelee();
        });

        abInst.OnCancel.AddListener(() =>
        {
            casting.Value = false;
            Character.Mover.DoneInMelee();
        });

        return(ability.StartCasting(aiTargeting));
    }