Exemplo n.º 1
0
        private void OnLivesChanged()
        {
            RemoveNextLife();

            if (LivesChanged != null)
            {
                LivesChanged.Invoke();
            }
        }
Exemplo n.º 2
0
 private void AddLive(int amount)
 {
     _lives += amount;
     if (_lives < 0)
     {
         GameOver();
     }
     LivesChanged?.Invoke(_lives);
 }
Exemplo n.º 3
0
        public void SetLives(int lives)
        {
            var info = new DamageChangeInfo
            {
                damageable = this,
                newLives   = lives,
                oldLives   = CurrentLives
            };

            CurrentLives = lives;

            if (CurrentLives == 0)
            {
                Debug.Log("Finished");
                Finished?.Invoke(info);
            }

            LivesChanged?.Invoke(info);
        }
Exemplo n.º 4
0
        public void WorkOutLivesEarned()
        {
            try
            {
                var minutesPast = (DateTime.Now - LastEarnedLife).TotalMinutes;

                int totalEarned = (int)(minutesPast / LivesRefreshTime);

                if (totalEarned > 0 || LastEarnedLife == DateTime.MinValue)
                {
                    LastEarnedLife  = DateTime.Now;
                    LivesRemaining += (int)totalEarned;

                    UserIO.Instance.SaveLivesInfo();
                    LivesChanged?.Invoke(true, LivesRemaining);
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance.WriteException(ex);
            }
        }
Exemplo n.º 5
0
        public void SubtractLives(int liveSubtraction, DamageChangeInfo info)
        {
            if (CurrentLives == 0)
            {
                Debug.Log("Damageable - Finished");
                Finished?.Invoke(info);
            }

            info.oldLives = CurrentLives;

            CurrentLives -= Mathf.Abs(liveSubtraction);
            CurrentLives  = Mathf.Clamp(CurrentLives, 0, maxLives);

            info.newLives = CurrentLives;

            if (CurrentLives == 0)
            {
                Debug.Log("Damageable - Finished");
                Finished?.Invoke(info);
            }

            LivesChanged?.Invoke(info);
            LostLife?.Invoke(info);
        }
Exemplo n.º 6
0
 public void SetLivesChanged(int lives)
 {
     LivesCount = lives;
     LivesChanged?.Invoke(lives);
 }
Exemplo n.º 7
0
 public static void ChangeLives(int lives)
 {
     LivesChanged?.Invoke(lives);
 }
Exemplo n.º 8
0
 protected virtual void OnLivesChanged(object sender, LivesChangedArgs e) => LivesChanged?.Invoke(sender, e);
Exemplo n.º 9
0
 private void Start()
 {
     ScoreChanged?.Invoke(_score);
     LivesChanged?.Invoke(_lives);
 }