public void Goto(params StateLink[] serires) { if (serires.Length <= 0) { return; } if (!ignoreSeriesRunningCheck && StateLinkSeries.Count > 0) { Debug.LogWarning(string.Format("{0}.StateMachine >> New StateLinkSerires(firstStateName'{1}') is accepted," + " but Current StateLinkSerires(nextStateName'{2}') is already running. This serires will be stoped and clear.", gameObject.name, serires[0].stateName, StateLinkSeries.First.Value.stateName)); StateLinkSeries.Clear(); } foreach (var stateLink in serires) { StateLinkSeries.AddLast(stateLink); } ignoreSeriesRunningCheck = true; { Goto(StateLinkSeries.First.Value.stateName, StateLinkSeries.First.Value.timeLength, StateLinkSeries.First.Value.delayTime); } ignoreSeriesRunningCheck = false; StateLinkSeries.RemoveFirst(); }
void Update() { if (!IsPlaying) { return; } if (OnStateBegin == null || OnStateBegin(this)) { if (CurrentState != null && CurrentState.OnState != null && StateStartTime <= Time.time) { // Note: // OnState()でCurrentStateの更新がある可能性があるので, // previousStateの更新は, その前にやる. IsStateChange = (previousState != CurrentState); previousState = CurrentState; CurrentState.OnState(CurrentState); } if (StateStartTime + StateTimeLength < Time.time) { if (StateLinkSeries.Count > 0) { ignoreSeriesRunningCheck = true; { Goto(StateLinkSeries.First.Value.stateName, StateLinkSeries.First.Value.timeLength, StateLinkSeries.First.Value.delayTime); } ignoreSeriesRunningCheck = false; StateLinkSeries.RemoveFirst(); } else { Goto(IdleState, 0.0f); } } OnStateEnd?.Invoke(this); } }