예제 #1
0
 public void OnSystemTimerFinishes(object state, System.Timers.ElapsedEventArgs e)
 {
     OpenTibiaUnity.GameManager.InvokeOnMainThread(() =>
     {
         _timerEvent.Invoke(state, e);
     });
 }
예제 #2
0
        public void Increment()
        {
            // make sure the timer can run
            if (_currentTime >= _duration)
            {
                return;
            }

            // update and bound _currentTime
            _currentTime = Mathf.Min(_currentTime + Time.deltaTime, _duration);
            if (_currentTime >= _duration)
            {
                // check if looping
                if (_looping)
                {
                    // decrement the duration and signal iteration
                    _currentTime -= _duration;
                    _onIterate.Invoke();
                }
                else
                {
                    _currentTime = _duration;                     // bound to duration
                }
            }

            // signal changed event
            _onUpdate.Invoke(_currentTime);
            _onProgress.Invoke(Progress);

            // check if finished
            if (Progress == 1.0f)
            {
                _onFinish.Invoke();
            }
        }
예제 #3
0
        /// <summary>
        /// タイマー動作中の動作
        /// </summary>
        private void OnElapsed_TimersTimer(object sender, ElapsedEventArgs e)
        {
            if (_timerValue.Minute > MinTimerValue && _timerValue.Second == MinTimerValue)
            {
                // 1分減らして59秒にする
                _timerValue.Minute -= 1;
                _timerValue.Second  = MaxTimerValue;
            }
            else
            {
                // 1秒減らす
                _timerValue.Second -= 1;
            }

            // UIに反映(別スレッドなので、Dispatcherを利用)
            Application.Current.Dispatcher.Invoke(() => { TimerEvent?.Invoke(_timerValue); });

            // どちらも0になった場合はタイマー終了
            if (_timerValue.Minute != MinTimerValue || _timerValue.Second != MinTimerValue)
            {
                return;
            }

            // タイマーを終了
            _timerCount.Stop();
            _timerCount.Dispose();
            _timerCount = null;

            // ドミソミドと音を鳴らす
            BeepSound();
        }
예제 #4
0
 void OnUpdate()
 {
     onUpdate.Invoke(this);
     if (callbackUpdate != null)
     {
         callbackUpdate(this);
     }
 }
예제 #5
0
 void OnTriggerEnter(Collider collision)
 {
     if (!started && collision.gameObject == toCheckFor)
     {
         startTimer.Invoke();
         started = true;
     }
 }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        secondsElapsed += Time.deltaTime;
        int minutes = (int)secondsElapsed / 60;
        int seconds = (int)secondsElapsed % 60;

        timerEvent.Invoke($"{minutes}:{seconds:00}");
    }
예제 #7
0
 //終了時に呼び出される
 void OnCompleteCallback()
 {
     onComplete.Invoke(this);
     if (callbackComplete != null)
     {
         callbackComplete(this);
     }
     callbackComplete = null;
 }
예제 #8
0
        public void StartTimer()
        {
            IsPlaying = true;

            if (ElapsedGameTime == 0)
            {
                onStarted.Invoke();
            }
        }
예제 #9
0
        /// <summary>
        /// Event generating method
        /// </summary>
        public void Start()
        {
            timer.Enabled = true;
            while (timer.Enabled)
            {
            }

            TimerEvent?.Invoke(this, "Alarm!");
        }
예제 #10
0
 //更新時呼び出される
 void OnUpdate(WaitTimer timer)
 {
     this.Time   = timer.Time;
     this.Time01 = timer.Time01;
     onUpdate.Invoke(this);
     if (callbackUpdate != null)
     {
         callbackUpdate(this);
     }
 }
예제 #11
0
 //終了時に呼び出される
 void OnCompleteCallback()
 {
     IsPlaying = false;
     onComplete.Invoke(this);
     if (callbackComplete != null)
     {
         callbackComplete(this);
     }
     callbackComplete = null;
 }
예제 #12
0
        private void Run(object state)
        {
            while (IsLess(DateTime.Now, _dateTime))
            {
                Thread.Sleep(10);
            }

            TimerEventArgs eventArgs = new TimerEventArgs(DateTime.Now, "DateTime.Now");

            TimerEvent.Invoke(this, eventArgs);
        }
예제 #13
0
        private void Wait(object state)
        {
            while (DateTime.Now < this.dateTime)
            {
                Thread.Sleep(100);
            }

            TimerEventArgs timerEventArgs = new TimerEventArgs(DateTime.Now, "ring ring!");

            TimerEvent.Invoke(this, timerEventArgs);
        }
