示例#1
0
    /// <summary>
    /// Determines if the loans have been paid regularly.
    /// There are consequences to falling behind and slight rewards for keeping
    /// up with payments.
    /// </summary>
    private static void processDueInvoices()
    {
        // go through all loans and raise the threat level if nothing was paid on them
        // while you're at it, apply interest
        Debug.Log($"Processing {loanList.Count} loans");
        foreach (Loan l in loanList)
        {
            CreditorData cd = lenders[l.lender];
            if (!l.paid)
            {
                cd.paid = false;
                cd.threatLevel++;
                paymentStreak = 0;
            }
            l.age++;
            l.paid = false;
            if (!l.inGracePeriod)
            {
                l.total += (float)Math.Round(l.rate * l.total, 2);
            }
            l.inGracePeriod = false;
        }

        // update creditor threat levels if their loans were paid
        foreach (KeyValuePair <string, CreditorData> entry in lenders)
        {
            CreditorData cd = entry.Value;
            if (cd.paid)
            {
                paymentStreak++;
                cd.threatLevel--;
            }
        }
    }
示例#2
0
    /// <summary>
    /// Runs on start. Adds creditors to tracker if not already there,
    /// adds initial debt and sets the interest rate text for that day.
    /// </summary>
    private void Start()
    {
        audioS      = GetComponent <AudioSource>();
        defaultText = dialogText.text;
        creditorPanel.SetActive(false);

        // if StateManager isn't already tracking me by my creditorID, add me
        if (!StateManager.lenders.ContainsKey(creditorId))
        {
            CreditorData cd = new CreditorData(false, baseThreatLevel);
            StateManager.lenders.Add(creditorId, cd);
        }

        // these assumptions imply this is the first visit to the hub, as the player hasn't seen the dungeon entry tutorial (and therefore hasn't been inside the dungeon, so they can't have gone to the hub more than once)
        // when this is the case, accrue initial debt if applicable
        if (!StateManager.sawEntryTutorial && StateManager.cashOnHand <= StateManager.totalDebt && initiallyIndebted)
        {
            debtIsLoud = 0;
            initialDebtType.addLoanInput.text = initialDebtAmount.ToString();
            addDebt(initialDebtType);
            StateManager.cashOnHand -= initialDebtAmount - initialRemainingCash;
            debtIsLoud      = 1;
            dialogText.text = defaultText;
        }

        updateFields();
        Debug.Log($"{creditorId} threat: {threatLevel}, loans: {numberOfLoans}, sum: {loanTotal}");
        // iterator through valid loans that changes loan text in the GUI based on type
        float helperRate, helperCollateral;

        foreach (ValidLoan item in validLoans)
        {
            if (item.loanType != LoanType.Secured)
            {
                helperRate         = (float)Math.Round(item.interestRate * StateManager.rateAdjuster * 100f, 2);
                item.loanData.text = $"@ {helperRate.ToString("N2")}%";
            }
            else
            {
                helperRate         = (float)Math.Round(item.interestRate * StateManager.rateAdjuster * item.collateralRateReduction * 100f, 2);
                helperCollateral   = (float)Math.Round(item.collateralAmountPercent * 100f, 2);
                item.loanData.text = $"@ {helperRate.ToString("N2")}%\n+ {helperCollateral.ToString("N2")}%";
            }
        }
    }