/// <summary>
        /// Entfernt Obst und gibt die Zelle wieder frei.
        /// </summary>
        /// <param name="nahrung">Das zu entfernenden Obst</param>
        public void EntferneObst(CoreFruit fruit)
        {
            Fruits.Remove(fruit);
            Cell cell = CellSpawnList.Find((x) => x.SpawnedFood == fruit);

            cell.SpawnedFood = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Erntfernt Ameisen die keine Energie mehr haben.
        /// </summary>
        /// <param name="colony">betroffenes Volk</param>
        private void removeAnt(CoreColony colony)
        {
            List <CoreAnt> liste = new List <CoreAnt>();

            for (int i = 0; i < colony.VerhungerteInsekten.Count; i++)
            {
                CoreAnt ant = colony.VerhungerteInsekten[i] as CoreAnt;
                if (ant != null && !liste.Contains(ant))
                {
                    liste.Add(ant);
                    colony.Statistik.StarvedAnts++;
                    PlayerCall.HasDied(ant, CoreKindOfDeath.Starved);
                }
            }

            for (int i = 0; i < colony.EatenInsects.Count; i++)
            {
                CoreAnt ant = colony.EatenInsects[i] as CoreAnt;
                if (ant != null && !liste.Contains(ant))
                {
                    liste.Add(ant);
                    colony.Statistik.EatenAnts++;
                    PlayerCall.HasDied(ant, CoreKindOfDeath.Eaten);
                }
            }

            for (int i = 0; i < colony.BeatenInsects.Count; i++)
            {
                CoreAnt ant = colony.BeatenInsects[i] as CoreAnt;
                if (ant != null)
                {
                    if (!liste.Contains(ant))
                    {
                        liste.Add(ant);
                        colony.Statistik.BeatenAnts++;
                        PlayerCall.HasDied(ant, CoreKindOfDeath.Beaten);
                    }
                }
            }

            for (int i = 0; i < liste.Count; i++)
            {
                CoreAnt ant = liste[i];
                if (ant != null)
                {
                    colony.EntferneInsekt(ant);

                    for (int j = 0; j < Playground.Fruits.Count; j++)
                    {
                        CoreFruit fruit = Playground.Fruits[j];
                        fruit.TragendeInsekten.Remove(ant);
                    }
                }
            }

            colony.VerhungerteInsekten.Clear();
            colony.EatenInsects.Clear();
            colony.BeatenInsects.Clear();
        }
        /// <summary>
        /// Erzeugt ein neues Obsttück.
        /// </summary>
        public void NeuesObst()
        {
            Cell      cell  = findeRohstoffZelle();
            int       wert  = mapRandom.Next(SimulationSettings.Custom.FruitAmountMinimum, SimulationSettings.Custom.FruitAmountMaximum);
            Vector2D  punkt = cell.Position + new Vector2D(mapRandom.Next(cell.Width), mapRandom.Next(cell.Height));
            CoreFruit Fruit = new CoreFruit(punkt.X, punkt.Y, wert);

            Fruits.Add(Fruit);
            cell.SpawnedFood = Fruit;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Prüft ob eine Ameise ein Obsstück sieht.
 /// </summary>
 /// <param name="ameise">betroffene Ameise</param>
 private void ameiseUndObst(CoreAnt ameise)
 {
     for (int i = 0; i < Playground.Fruits.Count; i++)
     {
         CoreFruit obst       = Playground.Fruits[i];
         int       entfernung = CoreCoordinate.BestimmeEntfernungI(ameise.CoordinateBase, obst.CoordinateBase);
         if (ameise.ZielBase != obst && entfernung <= ameise.SichtweiteI)
         {
             PlayerCall.Spots(ameise, obst);
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Prüft ob eine Ameise an ihrem Ziel angekommen ist.
        /// </summary>
        /// <param name="ant">betroffene Ameise</param>
        private static void ameiseUndZiel(CoreAnt ant)
        {
            // Ameisenbau.
            if (ant.ZielBase is CoreAnthill)
            {
                if (ant.GetragenesObstBase == null)
                {
                    ant.ZurückgelegteStreckeI = 0;
                    ant.ZielBase = null;
                    ant.SmelledMarker.Clear();
                    ant.colony.Statistik.CollectedFood += ant.AktuelleLastBase;
                    ant.AktuelleLastBase    = 0;
                    ant.AktuelleEnergieBase = ant.MaximaleEnergieBase;
                    ant.IstMüdeBase         = false;
                }
            }

            // Zuckerhaufen.
            else if (ant.ZielBase is CoreSugar)
            {
                CoreSugar zucker = (CoreSugar)ant.ZielBase;
                ant.ZielBase = null;
                if (zucker.Menge > 0)
                {
                    PlayerCall.TargetReached(ant, zucker);
                }
            }

            // Obststück.
            else if (ant.ZielBase is CoreFruit)
            {
                CoreFruit obst = (CoreFruit)ant.ZielBase;
                ant.ZielBase = null;
                if (obst.Menge > 0)
                {
                    PlayerCall.TargetReached(ant, obst);
                }
            }

            // Insekt.
            else if (ant.ZielBase is CoreInsect)
            {
            }

            // Anderes Ziel.
            else
            {
                ant.ZielBase = null;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Perform call to "Spots(Fruit)" on given ant.
        /// </summary>
        /// <param name="ant">ant</param>
        /// <param name="fruit">fruit</param>
        public static void Spots(CoreAnt ant, CoreFruit fruit)
        {
            AreaChanged(
                null, new AreaChangeEventArgs(ant.colony.Player, Area.SpotsFruit));
            playerRights.PermitOnly();
            ant.NimmBefehleEntgegen = true;
            try {
                ant.SiehtBase(fruit);
            }
            catch (Exception ex) {
                throw new AiException("KI-Fehler in der Sieht(Obst)-Methode", ex);
            }

            ant.NimmBefehleEntgegen = false;
            AreaChanged(
                null, new AreaChangeEventArgs(null, Area.Unknown));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Perform call to "TargetReached(Fruit)" on given ant.
 /// </summary>
 /// <param name="ant">ant</param>
 /// <param name="fruit">fruit</param>
 public static void TargetReached(CoreAnt ant, CoreFruit fruit)
 {
     AreaChanged(
         null,
         new AreaChangeEventArgs(ant.colony.Player, Area.ReachedFruit));
     playerRights.PermitOnly();
     ant.NimmBefehleEntgegen = true;
     try
     {
         ant.ZielErreichtBase(fruit);
     }
     catch (Exception ex)
     {
         throw new AiException(string.Format("{0}: KI-Fehler in der ZielErreicht(Obst)-Methode", ant.colony.Player.Guid), ex);
     }
     ant.NimmBefehleEntgegen = false;
     AreaChanged(
         null, new AreaChangeEventArgs(null, Area.Unknown));
 }
Exemplo n.º 8
0
        /// <summary>
        /// Removes fruit from list.
        /// </summary>
        /// <param name="colony">winning colony</param>
        private void removeFruit(CoreColony colony)
        {
            //List<CoreFruit> gemerktesObst = new List<CoreFruit>();
            for (int j = 0; j < Playground.Fruits.Count; j++)
            {
                CoreFruit obst = Playground.Fruits[j];
                for (int i = 0; i < colony.AntHills.Count; i++)
                {
                    CoreAnthill bau = colony.AntHills[i];
                    if (bau != null)
                    {
                        int entfernung = CoreCoordinate.BestimmeEntfernungI(obst.CoordinateBase, bau.CoordinateBase);
                        if (entfernung <= PLAYGROUND_UNIT)
                        {
                            //gemerktesObst.Add(obst);

                            // Löschen
                            colony.Statistik.CollectedFood += obst.Menge;
                            colony.Statistik.CollectedFruits++;
                            obst.Menge = 0;
                            for (int z = 0; z < obst.TragendeInsekten.Count; z++)
                            {
                                CoreInsect insect = obst.TragendeInsekten[z];
                                if (insect != null)
                                {
                                    insect.GetragenesObstBase = null;
                                    insect.AktuelleLastBase   = 0;
                                    insect.RestStreckeI       = 0;
                                    insect.RestWinkelBase     = 0;
                                    insect.GeheZuBauBase();
                                }
                            }
                            obst.TragendeInsekten.Clear();
                            Playground.EntferneObst(obst);
                            j--;
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Lässt das Insekt ein Obststück nehmen.
        /// </summary>
        /// <param name="obst">Das Obststück.</param>
        internal void NimmBase(CoreFruit obst)
        {
            if (!NimmBefehleEntgegen)
            {
                return;
            }
            if (GetragenesObstBase == obst)
            {
                return;
            }
            if (GetragenesObstBase != null)
            {
                LasseNahrungFallenBase();
            }
            int entfernung = CoreCoordinate.BestimmeEntfernungI(CoordinateBase, obst.CoordinateBase);

            if (entfernung <= SimulationEnvironment.PLAYGROUND_UNIT)
            {
                BleibStehenBase();
                GetragenesObstBase = obst;
                obst.TragendeInsekten.Add(this);
                AktuelleLastBase = colony.Last[CasteIndexBase];
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Gibt an, ob weitere Insekten benötigt werden, um ein Stück Obst zu
 /// tragen.
 /// </summary>
 /// <param name="obst">Obst</param>
 /// <returns></returns>
 internal bool BrauchtNochTräger(CoreFruit obst)
 {
     return(obst.BrauchtNochTräger(colony));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Wird einmal aufgerufen, wenn die Ameise ein Obststück als Ziel hat und
 /// bei diesem ankommt.
 /// </summary>
 /// <param name="obst">Das Obstück.</param>
 internal virtual void ZielErreichtBase(CoreFruit obst)
 {
 }
Exemplo n.º 12
0
 /// <summary>
 /// Wird wiederholt aufgerufen, wenn die Ameise mindstens ein
 /// Obststück sieht.
 /// </summary>
 /// <param name="obst">Das nächstgelegene Obststück.</param>
 internal virtual void SiehtBase(CoreFruit obst)
 {
 }