Exemplo n.º 1
0
        private void CreateBees()
        {
            if (PlayAreaSize == Size.Empty)
            {
                return;
            }

            if (_bees.Count() > 0)
            {
                List <Bee> allBees = _bees.Keys.ToList();
                foreach (Bee bee in allBees)
                {
                    MoveOneBee(bee);
                }
            }
            else
            {
                int beeCount = _random.Next(5, 10);
                for (int i = 0; i < beeCount; i++)
                {
                    int   s           = _random.Next(50, 100);
                    Size  beeSize     = new Size(s, s);
                    Point newLocation = FindNonOverlappingPoint(beeSize);
                    Bee   newBee      = new Bee(newLocation, beeSize);
                    _bees[newBee] = new Point(newLocation.X, newLocation.Y);
                    OnBeeMoved(newBee, newLocation.X, newLocation.Y);
                }
            }
        }
Exemplo n.º 2
0
        private void OnBeeMoved(Bee beeThatMoved, double x, double y)
        {
            EventHandler <BeeMovedEventArgs> beeMoved = BeeMoved;

            if (beeMoved != null)
            {
                beeMoved(this, new BeeMovedEventArgs(beeThatMoved, x, y));
            }
        }
Exemplo n.º 3
0
 private void MoveOneBee(Bee bee = null)
 {
     if (_bees.Keys.Count() == 0)
     {
         return;
     }
     if (bee == null)
     {
         int        beeCount = _stars.Count;
         List <Bee> bees     = _bees.Keys.ToList();
         bee = bees[_random.Next(bees.Count)];
     }
     bee.Location = FindNonOverlappingPoint(bee.Size);
     _bees[bee]   = bee.Location;
     OnBeeMoved(bee, bee.Location.X, bee.Location.Y);
 }
Exemplo n.º 4
0
 public BeeMovedEventArgs(Bee beeThatMoved, double x, double y)
 {
     BeeThatMoved = beeThatMoved;
     X            = x;
     Y            = y;
 }