// Start is called before the first frame update void Start() { mChildrenPool = new ChildrenPool[NumberOfChildrenPool]; mAdultPool = new AdultPopulation(StartMale, StartFemale, MaximumPopulation); EventManager.StartListening("update_childdeathrate", HandleChildDeathRateUpdate); EventManager.StartListening("update_maledeathrate", HandleMaleDeathRateUpdate); EventManager.StartListening("update_femaledeathrate", HandleFemaleDeathRateUpdate); EventManager.StartListening("update_foodproductionrate", HandleFoodProductionRateUpdate); EventManager.StartListening("update_foodproductionmodifier", HandleFoodProductionModifierUpdate); EventManager.StartListening("update_occupanylimit", HandleOccupanyLimitUpdate); EventManager.StartListening("update_knowledgerate", HandleKnowledgeRateUpdate); }
public static void ProceedAdult(ref AdultPopulation adultPop, float nomalizedMaleRate, float nomalizedFemaleRate, float nomalizedMaleModifier, float nomalizedFemaleModifier) { int beforePopMale = adultPop.TotalMales; int beforePopFemale = adultPop.TotalFemales; adultPop.ApplyMortalityRate(nomalizedMaleRate, nomalizedFemaleRate, nomalizedMaleModifier, nomalizedFemaleModifier); // @TODO: Maybe introduce enum to detail what kind of death occured or pass two args ? if (beforePopMale - adultPop.TotalMales > 0 || beforePopFemale - adultPop.TotalFemales > 0) { EventManager.TriggerEvent("adult_death", new object[] { beforePopMale - adultPop.TotalMales, beforePopFemale - adultPop.TotalFemales }); } }
public static void ProceedNewYear(int year, ref ChildrenPool[] pools, int poolSize, ref AdultPopulation adultPop, int maximumPopulation, int childrenPopulation, ref float foodAmount) { if (year > 0) { childrenPopulation -= pools[(year - 1) % poolSize].children; pools[(year - 1) % poolSize].finish(); adultPop.AddFemales(pools[(year - 1) % poolSize].female); adultPop.AddMales(pools[(year - 1) % poolSize].male); EventManager.TriggerEvent("gender_commit", new object[] { pools[(year - 1) % poolSize].female, pools[(year - 1) % poolSize].male }); } int numberOfChildren = adultPop.TotalFemales / poolSize; if (adultPop.TotalFemales > 0 && (int)Time.timeSinceLevelLoad % (int)((float)poolSize / (float)(adultPop.TotalFemales % poolSize)) == 0) { numberOfChildren++; } pools[year % poolSize] = new ChildrenPool(Mathf.Min(numberOfChildren, maximumPopulation - adultPop.Total - childrenPopulation)); if (foodAmount < adultPop.Total) { EventManager.TriggerEvent("starvation_comming", new object[] { }); } EventManager.TriggerEvent("children_birth", new object[] { pools[year % poolSize].children }); int death = adultPop.Feed(ref foodAmount); if (foodAmount == 0) { EventManager.TriggerEvent("starvation", new object[] { death }); } }