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