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; }
public IEnumerator DelayedAIAction(DecayingDev.Action _AIAction, string[] args, float delayTime) { yield return(new WaitForSeconds(delayTime)); _AIAction.Execute(args, gameObject); state = ScheduleState.RunningAction; }
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); } }
public void ExecuteSecondAction(List <string> args) { PauseAction(); state = ScheduleState.SecondaryAction; CurSecondaryAction.Execute(args.ToArray(), gameObject); CurAction = null; }