/// <summary> /// create new squadron /// </summary> /// <param name="Colonel">unit that will be formation leader</param> /// <param name="game">game</param> public Squadron(UnitPilot Colonel, IGame game) { isOrdered = false; state = States.Nothing; neededState = States.Nothing; stateChangingTimer = new Timer(0.5f); behaviour = Behaviours.Waiting; reSortingTimer = new Timer(2); List<UnitPilot> pilots = new List<UnitPilot>(); formation = new SwarmFormation(pilots); }
/// <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; } }
//CTOR internal UnitPilot(IUnit ControlledUnit, AI AI) { controlledUnit = ControlledUnit; radar = new Radar(controlledUnit.ShootingRadius + 50, controlledUnit, AI); computer = new OnBoardComputer(radar, controlledUnit); dangerRadius = dangerRadiusCoef * ((new Rectangle(GameVector.Zero, controlledUnit.Size, GameVector.UnitX)).GetBoundingCircle.Radius); StandBy(); escapeThreting = true; //SetFlightTgt(controlledUnit.Position + new GameVector(-500, 800)); targetUpdateTime = new Timer(1); relativeSpeedAim = 0; allowedSpeed = 0; AvoidingObstaclesEnabled = true; timer = new Timer(0.05f); SetMaxSpeed(controlledUnit.MaxSpeed); }
public override void Init(int PlayerNumber, IGame Game) { if (PlayerNumber == 0) sign = 1; else sign = -1; AngleForward=1.57f*(1-sign); base.Init(PlayerNumber, Game); cruisers= CreateSquadron(); corvettes= CreateSquadron(); destroyers= CreateSquadron(); for (int i = 0; i < friends.Count; i++) { if (friends[i].Type == ShipTypes.Cruiser) cruisers.AddUnit(friends[i]); else { if (friends[i].Type == ShipTypes.Destroyer) { destroyers.AddUnit(friends[i]); } else { corvettes.AddUnit(friends[i]); } } } center = cruisers.formation.GetMassCenter(); cruisers.SetFormationTypeLine(600); destroyers.SetFormationTypeBar(10,200,150); corvettes.SetFormationTypeLine(600); corvettes.ArrayOrder(center-GameVector.UnitX*1000*sign, AngleForward); cruisers.ArrayOrder(center, AngleForward); destroyers.ArrayOrder(center-GameVector.UnitX * 2000*sign, AngleForward); timer = new Timer(3); Stage = 0; }
/// <summary> /// AI initializing method /// </summary> /// <param name="PlayerNumber">Player number</param> /// <param name="Game">Played game</param> public virtual void Init(int PlayerNumber, IGame Game) { playerNumber = PlayerNumber; friends = new List<UnitPilot>(); enemies = new List<IUnit>(); squadrons = new List<Squadron>(); game = Game; IUnit unit; for (int i = 0; i < game.UnitsCount; i++) { unit = game.GetUnit(i); if (unit.PlayerOwner == playerNumber) { UnitPilot pilot = new UnitPilot(unit, this); friends.Add(pilot); } else enemies.Add(unit); } enemyAnalyzing = new EnemyAnalyzing(enemies); analyzingTimer = new Timer(3); }