コード例 #1
0
    public override void SetExtendedData(Building building)
    {
        ResidentialBuilding residence = building.gameObject.GetComponent <ResidentialBuilding>();

        residenceClass.text = GetClassString(residence.ResidentClass());
        capacity.text       = residence.HousingCapacity().ToString();
        occupancy.text      = residence.ResidentsCount().ToString();
        quality.text        = residence.housingQuality.ToString();
        rent.text           = residence.Rent().ToString();
    }
コード例 #2
0
    public bool ProcessFinances() //Must be called once per day. Returns false if citizen can pay their expenses.
    {
        long income   = 0;
        long expenses = 0;

        //get paid
        if (workAddress != null)
        {
            income += workAddress.Wages();
        }

        //add rent to expenses
        expenses += homeAddress.Rent();

        //add other life expenses
        switch (citizenClass)
        {
        case CitizenClass.low:
            expenses += lifeStyleExpensesPerDayLow;
            break;

        case CitizenClass.middle:
            expenses += lifeStyleExpensesPerDayMiddle;
            break;

        case CitizenClass.high:
            expenses += lifeStyleExpensesPerDayHigh;
            break;
        }

        expenses -= income; //if income > expenses, result will be negative, which will increase savings.
        savings   = System.Convert.ToInt64(Mathf.Min(savings - expenses, maxSavings));

        if (savings < 0)
        {
            //AssignDebt();
            return(false);
        }

        return(true);
    }