예제 #1
0
        private void AddBee(Random random)
        {
            beeCount++;

            int r1 = random.Next(100) - 50;
            int r2 = random.Next(100) - 50;

            Point startPoint = new Point(locations["Nursery"].X + r1, locations["Nursery"].Y + r2);
            Bee   newBee     = new Bee(beeCount, startPoint, this, world);

            newBee.MessageSender += this.MessageSender;
            world.Bees.Add(newBee);
        }
예제 #2
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 == 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);
            }
        }