Beispiel #1
0
    public void ExecuteAction(int index, bool Secondary = false, bool started = false)
    {
        state       = ScheduleState.WaitingForNextAction;
        ActionIndex = index;
        PeriodSlot period;

        DecayingDev.Action _AIAction;
        if (index < schedule.Periods.Count)
        {
            period    = schedule.Periods[index];
            _AIAction = period.action;
        }
        else
        {
            ActionIndex = 0;
            period      = schedule.Periods[0];
            _AIAction   = period.action;
        }

        if (started)
        {
            StartCoroutine(DelayedAIAction(_AIAction, period.args.ToArray(), 0));
        }
        else
        {
            StartCoroutine(DelayedAIAction(_AIAction, period.args.ToArray(), PreviousIndex(schedule.Periods)));
        }
        //action.Execute(period.args.ToArray(), gameObject);
        CurAction = _AIAction;
    }
Beispiel #2
0
    public IEnumerator DelayedAIAction(DecayingDev.Action _AIAction, string[] args, float delayTime)
    {
        yield return(new WaitForSeconds(delayTime));

        _AIAction.Execute(args, gameObject);
        state = ScheduleState.RunningAction;
    }
Beispiel #3
0
 void AwaitNextAction()
 {
     if (CurAction is MoveTo || CurSecondaryAction is MoveTo)
     {
         if (agent.remainingDistance < 1)
         {
             if (CurSecondaryAction)
             {
                 CurAction          = schedule.Periods[ActionIndex].action;
                 CurSecondaryAction = null;
                 ExecuteAction(ActionIndex);
             }
             else
             {
                 ExecuteAction(ActionIndex + 1);
             }
             animator.SetBool("Moving", false);
         }
     }
     if (CurAction is Idle)
     {
         if (!Idling)
         {
         }
     }
     if (CurAction is ForceAIAction)
     {
         ExecuteAction(ActionIndex + 1);
     }
 }
Beispiel #4
0
    public void ExecuteSecondAction(List <string> args)
    {
        PauseAction();
        state = ScheduleState.SecondaryAction;

        CurSecondaryAction.Execute(args.ToArray(), gameObject);
        CurAction = null;
    }