/// <summary> /// Callback when a state has finished executing. The Start and End states trigger this callback so the ability knows when to change. /// </summary> private void OnStateComplete() { if (m_CurrentStateID == HeightChangeIDs.Start) { m_CurrentStateID = HeightChangeIDs.Movement; m_AnimatorMonitor.DetermineStates(); } else if (m_CurrentStateID == HeightChangeIDs.Stop) { AbilityStopped(false); } }
/// <summary> /// Starts executing the ability. /// </summary> protected override void AbilityStarted() { // Go directly to the movement state if there is no start transition state. if (!string.IsNullOrEmpty(m_StartState)) { m_CurrentStateID = HeightChangeIDs.Start; } else { m_CurrentStateID = HeightChangeIDs.Movement; } base.AbilityStarted(); EventHandler.ExecuteEvent <bool>(m_GameObject, "OnAbilityHeightChange", true); EventHandler.RegisterEvent(m_GameObject, "OnAnimatorStateComplete", OnStateComplete); }
/// <summary> /// The ability has stopped running. /// </summary> /// <param name="checkForStopState">Should the stop state be checked?</param> private void AbilityStopped(bool checkForStopState) { // If there is a stop state then ensure that has been played first. if (checkForStopState && !string.IsNullOrEmpty(m_StopState)) { m_CurrentStateID = HeightChangeIDs.Stop; m_AnimatorMonitor.DetermineStates(); return; } // If a stop state exists then it has been played. Completely stop the ability. base.AbilityStopped(); // Restore the collider height/center. m_CurrentStateID = HeightChangeIDs.Start; EventHandler.ExecuteEvent <bool>(m_GameObject, "OnAbilityHeightChange", false); EventHandler.UnregisterEvent(m_GameObject, "OnAnimatorStateComplete", OnStateComplete); }