Esempio n. 1
0
    public ResidentialBuilding GetResidentialBuildingWithEmptySlot(CitizenClass _class, bool random = true)
    {
        //Make a list of available housing
        List <ResidentialBuilding> availableHousing = new List <ResidentialBuilding>();

        foreach (ResidentialBuilding residence in residentialBuildings)
        {
            if (residence.ResidentClass() == _class &&
                residence.EmptyHousingSlots() > 0)
            {
                //if we are not returning random housing, we return our first hit
                if (!random)
                {
                    return(residence);
                }

                availableHousing.Add(residence);
            }
        }

        //if the count of refs in availableHousing is zero, means no housing is current available
        if (availableHousing.Count < 1) //This check has a side effect that it includes error state (negative numbers), which might be problematic if not handled explicitly.
        {
            return(null);
        }

        //Pick a random residence and return it
        int randomInt = Random.Range(0, availableHousing.Count - 1);

        return(availableHousing[randomInt]);
    }
Esempio n. 2
0
    void GenerateImmigrationCase(CitizenClass _class)
    {
        //for each citizen class:
        //generate citizen.
        //assign home.
        //assign work.

        Citizen newCitizen = GenerateCitizen(_class);

        ResidentialBuilding home = GameManager.buildingsMan.GetResidentialBuildingWithEmptySlot(_class);

        if (home != null) //this shouldn't fail.
        {
            newCitizen.homeAddress = home;
            home.AddResident(newCitizen);
        }
        else
        {
            print("ERROR! Could not assign home to a citizen");
        }

        WorkPlace workPlace = GameManager.buildingsMan.GetEmptyWorkSlot(newCitizen.educationalLevel);

        if (workPlace != null) //contrary to the home case, this is a possibility.
        {
            newCitizen.workAddress = workPlace;
            workPlace.AssignEmployee(newCitizen);
        }

        population.Add(newCitizen);
    }
Esempio n. 3
0
    public int AddToIncomeTaxes(CitizenClass _class, int baseIncome, TaxRates taxRates)
    {
        int newAddition = 0;

        switch (_class)
        {
        case CitizenClass.low:
            newAddition = Mathf.RoundToInt((float)baseIncome * taxRates.low);
            low        += newAddition;
            break;

        case CitizenClass.middle:
            newAddition = Mathf.RoundToInt((float)baseIncome * taxRates.middle);
            middle     += newAddition;
            break;

        case CitizenClass.high:
            newAddition = Mathf.RoundToInt((float)baseIncome * taxRates.high);
            high       += newAddition;
            break;

        default:
            break;
        }

        return(newAddition);
    }
Esempio n. 4
0
    protected string GetClassString(CitizenClass _class)
    {
        switch (_class)
        {
        case CitizenClass.low:
            return("Lower Class");

        case CitizenClass.middle:
            return("Middle Class");

        case CitizenClass.high:
            return("Higher Class");

        default:
            return("N/A");
        }
    }
Esempio n. 5
0
    public ulong AvailableHousing(CitizenClass housingClass)
    {
        switch (housingClass)
        {
        case CitizenClass.low:
            return(resources.totalHousingSlots.low - resources.occuppiedHousingSlots.low);

        case CitizenClass.middle:
            return(resources.totalHousingSlots.middle - resources.occuppiedHousingSlots.middle);

        case CitizenClass.high:
            return(resources.totalHousingSlots.high - resources.occuppiedHousingSlots.high);

        default:
            return(0);
        }
    }
Esempio n. 6
0
    public void IncrementSlotValue(ulong increment, CitizenClass housingClass)
    {
        switch (housingClass)
        {
        case CitizenClass.low:
            low += increment;
            break;

        case CitizenClass.middle:
            middle += increment;
            break;

        case CitizenClass.high:
            high += increment;
            break;

        default:
            break;
        }
    }
