//Adds to a swarm public void AddToSwarm(AI a, int swarmValue) { loneAi.Remove(a); a.SwarmValue = swarmValue; swarms[swarmValue].AI.Add(a); swarms[swarmValue].Grid.AddPoint(); }
//Creates a swarm public void CreateSwarm(AI a, AI b) { loneAi.Remove(a); loneAi.Remove(b); a.SwarmValue = SwarmCount; b.SwarmValue = SwarmCount; swarms.Add(new Swarm(a, b)); }
//Constructer of the SwarmGrid Ai 'a' holds the center point for the grid public SwarmGrid(int Size, AI a, AI b) { size = Size; //Adds all the points points.Add(new Vector2(a.BoundingRect.X, a.BoundingRect.Y)); AddPoint(); }
//Removes an ai public void RemoveAI(AI a) { if (a.SwarmValue != -1) { swarms[a.SwarmValue].Grid.RemovePoint(); swarms[a.SwarmValue].AI.Remove(a); } else { loneAi.Remove(a); } }
//Adds a lone ai public void AddLoneAI(AI a) { loneAi.Add(a); }
//Initializes the swarm public Swarm(AI a, AI b) { ai.Add(a); ai.Add(b); //Creates a very small velocity to groupVelocity = a.Velocity; //Creates the swarm grid if needed switch (a.Type) { case Type.Square: grid = new SwarmGrid(a.BoundingRect.Width, a, b); break; case Type.Circle: grid = new SwarmGrid(a.BoundingRect.Width, a, b); break; case Type.Triangle: grid = new SwarmGrid(a.BoundingRect.Width, a, b); break; } }