Esempio n. 1
0
 private void CreateBees()
 {
     if (PlayAreaSize == Size.Empty)
     {
         return;                            //if empty then end executing method
     }
     if (_bees.Count() > 0)
     {
         List <Bee> allBees = _bees.Keys.ToList();
         foreach (Bee bee in allBees)
         {
             MoveOneBee(bee);//Moving Bee
         }
     }
     else
     {//Creating new Bees
         int beeCount = random.Next(5, 16);
         for (int i = 0; i < beeCount; i++)
         {
             int   s           = random.Next(40, 151);
             Size  beeSize     = new Size(s, s);                      //setting size of Bee
             Point newLocation = FindNonOverLappingPoint(beeSize);    //looking for good placement
             Bee   newBee      = new Bee(newLocation, beeSize);
             _bees[newBee] = new Point(newLocation.X, newLocation.Y); //adding location of bee to dict
             OnBeeMoved(newBee, newLocation.X, newLocation.Y);        //calling  event
         }
     }
 }
Esempio n. 2
0
        private void OnBeeMoved(Bee beeThatMoved, double x, double y)//event
        {
            EventHandler <BeeMovedEventArgs> beeMoved = BeeMoved;

            if (BeeMoved != null)
            {
                beeMoved(this, new BeeMovedEventArgs(beeThatMoved, x, y));
            }
        }
Esempio n. 3
0
 private void MoveOneBee(Bee bee = null)
 {
     if (_bees.Keys.Count() == 0)
     {
         return;                         //if there is no bees
     }
     if (bee == null)
     {//choose random bee
         List <Bee> bees = _bees.Keys.ToList();
         bee = bees[random.Next(bees.Count)];
     }
     bee.Location = FindNonOverLappingPoint(bee.Size); //finding spot to move on
     _bees[bee]   = bee.Location;                      //update Bee pos
     OnBeeMoved(bee, bee.Location.X, bee.Location.Y);  //calling event
 }
Esempio n. 4
0
 public BeeMovedEventArgs(Bee beeThatMoved, double x, double y)
 {
     BeethatMoved = beeThatMoved;
     X            = x;
     Y            = y;
 }