コード例 #1
0
ファイル: Timer.cs プロジェクト: Cjaker/TibiaUnity3D
 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
ファイル: TimerController.cs プロジェクト: kleon6436/Timer
        /// <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;
    }
コード例 #15
0
 /// <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
ファイル: TimerController.cs プロジェクト: kleon6436/Timer
        /// <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
ファイル: TimerHook.cs プロジェクト: yazici/ScriptableArch
 protected virtual void RaiseTimerEvent()
 {
     TimerEvent?.Invoke(this, new TimerEventArgs());
     Timer.UnregisterHook(this);
 }
コード例 #25
0
ファイル: GameEventManager.cs プロジェクト: harko12/HighOrLow
 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();
 }