Esempio n. 1
0
    private void Update()
    {
        if (gameStarted == false)
        {
            if (countdownTimer > 0.5f)
            {
                InputManager.Instance.Activate(false);
                countdownTimer    -= Time.deltaTime;
                second             = countdownTimer % 60;
                startingTimer.text = string.Format("{0:0}", second);
            }
            else
            {
                startingTimer.text = startingText;
                countdownTimer    -= Time.deltaTime;

                if (countdownTimer < -0.5f)
                {
                    OnCountdownEnd?.Invoke();
                    InputManager.Instance.Activate(true);
                    timerStarted = true;
                    gameStarted  = true;
                }
            }
        }

        // if timer is started decrease it by time passed
        if (timerStarted == true)
        {
            //Destroy(startingTimer, 0.5f);

            if (levelPreparationTime > 0)
            {
                levelPreparationTime -= Time.deltaTime;
            }
            else
            {
                OnPreparationEnd?.Invoke();
            }

            currentTime -= Time.deltaTime;
            CalculateTime();
            OnTimerUpdate?.Invoke(minutes, seconds);

            // if countdown arrived to 0 send timer ended message and reset timer
            if (currentTime <= 0)
            {
                SoundManager.Instance.PlayAudioClip(endGameClip, false, endGameClipLoop, endGameClipPriority, endGameClipVolume,
                                                    UnityEngine.Random.Range(endGameClipPitchMin, endGameClipPitchMax));

                timerStarted = false;
                OnGameEnd?.Invoke();
            }

            if (levelTimeTotal - currentTime <= 0.5f)
            {
                startingTimer.gameObject.SetActive(false);
            }
        }
    }
Esempio n. 2
0
    void TimerUpdate()
    {
        float percent = currentTime / maxTime;

        if (incrementalDistancePercent)
        {
            percent = 1 - percent;
        }

        OnTimerUpdate?.Invoke(currentTime, percent);
    }
Esempio n. 3
0
 public void update()
 {
     if (isInProgress)
     {
         float elapsedMilliseconds = DemagoScript.getScriptTime() - startTime;
         if (elapsedMilliseconds <= millisecondsToWait)
         {
             float elapsedPourcent = elapsedMilliseconds / millisecondsToWait;
             OnTimerUpdate?.Invoke(elapsedMilliseconds, elapsedPourcent);
         }
         else
         {
             this.stop();
         }
     }
 }
Esempio n. 4
0
 private void Update()
 {
     if (remainingTime > 0)
     {
         remainingTime -= Time.deltaTime;
         OnTimerUpdate?.Invoke(this, EventArgs.Empty);
     }
     else
     {
         if (!hordeActive)
         {
             hordeActive = true;
             OnHordeActive?.Invoke(this, EventArgs.Empty);
         }
     }
 }
Esempio n. 5
0
 // unregister a method to on game end event
 public void UnregisterOnTimerUpdate(Action <int, int> action)
 {
     OnTimerUpdate?.Invoke(minutes, seconds);
     OnTimerUpdate -= action;
 }
 public void FireTimerUpdate(float procent, float time)
 {
     OnTimerUpdate?.Invoke(procent, time);
 }