public void MakeChildren() { List <Child> temp = new List <Child>(); Child tempChild; foreach (Adult adult in Humans.Where(x => x.IsAdult)) { if (adult.HasPartner) { tempChild = Couple.MakeChild(adult, 5); if (tempChild != null) { temp.Add(tempChild); } } } if (temp.Count > 0) { for (int i = 0; i < temp.Count; i++) { Announcements.Add($"{temp[i].Name} has been born!"); Births++; Humans.Add(temp[i]); } } }
public void KillHuman(int index) { if (Humans.Count > 0) { Announcements.Add($"{Humans[index].Name} has died"); if (Humans[index].IsAdult) { Couple.BreakUp((Adult)Humans[index]); } Humans.RemoveAt(index); Deaths++; } }
public void CreateCouples() { int partnerIndex; bool isCouple; foreach (Adult adult in Humans.Where(x => x.IsAdult)) { do { partnerIndex = Globals.random.Next(Humans.IndexOf(adult), Humans.Count); } while (!Humans[partnerIndex].IsAdult && Humans[partnerIndex].Name != adult.Name); isCouple = Couple.MakeCouple((Adult)adult, (Adult)Humans[partnerIndex], 3); if (isCouple) { Announcements.Add($"{adult.Name} and {Humans[partnerIndex].Name} has become a couple"); } } }