/// <summary> /// Adds a Transition to the collection for the specified event ID. /// </summary> /// <param name="eventId"> /// The event ID associated with the Transition. /// </param> /// <param name="guard"> /// The guard to test to determine whether the transition should take /// place. /// </param> /// <param name="targetState"> /// The target state of the transtion. /// </param> /// <param name="actions"> /// Optional array of actions, to be performed during the transition. /// </param> /// <remarks> /// When a Transition is added to the collection, it is associated with /// the specified event ID. When a State receives an event, it looks up /// the event ID in its TransitionCollection to see if there are any /// Transitions for the specified event. /// </remarks> public void Add(TEvent eventId, GuardHandler <TState, TEvent, TArgs> guard, State targetState, params EventHandler <TransitionEventArgs <TState, TEvent, TArgs> >[] actions) { Transition trans = new Transition(guard, targetState); foreach (EventHandler <TransitionEventArgs <TState, TEvent, TArgs> > action in actions) { if (action == null) { continue; } trans.Actions += action; } Add(eventId, trans); }
protected void Awake() { PauseMenu = this.gameObject.transform.Find("PauseMenu").gameObject; mainChar = GameObject.Find("MainChar").GetComponent <CharacterController> (); anim = mainChar.GetComponent <Animator> (); guardsObj = GameObject.FindGameObjectsWithTag("Guard"); gHandler = this.gameObject.GetComponent <GuardHandler> (); blockRaycasts = transform.Find("RaycastBlocker").gameObject; if (guardsObj.Length > 0) { for (int i = 0; i < guardsObj.Length; i++) { guardsAI.Add(guardsObj [i].gameObject.GetComponent <GuardsAI> ()); } } saveScript = gameObject.GetComponent <SaveScript>(); }
/// <summary> /// Initializes a new instance of the Transition class with the /// specified guard. /// </summary> /// <param name="guard"> /// The guard to test to determine whether the transition should take /// place. /// </param> public Transition(GuardHandler guard) { this.guard = guard; }
/// <summary> /// Initializes a new instance of the Transition class with the /// specified guard and target. /// </summary> /// <param name="guard"> /// The guard to test to determine whether the transition should take /// place. /// </param> /// <param name="target"> /// The target state of the transition. /// </param> public Transition(GuardHandler guard, State target) { this.guard = guard; this.target = target; }
void Awake() { guardHandler = GameObject.Find("UI").GetComponent <GuardHandler>(); }
/// <summary> /// Initializes a new instance of the Transition class with the /// specified guard and target. /// </summary> /// <param name="guard"> /// The guard to test to determine whether the transition should take /// place. /// </param> /// <param name="target"> /// The target state of the transition. /// </param> public Transition(GuardHandler <TState, TEvent, TArgs> guard = null, State target = null) { m_guard = guard ?? s_emptyGuard; m_target = target; }
/// <summary> /// Adds a new transition to the state machine. The source and target states will be /// implicitly added to the state machine if necessary. /// </summary> /// <param name="source">The source state.</param> /// <param name="eventId">The event that will trigger the transition.</param> /// <param name="guard">A transition guard.</param> /// <param name="target">The target state.</param> /// <param name="actions">Optional actions that will be performed during the transition.</param> public void AddTransition(TState source, TEvent eventId, GuardHandler <TState, TEvent, TArgs> guard, TState target, params EventHandler <TransitionEventArgs <TState, TEvent, TArgs> >[] actions) { states[source].Transitions.Add(eventId, guard, states[target], actions); }
private void InitializeGuards() { guardFooIsTrue = FooIsTrue; guardFooIsFalse = FooIsFalse; }
void Awake() { gHandler = GameObject.Find("UI").GetComponent <GuardHandler> (); clip = Resources.Load("Music/siren-03") as AudioClip; }