public void AddListener_ReceivesPauseStatusUpdates() { _timeService.AddPauseListener(_listener); const EPauseStatus newStatus = EPauseStatus.Paused; _timeService.SetPauseStatus(EPauseStatus.Paused); Assert.AreEqual(newStatus, _listener.UpdatePauseStatusResult); }
public void AddListener_MultipleListeners_AllUpdated() { _timeService.AddPauseListener(_listener); _timeService.AddPauseListener(_otherListener); const EPauseStatus newStatus = EPauseStatus.Paused; _timeService.SetPauseStatus(EPauseStatus.Paused); Assert.AreEqual(newStatus, _listener.UpdatePauseStatusResult); Assert.AreEqual(newStatus, _otherListener.UpdatePauseStatusResult); }
public void RemoveListener_NotUpdated() { _timeService.AddPauseListener(_listener); _timeService.AddPauseListener(_otherListener); _timeService.RemovePauseListener(_listener); const EPauseStatus newStatus = EPauseStatus.Paused; _timeService.SetPauseStatus(EPauseStatus.Paused); Assert.IsNull(_listener.UpdatePauseStatusResult); Assert.AreEqual(newStatus, _otherListener.UpdatePauseStatusResult); }
public static EPauseStatus Invert(EPauseStatus inPauseStatus) { switch (inPauseStatus) { case EPauseStatus.Paused: return(EPauseStatus.Unpaused); case EPauseStatus.Unpaused: return(EPauseStatus.Paused); default: return(inPauseStatus); } }
public void UpdatePauseStatus_FiresCorrespondingEvent() { var eventSpy = new UnityTestMessageHandleResponseObject <PauseStatusChangedMessage>(); var handler = UnityMessageEventFunctions.RegisterActionWithDispatcher <PauseStatusChangedMessage>( _pauseListener.gameObject, eventSpy.OnResponse); const EPauseStatus sentStatus = EPauseStatus.Paused; _pauseListener.UpdatePauseStatus(sentStatus); Assert.IsTrue(eventSpy.ActionCalled); Assert.AreEqual(sentStatus, eventSpy.MessagePayload.NewPauseStatus); UnityMessageEventFunctions.UnregisterActionWithDispatcher(_pauseListener.gameObject, handler); }
public void SetPauseStatus(EPauseStatus inPauseStatus) { if (_currentPauseStatus != inPauseStatus) { _currentPauseStatus = inPauseStatus; switch (_currentPauseStatus) { case EPauseStatus.Paused: _priorTimeScale = UnityEngine.Time.timeScale; UnityEngine.Time.timeScale = 0.0f; break; case EPauseStatus.Unpaused: UnityEngine.Time.timeScale = _priorTimeScale; break; default: break; } UpdatePauseListeners(); } }
public TimeService() { _pauseListeners = new List <IPauseListenerInterface>(); _currentPauseStatus = EPauseStatus.Unpaused; _priorTimeScale = 0.0f; }
public PauseStatusChangedMessage(EPauseStatus inNewPauseStatus) : base() { NewPauseStatus = inNewPauseStatus; }
// IPauseListenerComponent public void UpdatePauseStatus(EPauseStatus inStatus) { UnityMessageEventFunctions.InvokeMessageEventWithDispatcher(gameObject, new PauseStatusChangedMessage(inStatus)); }
public void SetPauseStatus(EPauseStatus inPauseStatus) { SetPauseStatusResult = inPauseStatus; }
public void UpdatePauseStatus(EPauseStatus inStatus) { UpdatePauseStatusResult = inStatus; }