private void CreateBees() { if (PlayAreaSize == Size.Empty) { return; } if (_bees.Count < 1) { 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); Point newLocation = FindNonOverlappingPoint(beeSize); Bee newBee = new Bee(newLocation, beeSize); _bees[newBee] = new Point(newLocation.X, newLocation.Y); OnBeeMoved(newBee, newLocation.X, newLocation.Y); } } else { List <Bee> bees = _bees.Keys.ToList(); foreach (Bee bee in bees) { MoveOnBee(bee); } } }
private void MoveOnBee(Bee bee = null) { if (_bees.Count == 0) { return; } if (bee == null) { List <Bee> bees = _bees.Keys.ToList(); bee = bees[_random.Next(bees.Count)]; } Point newPoint = FindNonOverlappingPoint(bee.Size); bee.Location = newPoint; _bees[bee] = newPoint; OnBeeMoved(bee, newPoint.X, newPoint.Y); }
private void OnBeeMoved(Bee beeThatMoved, double x, double y) { BeeMoved?.Invoke(this, new BeeMovedEventArgs(beeThatMoved, x, y)); }
public BeeMovedEventArgs(Bee beeThatMoved, double x, double y) { BeeThatMoved = beeThatMoved; X = x; Y = y; }