예제 #1
0
        private void CreateBees()
        {
            if (_playAreaSize == null)
            {
                return;
            }

            if (_bees.Count != 0)
            {
                foreach (Bee bee in _bees.Keys.ToList())
                {
                    MoveOneBee(bee);
                }
            }
            else
            {
                int howManyBees = _random.Next(5, 16);

                for (int i = 0; i < howManyBees; i++)
                {
                    Size  beeSize     = new Size(_random.Next(40, 150), _random.Next(40, 150));
                    Point beeLocation = new Point(_random.Next((int)_playAreaSize.Width),
                                                  _random.Next((int)_playAreaSize.Height));
                    Bee bee = new Bee(beeLocation, beeSize);
                    _bees.Add(bee, beeLocation);
                    OnBeeMoved(bee, beeLocation.X, beeLocation.Y);
                }
            }
        }
예제 #2
0
        private void MoveOneBee(Bee bee = null)
        {
            if (_bees.Count() == 0)
            {
                return;
            }

            Bee beeToMove;

            if (bee == null)
            {
                beeToMove = _bees.Keys.ToList()[_random.Next(_bees.Count())];
            }
            else
            {
                beeToMove = bee;
            }

            _bees.Remove(beeToMove);
            Point nonOverlappingPoint = FindNonOverlappingPoint(beeToMove.Size);

            beeToMove.Location = nonOverlappingPoint;
            _bees.Add(beeToMove, nonOverlappingPoint);
            OnBeeMoved(beeToMove, nonOverlappingPoint.X, nonOverlappingPoint.Y);
        }
 public BeeMovedEventArgs(Bee beeThatMoved, double x, double y)
 {
     BeeThatMoved = beeThatMoved;
     X            = x;
     Y            = y;
 }
예제 #4
0
 protected void OnBeeMoved(Bee beeThatMoved, double x, double y)
 {
     BeeMoved?.Invoke(this, new BeeMovedEventArgs(beeThatMoved, x, y));
 }