void CancelCurrentAnimation() { if (animationCoroutine.IsRunning || animationCoroutine.IsPaused) { animationCoroutine.Stop(); } }
void KillCoroutine(SafeCoroutine target) { if (target != null && target.IsRunning) { target.Stop(); } }
public void UnlockMinAndMaxX() { cameraScrollLocked = false; if (cameraMovementOverride.IsRunning) { cameraMovementOverride.Stop(); } }
/// <summary> /// 停止协程 /// 会把孩子协程也停止了 /// </summary> public void Stop() { mIterator = null; mState = EState.Stopped; if (mChildCoroutine != null) { mChildCoroutine.Stop(); } }
void CancelBehaviourCoroutine() { if (behaviourCoroutine.IsPaused || behaviourCoroutine.IsRunning) { behaviourCoroutine.Stop(); } moving = false; idle = false; punching = false; }
static void CoroutineGUI(string a_Name, SafeCoroutine a_SafeCoroutine) { GUILayout.BeginHorizontal(); GUI.enabled = a_SafeCoroutine.IsPause; if (GUILayout.Button("Resume " + a_Name)) { a_SafeCoroutine.Resume(); } GUI.enabled = a_SafeCoroutine.CanPause; if (GUILayout.Button("Pause " + a_Name)) { a_SafeCoroutine.Pause(); } GUI.enabled = a_SafeCoroutine.IsRunning || a_SafeCoroutine.IsPause; if (GUILayout.Button("Stop " + a_Name)) { a_SafeCoroutine.Stop(); } GUILayout.EndHorizontal(); }
private void StopChildRoutines() { IEnumerator l_Enumerator = m_WrappedCoroutine; while (l_Enumerator != null) { object l_Yield = l_Enumerator.Current; if (l_Yield != null) { if (l_Yield is IEnumerator) { l_Enumerator = l_Yield as IEnumerator; } else if (l_Yield is SafeCoroutine) { SafeCoroutine l_SafeCoroutine = l_Yield as SafeCoroutine; if (l_SafeCoroutine.State == SafeCoroutineState.Running || l_SafeCoroutine.State == SafeCoroutineState.Paused) { l_SafeCoroutine.Stop(); } // The safe coroutine takes care of further child coroutines. l_Enumerator = null; } else { // Stop the loop. l_Enumerator = null; } } else { // Stop the loop. l_Enumerator = null; } } }
public PlayerAttack GetAttack(AttackInputType attackInputType) { PlayerAttack oldAttack = currentAttack; // Attack in progress already if (currentAttack != null) { // Has it been long enough for another attack if (currentAttack.PassedBaseAttackTime()) { var attack = GetAttackFromDictionary(attackInputType); // No move next on the tree, start from base corresponding to button pressed if (attack == null) { if (baseAttacks.Keys.Contains(attackInputType)) { currentAttack = baseAttacks[attackInputType]; } } // Advance along the tree else { currentAttack = attack; } if (logMessages) { Debug.Log(currentAttack.name); } } else { if (logMessages) { Debug.Log("No valid attack"); } currentAttack = null; } } // Base attack on tree else { if (baseAttacks.Keys.Contains(attackInputType)) { currentAttack = baseAttacks[attackInputType]; } } if (currentAttack != null) { currentAttack.StartTime = Time.time; } if ((oldAttack == attack1 || oldAttack == attack2) || (oldAttack != currentAttack && currentAttack != null)) { if (behaviourCoroutine.IsPaused || behaviourCoroutine.IsRunning) { behaviourCoroutine.Stop(); } } return(currentAttack); }