예제 #14
0
    private IEnumerator RunTimer(Action onCompleted)
    {
        isRunning = true;
        while (TimeLeft > 0)
        {
            OnTimerTick?.Invoke(TimeLeft);
            yield return(new WaitForSeconds(1));

            TimeLeft--;
        }
        onCompleted();
        isRunning = false;
    }
 /// <summary>
 /// Update is called once per frame
 /// </summary>
 void Update()
 {
     // update timer and check for finished
     if (running)
     {
         elapsedSeconds += Time.deltaTime;
         if (elapsedSeconds >= totalSeconds)
         {
             running = false;
             timerEvent.Invoke();
         }
     }
 }
예제 #16
0
 /// <summary>
 /// ゲーム時間処理
 /// </summary>
 private IEnumerator WaitUntilTimeOver()
 {
     onGameStart.Invoke((int)remainingGameTime);
     while (remainingGameTime > 0f)
     {
         var n = (int)remainingGameTime;
         remainingGameTime = Mathf.Max(0f, remainingGameTime - Time.deltaTime);
         if ((int)remainingGameTime != n)    // 残り時刻の整数部が変化した。
         {
             onTimeUpdate.Invoke((int)remainingGameTime);
         }
         yield return(null);
     }
     remainingGameTime = 0f;
 }
예제 #17
0
        /// <summary>
        /// タイマーをリセット
        /// </summary>
        public void ResetTimer()
        {
            // タイマーが動作中の場合
            if (_timerCount != null)
            {
                // タイマーを停止
                _timerCount.Stop();
                _timerCount.Dispose();
                _timerCount = null;
            }

            // タイマーを最小値に戻す
            _timerValue.Minute = MinTimerValue;
            _timerValue.Second = MinTimerValue;

            TimerEvent?.Invoke(_timerValue);
        }
예제 #18
0
    // Update is called once per frame

    void Update()
    {
        if (inited)
        {
            if (!paused)
            {
                timer += Time.deltaTime;
                if (timer >= totalTime)
                {
                    Finish();
                }
                else
                {
                    OnTick?.Invoke();
                }
            }
        }
    }
예제 #19
0
        private void FixedUpdate()
        {
            if (!IsPlaying)
            {
                return;
            }

            ElapsedGameTime += Time.deltaTime * TimeScale;

            if (ElapsedGameTime - _secondsTimer >= 1)
            {
                _secondsTimer = Mathf.FloorToInt(ElapsedGameTime);
                onTick.Invoke();
            }

            if (ElapsedGameTime >= TotalGameTime)
            {
                TimerCompleted();
            }
        }
예제 #20
0
    private void Update()
    {
        timeSoFar += Time.deltaTime;

        if (timers.Length == 0)
        {
            return;
        }

        if (timeSoFar < totalTime)
        {
            timers[currentSelection].ChangeTimer(timeSoFar / totalTime);
        }
        else
        {
            timers[currentSelection].ChangeTimer(1);
            if (currentSelection + 1 < timers.Length)
            {
                currentSelection++;
                timeSoFar = 0;
                onChangeImage.Invoke(currentSelection);
            }
        }
    }
예제 #21
0
 static private void TimerUp(object value)
 {
     systemTimeMS += 50;
     TimerEvent?.Invoke();
 }
예제 #22
0
 private void InitGameTimer()
 {
     remainingGameTime = gameTime;
     onTimeUpdate.Invoke((int)gameTime);
 }
예제 #23
0
 //遅延を考慮した開始時に呼び出される
 void OnStart(WaitTimer timer)
 {
     onStart.Invoke(this);
 }
예제 #24
0
 protected virtual void RaiseTimerEvent()
 {
     TimerEvent?.Invoke(this, new TimerEventArgs());
     Timer.UnregisterHook(this);
 }
예제 #25
0
 public string OnTimerUpdateInvoke(TimeUpdateInfo t)
 {
     OnTimerUpdate.Invoke(OnTimerUpdateKey, t);
     return(OnTimerUpdateKey);
 }
예제 #26
0
 public void StopTimer()
 {
     IsPlaying = false;
     ResetTimer();
     onStopped.Invoke();
 }
예제 #27
0
 public void ResumeTimer()
 {
     IsPlaying = true;
     onResumed.Invoke();
 }
예제 #28
0
 public void PauseTimer()
 {
     IsPlaying = false;
     onPaused.Invoke();
 }
예제 #29
0
 public void OnTimerEvent(ISendResponse sendResponse)
 {
     TimerEvent?.Invoke(this, new TimerEventArgs(sendResponse));
 }
예제 #30
0
 private void TimerCompleted()
 {
     IsPlaying = false;
     onCompleted.Invoke();
 }