private void KeyRelease(object sender, KeyEventArgs e) { // Gets the data context. KinectController model = DataContext as KinectController; IPausable viewModel = model.NavigationManager.CurrentNavigationContext as IPausable; // The current view model is not IPausable if (viewModel == null) { return; } if (e.Key == Key.Space) { if (viewModel.IsPaused) { viewModel.Resume(); } else { viewModel.Pause(); } } if (e.Key == Key.Escape) { model.NavigationManager.GoBack(); } }
public void remove(IPausable p) { int h = p.GetHashCode(); if (p.isSceneOnly()) { for (int i = 0, c = sceneOnly.Count; i < c; ++i) { if (h == sceneOnly[i].GetHashCode()) { sceneOnly.RemoveAt(i); sceneOnlyMonos.RemoveAt(i); break; } } } else { for (int i = 0, c = durables.Count; i < c; ++i) { if (h == durables[i].GetHashCode()) { durables.RemoveAt(i); durablesMonos.RemoveAt(i); break; } } } }
public void RemovePausableObject(IPausable toRemove) { if (_objectsAffectedByPause.Contains(toRemove)) { _objectsAffectedByPause.Remove(toRemove); } }
/// <summary> /// Coroutine to wait for the object to become AbstractDanmakuControllerd /// <see href="http://docs.unity3d.com/Manual/Coroutines.html">Unity Manual: Coroutines</see> /// </summary> /// <returns> The Coroutine IEnumerator </returns> private static IEnumerator PauseWait(IPausable pausable) { while (pausable.Paused) { yield return(wfeof); } }
public void OnPause() { Debug.Log("PauseManager.OnPause"); isPaused = true; gcSurvival.GamePaused = true; if (gcSurvival.Score != 0) { PlayerPrefs.SetInt("GamePaused", 1); } foreach (AudioSource audio in audios) { audio.enabled = false; } foreach (var pausableComponent in pausableInterfaces) { IPausable pausableInterface = (IPausable)pausableComponent; if (pausableInterface != null) { pausableInterface.OnPause(); } btnAudio.Play(); } }
public static void RegisterPausable(IPausable pausable) { if (pausables == null) { pausables = new List <IPausable>(); } pausables.Add(pausable); }
// Register the input pausable object to have its OnPause/OnResume methods called public void Register(IPausable pausable) { // Register the input pausable to be executed for every pausble event foreach (BroadcastType bt in BroadcastType.GetValues(typeof(BroadcastType))) { pausableDict[bt].Add(pausable); } }
public void AddPausableObject(IPausable toAdd) { toAdd.Paused = _paused; if (!_objectsAffectedByPause.Contains(toAdd)) { _objectsAffectedByPause.Add(toAdd); } }
/// <summary> /// A useful utility function for Coroutines in implementors of IPausable. /// If the instance is not paused, it will wait return a WaitForEndOfFrame instance. /// If the instance is paused, it will wait until the object becomes AbstractDanmakuControllerd before continuing. /// <example> /// This is standard usage for this function: /// <code> /// yield return AbstractDanmakuController() /// </code> /// </example> /// <see href="http://docs.unity3d.com/Manual/Coroutines.html">Unity Manual: Coroutines</see> /// </summary> /// <returns> The approriate YieldInstruction for the situation.</returns> public static YieldInstruction WaitForUnpause(IPausable pausableObject, YieldInstruction value = null) { if (pausableObject.Paused) { return(UtilityBehaviour.StartCoroutine(PauseWait(pausableObject))); } else { return(value); } }
/** * Register a pausable object with the manager */ public void RegisterPausable(IPausable pausable) { if (timeState == TimeState.Paused) { pausable.Pause(); } else { pausable.Resume(); } pausableObjects.Add(pausable); }
public void register(IPausable p, GameObject go) { if (p.isSceneOnly()) { sceneOnly.Add(p); sceneOnlyMonos.Add(go.GetComponents <MonoBehaviour>()); } else { durables.Add(p); durablesMonos.Add(go.GetComponents <MonoBehaviour>()); } }
public void OnPause() { Debug.Log("PauseManager.OnPause"); isPaused = true; foreach (var pausableComponent in pausableInterfaces) { IPausable pausableInterface = (IPausable)pausableComponent; if (pausableInterface != null) { pausableInterface.OnPause(); } } }
// Return the callback appropriate for the input broadcast type private static Action GetCallback(BroadcastType bt, IPausable pausable) { // fancy C# switch expression - shorthand for good ol' switch-case block switch (bt) { case BroadcastType.Pause: return(pausable.OnPause); case BroadcastType.Resume: return(pausable.OnResume); default: throw new Exception(bt.ToString()); } }
/// <summary> /// Register the specified MonoBehaviour into the pausable components list /// Call this method in Start(). Calling from Awake() will fail to correctly get children components. /// </summary> /// <param name="p">Pausable implementation</param> /// <param name="mono">MonoBehaviour</param> public void register(IPausable p, MonoBehaviour mono) { MonoBehaviour[] monoArray = new MonoBehaviour[1]; monoArray[0] = mono; if (p.isSceneOnly()) { sceneOnly.Add(p); sceneOnlyMonos.Add(monoArray); } else { durables.Add(p); durablesMonos.Add(monoArray); } }
private void OnPause(bool pause) { if (pausableComponents == null) { return; } foreach (Component c in pausableComponents) { if (c is IPausable) { IPausable pausable = c as IPausable; pausable.Pause(pause); } } }
private IPausable GetActivePausable() { if (pausable != null) { if (pausable is ImageProvider imageProvider && imageProvider.IsActive) { return(pausable); } } var activeProvider = ProvidersHolder.Instance.ActiveProvider; if (activeProvider is IPausable provider) { pausable = provider; return(provider); } return(null); }
public void DisplayScene(Scene scene, IPausable pausable) { if (ActorDirectory.Instance == null) { throw new System.Exception("ActorDirectory is not active in this scene. Maybe you forgot to add it into globals?"); } if (gameObject.activeInHierarchy) { Debug.LogWarning("A new Scene was loaded when an old one was still playing. Was this desired behaviour?"); this.pausable = null; Hide(); } JumpToNode = -1; DecisionMade = -1; exitRequest = false; CurrentScene = scene; gameObject.SetActive(true); this.pausable = pausable; pausable.Pause(); NextAction(); }
public void PlayDialog(Interactable interactable, GameEvent onDialogEnd, bool singleInteraction) { PlayingDialog = true; _singleInteraction = singleInteraction; _dialogEndEvent = onDialogEnd; _interactable = interactable; _skipFrame = true; DisablePlayerControlls(); foreach (Dialog d in interactable.dialog) { _dialogQueue.Enqueue(d); } DisplayNextSentence(); // First update dialog name and text DisplayDialogBox(); // Then show dialog box }
/// <summary> /// Register the specified gameobject into the pausable components list /// Call this method in Start(). Calling from Awake() will fail to correctly get children components. /// </summary> /// <param name="p">Pausable implementation</param> /// <param name="go">GameObject</param> public void register(IPausable p, GameObject go) { // extract all MonoBehaviour components in one big array MonoBehaviour[] comps = go.GetComponentsInChildren <MonoBehaviour>(); MonoBehaviour[] combined = new MonoBehaviour[comps.Length]; Array.Copy(comps, 0, combined, 0, comps.Length); /*MonoBehaviour[] comps = go.GetComponents<MonoBehaviour>(); * MonoBehaviour[] compsChildren = go.GetComponentsInChildren<MonoBehaviour>(); * MonoBehaviour[] combined = new MonoBehaviour[comps.Length + compsChildren.Length]; * Array.Copy(comps, 0, combined, 0, comps.Length); * Array.Copy(compsChildren, 0, combined, comps.Length, compsChildren.Length);*/ if (p.isSceneOnly()) { sceneOnly.Add(p); sceneOnlyMonos.Add(combined); } else { durables.Add(p); durablesMonos.Add(combined); } }
public void RegisterPausable(IPausable pausable) { _pausables.Add(pausable); }
public static void RemoveList(IPausable pausable) { pausables.Remove(pausable); }
public static void RegisterPausable(IPausable pausable) { Pausables = Pausables.Add(pausable); }
public static void UnRegisterPausable(IPausable pausable) { Pausables = Pausables.Remove(pausable); }
public void UnSubscribePausable(IPausable iPausable) { OnPauseAction -= iPausable.Pause; OnUnPauseAction -= iPausable.UnPause; }
public static void RemovePauseble(IPausable pausable) { pausables.Remove(pausable); }
public void UnregisterPausable(IPausable pausable) { _pausables.Remove(pausable); }
public void addPausable(IPausable pausable){ onPause += pausable.Pause; onUnPause += pausable.UnPause; }
bool PausedOrNextOf <TPauseYield>(this IPausable <TPauseYield> pausable, in IEnumerator enumerator,
public void removePausable(IPausable unPausable){ onPause -= unPausable.Pause; onUnPause -= unPausable.UnPause; }
public static void AddPausableObject(IPausable pausable) { pauseables.Add(pausable); }