private void StarvationDeaths(TownHall townHall) { int howManyBeesToKill = random.Next(1, 4); for (int i = 0; i <= howManyBeesToKill; i++) { townHall.KillBee(); } }
public void GiveHoney(TownHall townHall) { for (int i = 0; i < NumberOfWorkers; i++) { double neededHoney = WorkersList.ElementAt(i).HoneyConsumptionRate(); if (!GetHoney(neededHoney)) { StarvationDeaths(townHall); break; } } }
private bool LookForNectarCollectors(TownHall townHall, Job jobToDo, int numberOfShifts) { if (townHall.WorkersList.Count != 0) { for (int i = 0; i < townHall.WorkersList.Count; i++) { Worker worker = townHall.WorkersList.ElementAt(i); if (worker is NectarCollector) { worker = worker as NectarCollector; if (worker.DoThisJob(jobToDo, numberOfShifts)) { MessageBox.Show("Przypisano pracę N/C nr: " + (i + 1).ToString()); return(true); } } } } return(false); }
/// <summary> /// Method which shearches the WorkerList to assign work to the right bee. /// </summary> /// <param name="townHall"></param> /// <param name="jobToDo"></param> /// <param name="numberOfShifts"></param> /// <returns></returns> public bool AssignWork(TownHall townHall, Job jobToDo, int numberOfShifts) { ObservableCollection <Worker> workerList = townHall.WorkersList; if (LookForNectarCollectors(townHall, jobToDo, numberOfShifts)) { return(true); } if (LookForNectarConverter(townHall, jobToDo, numberOfShifts)) { return(true); } for (int i = 0; i < Building.NumberOfWorkers; i++) { Worker worker = workerList.ElementAt(i); if (worker.DoThisJob(jobToDo, numberOfShifts)) { MessageBox.Show("Przypisano pracę pszczole nr: " + (i + 1).ToString()); return(true); } } return(false); }