Beispiel #1
0
        public void AddBankInterest()
        {
            if (hasBank)
            {
                int interestGain = CalculateInterestGain();
                if (interestGain > maxAmount)
                {
                    interestGain = maxAmount;
                }
                if (interestGain > 0)
                {
                    int gain = interestGain;
                    if (bank + interestGain > maxAmount)
                    {
                        if (interestGain > bank)
                        {
                            gain = interestGain - bank;
                        }
                        else
                        {
                            gain = bank - interestGain;
                        }
                    }
                    bank += gain;

                    _lastInterestDate = World.CurrentDate;
                    _lastInterestTime = World.CurrentTimeOfDay;

                    EconomyEventArgs e = new EconomyEventArgs();
                    e.amount = gain;
                    OnBankInterestReceived(e);
                }
            }
        }
Beispiel #2
0
        public void SpendCash(int amount)
        {
            if (amount <= cash)
            {
                if (amount > 0)
                {
                    cash -= amount;

                    EconomyEventArgs e = new EconomyEventArgs();
                    e.amount = amount;
                    OnSpentCash(e);
                }
            }
        }
Beispiel #3
0
        public void GainCash(int amount)
        {
            if (amount < 0)
            {
                amount = 0;
            }
            if (amount > 0)
            {
                cash += amount;

                EconomyEventArgs e = new EconomyEventArgs();
                e.amount = amount;
                OnGainedCash(e);
            }
        }
Beispiel #4
0
        public void DepositBank(int amount)
        {
            if (hasBank)
            {
                if (amount <= cash)
                {
                    if (amount > 0)
                    {
                        cash -= amount;
                        bank += amount;

                        EconomyEventArgs e = new EconomyEventArgs();
                        e.amount = amount;
                        OnDepositedBank(e);
                    }
                }
            }
        }
Beispiel #5
0
        public void WithdrawBank(int amount)
        {
            if (hasBank)
            {
                if (amount <= bank)
                {
                    if (amount > 0)
                    {
                        cash += amount;
                        bank -= amount;

                        EconomyEventArgs e = new EconomyEventArgs();
                        e.amount = amount;
                        OnWithdrewBank(e);
                    }
                }
            }
        }
Beispiel #6
0
 private void EconomyScript_BankInterestReceived(object sender, EconomyEventArgs e)
 {
 }
Beispiel #7
0
 private void EconomyScript_WithdrewBank(object sender, EconomyEventArgs e)
 {
 }
Beispiel #8
0
 private void EconomyScript_DepositedBank(object sender, EconomyEventArgs e)
 {
 }
Beispiel #9
0
 private void EconomyScript_SpentCash(object sender, EconomyEventArgs e)
 {
 }
Beispiel #10
0
 private void EconomyScript_GainedCash(object sender, EconomyEventArgs e)
 {
 }
Beispiel #11
0
 protected virtual void OnBankInterestReceived(EconomyEventArgs e)
 {
     BankInterestReceived?.Invoke(this, e);
 }
Beispiel #12
0
 protected virtual void OnDepositedBank(EconomyEventArgs e)
 {
     DepositedBank?.Invoke(this, e);
 }
Beispiel #13
0
 protected virtual void OnWithdrewBank(EconomyEventArgs e)
 {
     WithdrewBank?.Invoke(this, e);
 }
Beispiel #14
0
 protected virtual void OnSpentCash(EconomyEventArgs e)
 {
     SpentCash?.Invoke(this, e);
 }
Beispiel #15
0
 protected virtual void OnGainedCash(EconomyEventArgs e)
 {
     GainedCash?.Invoke(this, e);
 }