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, 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); } } }
private void CreateBees() { if (_playAreaSize == Size.Empty) { return; } if (_bees.Count > 0) { for (int i = 0; i < _bees.Count; i++) { MoveOneBee(_bees.ElementAt(i).Key); } } else { int numberOfBees = _random.Next(5, 15); for (int i = 0; i < numberOfBees; i++) { int size = _random.Next(40, 150); Size beeSize = new Size(size, size); Point beeLocation = FindNonOverlappingPoint(beeSize); Bee bee = new Bee(beeLocation, beeSize); _bees.Add(bee, bee.Location); OnBeeMoved(bee, bee.Location.X, bee.Location.Y); } } }
private void CreateBees() { // If the play area is empty, return. If there are already bees, move each of them. // Otherwise, create between 5 and 15 randomly sized bees (40 to 150 pixels), add // it to the _bees collection, and fire the BeeMoved event. if (PlayAreaSize.IsEmpty) { return; } if (_bees.Count > 0) { List <Bee> bees = _bees.Keys.ToList(); foreach (Bee bee in bees) { MoveOneBee(bee); } } else { int numberOfBees = _random.Next(5, 10); for (int i = 0; i < numberOfBees; i++) { int s = _random.Next(50, 100); Size beeSize = new Size(s, s); Point beeLocation = FindNonOverlappingPoint(beeSize); Bee bee = new Bee(beeLocation, beeSize); _bees.Add(bee, new Point(beeLocation.X, beeLocation.Y)); OnBeeMoved(bee, beeLocation.X, beeLocation.Y); } } }
protected void OnBeeMoved(Bee beeThatMoved, double x, double y) { EventHandler<BeeMovedEventArgs> beeMoved = BeeMoved; if (beeMoved != null) { beeMoved(this, new BeeMovedEventArgs(beeThatMoved, x, y)); } }
private void OnBeeMoved(Bee beeThatMoved, double x, double y) { EventHandler <BeeMovedEventArgs> beeMoved = BeeMoved; if (beeMoved != null) { beeMoved(this, new BeeMovedEventArgs(beeThatMoved, x, y)); } }
private void CreateABee() { int size = _random.Next(40, 150); Size beeSize = new Size(size, size); Point beeLocation = FindNonOverlappingPoint(beeSize); Bee newBee = new Bee(beeLocation, beeSize); _bees.Add(newBee, beeLocation); OnBeeMoved(newBee, beeLocation.X, beeLocation.Y); }
private void MoveOneBee(Bee bee = null) { if (_bees.Keys.Count() == 0) { return; } 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); }
private void MoveOneBee(Bee bee = null) { if (_bees.Keys.Count == 0) { return; } else if (bee == null) { bee = _bees.Keys.ToList()[_random.Next(_bees.Count)]; } bee.Location = FindNonOverlappingPoint(bee.Size); _bees[bee] = bee.Location; OnBeeMoved(bee, bee.Location.X, bee.Location.Y); }
private void MoveOneBee(Bee bee = null) { if (_bees.Count == 0) { return; } if (bee == null) { bee = _bees.ElementAt(_random.Next(0, _bees.Count)).Key; } _bees.Remove(bee); bee.Location = FindNonOverlappingPoint(bee.Size); _bees.Add(bee, bee.Location); OnBeeMoved(bee, bee.Location.X, bee.Location.Y); }
private void MoveOneBee(Bee bee = null) { // If there are no bees, return. If the bee parameter is null, choose a random bee, // otherwise use the bee argument. Then find a new non-overlapping point, update the bee's // location, update the _bees collection, and then fire the OnBeeMoved event. if (_bees.Keys.Count() == 0) { return; } if (bee == null) { bee = _bees.Keys.ToList()[_random.Next(_bees.Keys.Count())]; } bee.Location = FindNonOverlappingPoint(bee.Size); _bees[bee] = bee.Location; OnBeeMoved(bee, bee.Location.X, bee.Location.Y); }
private void MoveOneBee(Bee bee = null) { int beesCount = _bees.Keys.Count(); if (beesCount == 0) { return; } if (bee == null) { List <Bee> beesList = _bees.Keys.ToList(); int randomNumber = _random.Next(beesCount); bee = beesList[randomNumber]; } Point newLocation = FindNonOverlappingPoint(bee.Size); bee.Location = newLocation; _bees[bee] = bee.Location; OnBeeMoved(bee, newLocation.X, newLocation.Y); }
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, 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); } } }
public BeeMovedEventArgs(Bee beeThatMoved, double x, double y) { BeeThatMoved = beeThatMoved; X = x; Y = y; }