Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }