Esempio n. 1
0
File: World.cs Progetto: alkn86/.Net
        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);
            }
        }
Esempio n. 2
0
File: Hive.cs Progetto: giokats/.Net
        private void AddBee(Random random)
        {
            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, world, this, messageSender);
            world.Bees.Add(newBee);

        }
Esempio n. 3
0
        private void AddBee(Random random)
        {
            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, world, this, messageSender);

            world.Bees.Add(newBee);
        }
Esempio n. 4
0
        private BeeControl GetBeeControl(Bee bee)
        {
            BeeControl beeControl;

            if (!beeLookup.ContainsKey(bee))
            {
                beeControl = new BeeControl()
                {
                    Width = 40, Height = 40
                };
                beeLookup.Add(bee, beeControl);
                hiveForm.Controls.Add(beeControl);
                beeControl.BringToFront();
            }
            else
            {
                beeControl = beeLookup[bee];
            }
            return(beeControl);
        }