public void AddMoney(int amount) { Money += amount; // Invoke OnMoneyValueChanged event to notify subscribers (e.g: UI) to update money text value. OnMoneyValueChanged?.Invoke(this, this.Money); }
public bool TakePlantMoney() { if (Money < 2) { return(false); } Money -= 2; // Invoke OnMoneyValueChanged event to notify subscribers (e.g: UI) to update money text value. OnMoneyValueChanged?.Invoke(this, this.Money); return(true); }
public bool TakeMoney(int amount) { if (Money <= 0) { return(false); } if (amount > Money) { return(false); } Money -= amount; // Invoke OnMoneyValueChanged event to notify subscribers (e.g: UI) to update money text value. OnMoneyValueChanged?.Invoke(this, this.Money); return(true); }