示例#1
0
文件: World.cs 项目: 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);
            }
        }
示例#2
0
文件: Hive.cs 项目: 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);

        }
示例#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);
        }
示例#4
0
文件: Renderer.cs 项目: alkn86/.Net
        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);
        }