private void GiveBirthToANiceBoid(object sender, EventArgs e) { BoidControl boid = new BoidControl(Position, GetNewId(), ColonyColor); Boids.Add(boid); World.Map.Children.Add(boid); World.SetBoidAction(boid, Boids, World.WorldStatus); if (IsBoidsCountLimited && Boids.Count >= BoidsCountLimit) (sender as DispatcherTimer).Stop(); //TextBlock tb = World.Map.FindName("debugTextBlock") as TextBlock; //tb.Text = World.Map.Children.Count.ToString(); }
private void AddBoid(BoidControl boid) { BoidList.Add(boid); Map.Children.Add(boid); }
public int AddBoid() { int id = GetNewId(); BoidControl boid = new BoidControl(GetRandomVector(), GetNewId()); AddBoid(boid); return id; }
public void SetBoidAction(BoidControl boid, IList<BoidControl> boidList, WorldStatus status) { if (status == WorldStatus.GlobalFollowPath) boid.Action = new BoidActionFollowPath(GlobalPath); else if (status == WorldStatus.GlobalFlee) boid.Action = new BoidActionFlee(); else if (status == WorldStatus.GlobalSeek) boid.Action = new BoidActionSeek(); else if (status == WorldStatus.GlobalWander || status == WorldLogic.WorldStatus.GlobalFCAS && boid.ID == 1) { boid.Action = new BoidActionWander(); boid.MaxSpeed = 2; } else if (status == WorldLogic.WorldStatus.LookForFood) boid.Action = new BoidActionLookFor(new WorldObjectFood(1), this); else if (status == WorldLogic.WorldStatus.GlobalCohesion) boid.Action = new BoidActionCohesion(boid, boidList, 100); else if (status == WorldStatus.GlobalArrive) boid.Action = new BoidActionArrive(); else if (status == WorldStatus.GlobalSeparate) boid.Action = new BoidActionSeparate(boid, boidList); else if (status == WorldStatus.GlobalAligment) boid.Action = new BoidActionAligment(boid, boidList); else if (status == WorldStatus.GlobalFCAS) boid.Action = new BoidCombinedActionFCAS(boid, boidList, _boidList, 100); }
public int AddBoid(Point p) { int id = GetNewId(); BoidControl boid = new BoidControl(new Vector2(p), GetNewId()); AddBoid(boid); return id; }