Britbot
static void Britbot.Group.Switch ( Group  bigGroup,
Group  smallGroup 
) [inline, static]

Given two groups it will rearange the pirates in them so that the big group will have the pirates who are the most addvanced.

Parameters:
bigGroupthe big group
smallGroupthe small group

Definition at line 910 of file Group.cs.

        {
            //if we have no heading to work with
            if (bigGroup.Heading.Norm() == 0)
                return;

            //define the list of pirates of both groups
            List<int> pirateList = new List<int>();

            //add pirates of the biggroup
            pirateList.AddRange(bigGroup.Pirates);
            pirateList.AddRange(smallGroup.Pirates);
            Logger.Write("-------------------------------------Switch",true);
            Logger.Write("Biggroup: " + string.Join(", ", bigGroup.Pirates));
            Logger.Write("smallgroup: " + string.Join(", ", smallGroup.Pirates));
            Logger.Write("pirate list: " + string.Join(", ", pirateList));
            Logger.Write("heading: " + bigGroup.Heading);


            //sort array by allignment with the vector specified
            pirateList.Sort((p1, p2) => -1 * Navigator.ComparePirateByDirection(p1, p2, bigGroup.Heading));

            Logger.Write("pirate list: " + string.Join(", ", pirateList));

            //replace pirates
            bigGroup._hasChanged = true;
            bigGroup.Pirates = new ObservableCollection<int>(pirateList.GetRange(0, bigGroup.Pirates.Count));

            pirateList.RemoveRange(0, bigGroup.Pirates.Count);

            smallGroup._hasChanged = true;
            smallGroup.Pirates = new ObservableCollection<int>(pirateList);

            Logger.Write("Biggroup: " + string.Join(", ", bigGroup.Pirates));
            Logger.Write("smallgroup: " + string.Join(", ", smallGroup.Pirates));
        }