예제 #1
0
        private void StarvationDeaths(TownHall townHall)
        {
            int howManyBeesToKill = random.Next(1, 4);

            for (int i = 0; i <= howManyBeesToKill; i++)
            {
                townHall.KillBee();
            }
        }
예제 #2
0
 public void GiveHoney(TownHall townHall)
 {
     for (int i = 0; i < NumberOfWorkers; i++)
     {
         double neededHoney = WorkersList.ElementAt(i).HoneyConsumptionRate();
         if (!GetHoney(neededHoney))
         {
             StarvationDeaths(townHall);
             break;
         }
     }
 }
예제 #3
0
 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);
 }
예제 #4
0
        /// <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);
        }