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();
            }
        }
Beispiel #2
0
    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;
                }
            }
        }
    }
Beispiel #3
0
 public void RemovePausableObject(IPausable toRemove)
 {
     if (_objectsAffectedByPause.Contains(toRemove))
     {
         _objectsAffectedByPause.Remove(toRemove);
     }
 }
Beispiel #4
0
 /// <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);
     }
 }
Beispiel #5
0
    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();
        }
    }
Beispiel #6
0
 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);
     }
 }
Beispiel #8
0
        public void AddPausableObject(IPausable toAdd)
        {
            toAdd.Paused = _paused;

            if (!_objectsAffectedByPause.Contains(toAdd))
            {
                _objectsAffectedByPause.Add(toAdd);
            }
        }
Beispiel #9
0
 /// <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);
     }
 }
Beispiel #10
0
    /**
     * Register a pausable object with the manager
     */
    public void RegisterPausable(IPausable pausable)
    {
        if (timeState == TimeState.Paused)
        {
            pausable.Pause();
        }
        else
        {
            pausable.Resume();
        }

        pausableObjects.Add(pausable);
    }
Beispiel #11
0
 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());
        }
    }
Beispiel #14
0
 /// <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);
     }
 }
Beispiel #15
0
    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);
            }
        }
    }
Beispiel #16
0
        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);
        }
Beispiel #17
0
 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();
 }
Beispiel #18
0
        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
        }
Beispiel #19
0
    /// <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);
        }
    }
Beispiel #20
0
 public void RegisterPausable(IPausable pausable)
 {
     _pausables.Add(pausable);
 }
Beispiel #21
0
 public static void RemoveList(IPausable pausable)
 {
     pausables.Remove(pausable);
 }
Beispiel #22
0
 public static void RegisterPausable(IPausable pausable)
 {
     Pausables = Pausables.Add(pausable);
 }
Beispiel #23
0
 public static void UnRegisterPausable(IPausable pausable)
 {
     Pausables = Pausables.Remove(pausable);
 }
Beispiel #24
0
 public void UnSubscribePausable(IPausable iPausable)
 {
     OnPauseAction   -= iPausable.Pause;
     OnUnPauseAction -= iPausable.UnPause;
 }
        public void AddPausableObject(IPausable toAdd)
        {
            toAdd.Paused = _paused;

            if (!_objectsAffectedByPause.Contains(toAdd)) { _objectsAffectedByPause.Add(toAdd); }
        }
Beispiel #26
0
 public static void RemovePauseble(IPausable pausable)
 {
     pausables.Remove(pausable);
 }
Beispiel #27
0
 public void UnregisterPausable(IPausable pausable)
 {
     _pausables.Remove(pausable);
 }
Beispiel #28
0
	public void addPausable(IPausable pausable){
			onPause += pausable.Pause;
			onUnPause += pausable.UnPause;

	}
 public void RemovePausableObject(IPausable toRemove)
 {
     if (_objectsAffectedByPause.Contains(toRemove)) { _objectsAffectedByPause.Remove(toRemove); }
 }
Beispiel #30
0
 bool PausedOrNextOf <TPauseYield>(this IPausable <TPauseYield> pausable,
                                   in IEnumerator enumerator,
Beispiel #31
0
	public void removePausable(IPausable unPausable){
			onPause -= unPausable.Pause;
			onUnPause -= unPausable.UnPause;

	}
 public static void AddPausableObject(IPausable pausable)
 {
     pauseables.Add(pausable);
 }