Exemplo n.º 1
0
 /// <summary>
 /// removes the poop
 /// Warning uses Thread.sleep
 /// </summary>
 /// <param name="poop">the poop to remove</param>
 public void RemovePoop(Poop poop)
 {
     if (poops.Contains(poop))
     {
         Thread.Sleep((int)Math.Floor(timeToRemovePoop / Clock.GetSpeed() * 1000));
         poops.Remove(poop);
         poopCount--;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// gets the most importent pen
        /// </summary>
        /// <param name="importants">output the importants of the pen</param>
        /// <returns>the index of the pen</returns>
        private int GetMostImporten()
        {
            ImportantsEnum importants = ImportantsEnum.none;
            int            index      = -1;
            bool           running    = true;

            lock (zoo.AnimalPens)
            {
                for (int i = 0; i < zoo.AnimalPens.Count && running; i++)
                {
                    try
                    {
                        if (!zoo.AnimalPens[i].GetStatus())
                        {
                            // Checks if it is a giraffe
                            if (zoo.AnimalPens[i].GetType() == AnimalEnum.Giraffe)
                            {
                                // Checks if it is time to remove the poop
                                if (importants < ImportantsEnum.very && zoo.AnimalPens[i].GetPoopCount() > 0)
                                {
                                    index      = i;
                                    importants = ImportantsEnum.very;
                                }
                            }
                            // Checks if it is a Elefant
                            else if (importants < ImportantsEnum.high && zoo.AnimalPens[i].GetType() == AnimalEnum.Elefant)
                            {
                                // Checks if is time to remove the poop
                                if (zoo.AnimalPens[i].GetPoopCount() > 0)
                                {
                                    index      = i;
                                    importants = ImportantsEnum.high;
                                }
                            }
                            // Checks if it is a fox or wolf
                            else if (importants < ImportantsEnum.medium && (zoo.AnimalPens[i].GetType() == AnimalEnum.Fox || zoo.AnimalPens[i].GetType() == AnimalEnum.Wolf))
                            {
                                // Checks if it is time to remove the poop
                                if (((ICanidaePen)zoo.AnimalPens[i]).GetPoops().Count > 0)
                                {
                                    Poop poop = (((ICanidaePen)zoo.AnimalPens[i])).GetPoops()[0];
                                    if (poop != null && poop.Laid < (Clock.GetTime() - 12 * Clock.min))
                                    {
                                        index      = i;
                                        importants = ImportantsEnum.medium;
                                    }
                                }
                            }
                            // Checks if it is a rabbit
                            else if (importants < ImportantsEnum.low && zoo.AnimalPens[i].GetType() == AnimalEnum.Rabbit)
                            {
                                // Checks if it is time to remove poop
                                if (importants < ImportantsEnum.very && zoo.AnimalPens[i].GetPoopCount() >= 90)
                                {
                                    index      = i;
                                    importants = ImportantsEnum.low;
                                }
                            }
                        }
                    }
                    catch { }
                }
                if (index != -1)
                {
                    zoo.AnimalPens[index].SetStatus(true);
                }
            }
            return(index);
        }