|
Britbot
|
Decides where to move each pirate in the group.
Definition at line 229 of file Group.cs. {
Logger.BeginTime("GetGroupMoves at group " + this.Id);
//inital path finding for this group
Logger.BeginTime("UpdateMap");
Navigator.UpdateMap(this);
Logger.StopTime("UpdateMap");
//Check if the group is formed into structure. If not, get the moves to get into the structure
if (!this.IsFormed())
{
this.Heading = new HeadingVector();
//return for each of our pirate its move
foreach (KeyValuePair<Pirate, Direction> keyValuePair in this.GetStructureMoves(cancellationToken))
yield return keyValuePair;
}
else //if the group is in structure and ready to attack
{
if (this.Target == null)
this.Target = new NoTarget();
Direction master = this.Target.GetDirection(this);
//Convert the list of pirate indexes we have into a list of pirates
List<Pirate> myPirates = this.Pirates.ToList().ConvertAll(p => Bot.Game.GetMyPirate(p));
//Proceed to moving to the target unless it's a NoTarget - then we stay in place
if (this.Target.GetTargetType() != TargetType.NoTarget)
{
//sort the pirates in a way the closest ones to the target will travel first in order to avoid collisions
//return for each pirate the pirate and its direction
foreach (Pirate myPirate in myPirates)
yield return new KeyValuePair<Pirate, Direction>(myPirate, master);
//update heading
this.Heading.adjustHeading(master);
}
else //stay if we are on target
{
//return Direction.NOTHING for all pirates we got
foreach (Pirate myPirate in myPirates)
yield return new KeyValuePair<Pirate, Direction>(myPirate, Direction.NOTHING);
}
}
Logger.StopTime("GetGroupMoves at group " + this.Id);
}
|
1.7.6.1