Esempio n. 7
0
    public void SetSlotValue(ulong value, CitizenClass housingClass)
    {
        switch (housingClass)
        {
        case CitizenClass.low:
            low = value;
            break;

        case CitizenClass.middle:
            middle = value;
            break;

        case CitizenClass.high:
            high = value;
            break;

        default:
            break;
        }
    }
Esempio n. 8
0
    public void SetRate(CitizenClass _class, float rate) //rate will be clamped to minTaxRate and maxTaxRate
    {
        rate = Mathf.Clamp(rate, minTaxRate, maxTaxRate);

        switch (_class)
        {
        case CitizenClass.low:
            low = rate;
            break;

        case CitizenClass.middle:
            middle = rate;
            break;

        case CitizenClass.high:
            high = rate;
            break;

        default:
            break;
        }
    }
Esempio n. 9
0
    Citizen GenerateCitizen(CitizenClass _class)
    {
        //Housing, work and income will not be set here.

        Citizen newCitizen = new Citizen();

        newCitizen.happiness = new Happiness(50);
        newCitizen.id        = System.Guid.NewGuid();

        //uint ageMin = 18;
        //uint ageMax = 40;
        float[] educationLevelPropability = new float[4] {
            0.25f, 0.5f, 0.75f, 1.0f
        };                                                                           //4 elements conforming to EducationLevel order.
        int averageAge = 35;
        int ageRange   = 10;

        long _savings = 1000;

        //public long savings; //{get; private set;}

        switch (_class)
        {
        case CitizenClass.low:
            educationLevelPropability = new float[4] {
                0.1f, 0.25f, 0.9f, 1.0f
            };                                                                      //Any element following one with 1.0f probability will never happen (check the if-statements bellow)
                                                                                    //This translates to: citizen has 10% chance of being illterate, 15% of having primary education, 75% secondary, 10 tertiar.
            averageAge = 32;
            ageRange   = 14;
            _savings   = Random.Range(800, 1200);
            break;

        case CitizenClass.middle:
            educationLevelPropability = new float[4] {
                0.0f, 0.0f, 0.55f, 1.0f
            };
            averageAge = 35;
            ageRange   = 15;
            _savings   = Random.Range(4000, 6000);
            break;

        case CitizenClass.high:
            educationLevelPropability = new float[4] {
                0.0f, 0.0f, 0.1f, 1.0f
            };
            averageAge = 35;
            ageRange   = 10;
            _savings   = Random.Range(15000, 25000);
            break;

        default:
            break;
        }

        float dieRoll = Random.Range(0.0f, 1.0f);

        if (dieRoll < educationLevelPropability[0])
        {
            newCitizen.educationalLevel = EducationLevel.illiterate;
        }
        else if (dieRoll < educationLevelPropability[1])
        {
            newCitizen.educationalLevel = EducationLevel.primary;
        }
        else if (dieRoll < educationLevelPropability[2])
        {
            newCitizen.educationalLevel = EducationLevel.secondery;
        }
        else if (dieRoll < educationLevelPropability[3])
        {
            newCitizen.educationalLevel = EducationLevel.tertiary;
        }

        dieRoll = Random.Range(0.0f, 1.0f);

        if (dieRoll < 0.5f)
        {
            newCitizen.gender = Gender.male;
        }
        else
        {
            newCitizen.gender = Gender.female;
        }

        newCitizen.birthDay     = new System.DateTime(GameManager.simMan.date.Year - Random.Range(averageAge - ageRange, averageAge + ageRange), Random.Range(1, 12), Random.Range(1, 28));
        newCitizen.savings      = _savings;
        newCitizen.citizenClass = _class;

        return(newCitizen);
    }
Esempio n. 10
0
 public void UpdateOccupiedHousingSlots(ulong count, CitizenClass housingClass)
 {
     resources.occuppiedHousingSlots.SetSlotValue(count, housingClass);
 }
Esempio n. 11
0
 public void UpdateTotalHousingSlots(ulong count, CitizenClass housingClass)
 {
     resources.totalHousingSlots.SetSlotValue(count, housingClass);
 }