public void LateUpdate() { foreach (Transition t in transitions) { if (t.condition.Test()) { State target; if (t.GetType().Equals(typeof(TransitionDecision))) { TransitionDecision td = t as TransitionDecision; target = td.GetState(); } else { target = t.target; } target.enabled = true; this.enabled = false; return; } } }
/// <summary> /// 每帧检测与当前状态相关联的过度条件,找到满足条件的则激活 /// 过度条件对应的状态,关闭当前状态(自动进行状态跳转) /// </summary> public void LateUpdate() { for (int i = 0; i < transitions.Count; i++) { if (transitions[i].condition.Test()) { State target; if (transitions[i].GetType().Equals(typeof(TransitionDecision))) { // 如果是合并类型的状态 则通过GetState获取下一个状态 TransitionDecision td = transitions[i] as TransitionDecision; target = td.GetState(); } else { target = transitions[i].target; } target.enabled = true; this.enabled = false; return; } } }