Ejemplo n.º 1
0
        public bool timerIsRunning = false;    // Timerが動いているかどうか

        public void StartTimer()
        {
            elapsedTimeSecond.Value = 0;
            timerIsRunning          = true;

            OnTimeUp.Subscribe(_ =>
            {
                // ゲーム終了時
                seAudio.clip    = gameEndSE;
                voiceAudio.clip = gameEndVoice;

                // カウントダウン時に再生位置をいじったためここでも調整
                seAudio.time    = 0f;
                voiceAudio.time = 0f;

                seAudio.Play();
                voiceAudio.Play();
            }).AddTo(gameObject);

            var gameBGM = GameObject.Find("GameBGM").GetComponent <AudioSource>();

            Assert.IsNotNull(gameBGM);

            OnHarryUp.Subscribe(_ =>
            {
                gameBGM.pitch = harryUpBGMPick;
            }).AddTo(gameObject);
        }
Ejemplo n.º 2
0
 void CallDeletage()
 {
     if (OnTimeUpAction != null)
     {
         OnTimeUpAction();
         OnTimeUpAction = null;
     }
 }
Ejemplo n.º 3
0
 private void OnTimePassed(int minutes)
 {
     m_time -= minutes;
     if (m_time <= 0)
     {
         OnTimeUp?.Invoke(this);
     }
 }
Ejemplo n.º 4
0
        void FixedUpdate()
        {
            timeRemaining = Mathf.Max(timeRemaining - Time.fixedDeltaTime, 0);

            if (timeRemaining <= 0)
            {
                Time.timeScale = 0;
                Debug.Log("Time is up. Returning to editor.");
                OnTimeUp?.Invoke();
                StartCoroutine(ReturnToEditor());
            }
        }
        public void SetElapsedTime(TimeSpan elapsed)
        {
            if (validTimer)
            {
                TimeSpan remaining = duration - elapsed;

                if (remaining.TotalSeconds <= 0)
                {
                    remaining = new TimeSpan();

                    OnTimeUp?.Invoke(this, null);
                    InvalidateTimer();
                }
                lblRemainingTime.Content = remaining.ToString(@"hh\:mm\:ss");
            }
        }
Ejemplo n.º 6
0
        private void Init(float sec, OnTimeUpVoid funcVoid, OnTimeUp func, object obj, IDroppableItem timerDropper, bool onceCall, bool realtimeTimer, int engineLoop)
        {
            if (funcVoid != null)
            {
                onTimeUpVoidEvent = funcVoid;
            }

            if (func != null)
            {
                onTimeUpEvent = func;
            }

            _once       = onceCall;
            _realtime   = realtimeTimer;
            _firedObj   = obj;
            _engineLoop = engineLoop;

            if (Mathf.Approximately(sec, 0))
            {
                Call();

                if (_once)
                {
                    onTimeUpEvent     = null;
                    onTimeUpVoidEvent = null;
                    return;
                }
            }

            _timeStep = sec;
            _work     = true;

            if (timerDropper != null)
            {
                _dropper         = timerDropper;
                _dropper.onDrop += InternalDrop;
            }

            Sync.Add(() => _timers[_engineLoop].Add(this), _engineLoop);
        }
Ejemplo n.º 7
0
        public override void Drop()
        {
            if (dropped)
            {
                return;
            }

            if (_dropper != null)
            {
                _dropper.onDrop -= InternalDrop;
            }
            _dropper = null;

            Pause();

            onTimeUpEvent     = null;
            onTimeUpVoidEvent = null;

            Sync.Add(() => _timers[_engineLoop].Remove(this), _engineLoop);

            base.Drop();
        }
Ejemplo n.º 8
0
 private Timer(float sec, OnTimeUp func, object obj, IDroppableItem dropper, bool once = false, bool realtime = false, int?engineLoop = null)
 {
     Init(sec, null, func, obj, dropper, once, realtime, engineLoop ?? Loops.TIMER);
 }
Ejemplo n.º 9
0
 public static Timer CreateRealtime(float sec, OnTimeUp func, object obj, IDroppableItem dropper, bool once = false, int?engineLoop = null)
 {
     return(new Timer(sec, func, obj, dropper, once, true, engineLoop));
 }
Ejemplo n.º 10
0
 public Timer(int countTo, OnTimeUp onTimeUp)
     : this(countTo)
 {
     _onTimeUp = onTimeUp;
 }