コード例 #1
0
        public void AddListener_ReceivesPauseStatusUpdates()
        {
            _timeService.AddPauseListener(_listener);

            const EPauseStatus newStatus = EPauseStatus.Paused;

            _timeService.SetPauseStatus(EPauseStatus.Paused);

            Assert.AreEqual(newStatus, _listener.UpdatePauseStatusResult);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public static EPauseStatus Invert(EPauseStatus inPauseStatus)
        {
            switch (inPauseStatus)
            {
            case EPauseStatus.Paused:
                return(EPauseStatus.Unpaused);

            case EPauseStatus.Unpaused:
                return(EPauseStatus.Paused);

            default:
                return(inPauseStatus);
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
 public TimeService()
 {
     _pauseListeners     = new List <IPauseListenerInterface>();
     _currentPauseStatus = EPauseStatus.Unpaused;
     _priorTimeScale     = 0.0f;
 }
コード例 #8
0
ファイル: TimeMessages.cs プロジェクト: Huxellberger/Cell
 public PauseStatusChangedMessage(EPauseStatus inNewPauseStatus)
     : base()
 {
     NewPauseStatus = inNewPauseStatus;
 }
コード例 #9
0
 // IPauseListenerComponent
 public void UpdatePauseStatus(EPauseStatus inStatus)
 {
     UnityMessageEventFunctions.InvokeMessageEventWithDispatcher(gameObject, new PauseStatusChangedMessage(inStatus));
 }
コード例 #10
0
 public void SetPauseStatus(EPauseStatus inPauseStatus)
 {
     SetPauseStatusResult = inPauseStatus;
 }
コード例 #11
0
 public void UpdatePauseStatus(EPauseStatus inStatus)
 {
     UpdatePauseStatusResult = inStatus;
 }