예제 #1
0
        public void Go(Random random)
        {
            Hive.Go(random);
            for (int i = Bees.Count - 1; i >= 0; i--)
            {
                Bee bee = Bees[i];
                bee.Go(random);
                if (bee.CurrentState == Bee.BeeState.Retired)
                {
                    Bees.Remove(bee);
                }
            }

            double totalNectarHarvested = 0;

            for (int i = Flowers.Count - 1; i >= 0; i--)
            {
                Flower flower = Flowers[i];
                flower.Go();
                totalNectarHarvested += flower.NectarHarvested;
                if (!flower.Alive)
                {
                    Flowers.Remove(flower);
                }
            }

            if (totalNectarHarvested > NectarHarvestedPerNewFlower)
            {
                foreach (Flower flower in Flowers)
                {
                    flower.NectarHarvested = 0;
                }
                AddFlower(random);
            }
        }
예제 #2
0
        private void AddBee(Random random)
        {
            beeCount++;
            if (beeCount == MaxNumberOfBees)
            {
                throw new NotImplementedException();
            }

            int random_1 = random.Next(100) - 50;
            int random_2 = random.Next(100) - 50;

            Point startPoint = new Point(locations["Nursery"].X + random_1,
                                         locations["Nursery"].Y + random_2);

            // Once we have a system, we need to add this bee to the system
            Bee newBee = new Bee(beeCount, startPoint, world, this);

            newBee.MessageSender += this.MessageSender;

            //Now we access the World object and we add the bee the List<Bee>
            world.Bees.Add(newBee);
        }