// 更新状态 public void OnTick() { if (m_Active) { m_TickCount++; float t = m_UseRealTime ? Time.realtimeSinceStartup : Time.time; m_Runtime = t - m_StartTime; if (m_StateCount == 0) { return; } if (m_CurrentState != null) { m_StateRuntime = t - m_StateStartTime; m_StateTickCount++; } else if (m_States.TryGetValue(m_CurrentStateName, out m_CurrentState)) { m_StateStartTime = t; m_StateRuntime = 0; m_CurrentState.OnBegin(); m_StateTickCount = 1; } if (m_CurrentState != null) { m_CurrentState.OnTick(); } Transition trans = FindSuccessCondition(); if (trans != null) { ChangeState(trans); } } }
// 更新状态 public void OnTick(float deltaTime) { if (m_Active) { m_TickCount++; m_Runtime += deltaTime; if (m_StateCount == 0) { return; } if (m_CurrentState != null) { m_StateRuntime += deltaTime; m_StateTickCount++; } else if (m_States.TryGetValue(m_CurrentStateName, out m_CurrentState)) { m_StateRuntime = 0; m_CurrentState.OnBegin(); m_StateTickCount = 1; } if (m_CurrentState != null) { m_CurrentState.OnTick(deltaTime); } Transition trans = FindSuccessCondition(); if (trans != null) { ChangeState(trans); } } }