/// <summary> /// create new squadron /// </summary> /// <param name="Colonel">unit that will be formation leader</param> /// <param name="game">game</param> /// <param name="FormationType">formation type to set</param> public Squadron(UnitPilot Colonel,IGame game,FormationTypes FormationType) { isOrdered = true; state = States.Nothing; neededState = States.Nothing; stateChangingTimer = new Timer(0.5f); behaviour = Behaviours.Waiting; reSortingTimer = new Timer(2); List<UnitPilot> pilots = new List<UnitPilot>(); switch (FormationType) { case FormationTypes.Line: formation = new LineFormation(Colonel, pilots, 100, AngleClass.pi * 0.0f); break; case FormationTypes.Bar: formation = new BarFormation(Colonel, pilots, 5, 200, 150, 0); break; case FormationTypes.Stagger: formation = new StaggerFormation(Colonel, pilots, 90, 120); break; } }
/// <summary> /// Sets formation type to parametrized line /// </summary> /// <param name="WidthBetweenUnits">Width between two neirbours. Use from 150 to 250 as a common distance</param> public void SetFormationTypeLine(float WidthBetweenUnits) { isOrdered = true; state = States.Nothing; neededState = States.Nothing; behaviour = Behaviours.Waiting; UnitPilot Colonel = formation.Leader; List<UnitPilot> pilots = new List<UnitPilot>(); foreach (UnitPilot pilot in formation) { pilots.Add(pilot); } formation = new LineFormation(Colonel, pilots, WidthBetweenUnits, 0); }
/// <summary> /// sets a new formation type /// </summary> /// <param name="NewType">new formation type</param> public void SetFormationType(FormationTypes NewType) { isOrdered = NewType!= FormationTypes.Swarm; state = States.Nothing; neededState = States.Nothing; behaviour = Behaviours.Waiting; UnitPilot Colonel = formation.Leader; List<UnitPilot> pilots =new List<UnitPilot>(); foreach (UnitPilot pilot in formation) { pilots.Add(pilot); } switch (NewType) { case FormationTypes.Line: formation = new LineFormation(Colonel, pilots, 100, AngleClass.pi * 0.0f); break; case FormationTypes.Bar: formation = new BarFormation(Colonel, pilots, 5, 200, 150, 0); break; case FormationTypes.Stagger: formation = new StaggerFormation(Colonel, pilots, 90, 120); break; case FormationTypes.Swarm: formation = new SwarmFormation(pilots); break; //case FormationTypes.Custom: formation = new CustomFormation(pilots,0); break; } }