Exemple #1
0
        private void OnLivesChanged()
        {
            RemoveNextLife();

            if (LivesChanged != null)
            {
                LivesChanged.Invoke();
            }
        }
 private void AddLive(int amount)
 {
     _lives += amount;
     if (_lives < 0)
     {
         GameOver();
     }
     LivesChanged?.Invoke(_lives);
 }
Exemple #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);
        }
Exemple #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);
            }
        }
Exemple #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);
        }
Exemple #6
0
 public void SetLivesChanged(int lives)
 {
     LivesCount = lives;
     LivesChanged?.Invoke(lives);
 }
Exemple #7
0
 public static void ChangeLives(int lives)
 {
     LivesChanged?.Invoke(lives);
 }
Exemple #8
0
 protected virtual void OnLivesChanged(object sender, LivesChangedArgs e) => LivesChanged?.Invoke(sender, e);
 private void Start()
 {
     ScoreChanged?.Invoke(_score);
     LivesChanged?.Invoke(_lives);
 }