Beispiel #1
0
 public void OnPowerUpTimerExpiration(PowerUpTimerExpiredEvent powerUpTimerExpiredEvent)
 {
     if (timerId != null && timerId.Equals(powerUpTimerExpiredEvent.timerId))
     {
         Deactivate();
     }
 }
Beispiel #2
0
        void Update()
        {
            if (CurrentTimerId.HasValue)
            {
                int minutes = Mathf.FloorToInt(CurrentTime / 60F);
                int seconds = Mathf.FloorToInt(CurrentTime % 60);
                timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);

                if (IsCountingDown)
                {
                    CurrentTime -= Time.deltaTime;
                    if (CurrentTime <= 0f)
                    {
                        // Notify all the listeners that the PowerUp has been Deactivated
                        PowerUpTimerExpiredEvent powerUpTimerExpiredEvent = new PowerUpTimerExpiredEvent()
                        {
                            timerId = CurrentTimerId.Value
                        };
                        EventManager.Instance.NotifyListeners(powerUpTimerExpiredEvent);
                    }
                }
                else
                {
                    CurrentTime += Time.deltaTime;
                }
            }
        }