public void TryStopAction(CharacterAction action) { if (action == null) { return; } if (action.CanStopAction()) { int index = Array.IndexOf(m_Actions, action); if (m_ActiveAction == action) { m_ActiveAction = null; } action.StopAction(); ActionStopped(); } }
protected void StopStartAction(CharacterAction charAction) { // First, check if current Action can Start or Stop. // Current Action is Active. if (charAction.enabled && charAction.IsActive) { // Check if can stop Action is StopType is NOT Manual. if (charAction.StopType != ActionStopType.Manual) { if (charAction.CanStopAction()) { // Start the Action and update the animator. charAction.StopAction(); // Reset Active Action. if (m_ActiveAction = charAction) { m_ActiveAction = null; } // Move on to the next Action. return; } } } // Current Action is NOT Active. else { // Check if can start Action is StartType is NOT Manual. if (charAction.enabled && charAction.StartType != ActionStartType.Manual) { if (m_ActiveAction == null) { if (charAction.CanStartAction()) { // Start the Action and update the animator. charAction.StartAction(); //charAction.UpdateAnimator(); // Set active Action if not concurrent. if (charAction.IsConcurrentAction() == false) { m_ActiveAction = charAction; } // Move onto the next Action. return; } } else if (charAction.IsConcurrentAction()) { if (charAction.CanStartAction()) { // Start the Action and update the animator. charAction.StartAction(); //charAction.UpdateAnimator(); // Move onto the next Action. return; } } else { return; } } } }