Пример #1
0
 public SupportGroupShipControl(
     App game,
     TacticalObjective to,
     CombatAI commanderAI,
     TaskGroupShipControl supportTaskGroup)
     : base(game, to, commanderAI)
 {
     this.m_Type         = ShipControlType.SupportGroup;
     this.m_SupportGroup = supportTaskGroup;
 }
Пример #2
0
        private TaskGroupShipControl CreateSupportGroup(
            List <Ship> ships,
            TaskGroupShipControl supportGroup)
        {
            SupportGroupShipControl groupShipControl = new SupportGroupShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, supportGroup);

            foreach (Ship ship in ships)
            {
                groupShipControl.AddShip(ship, (this.m_Type == TaskGroupType.Aggressive || this.m_Type == TaskGroupType.Passive) && TaskGroup.GetTaskTypeFromShip(ship) == TaskGroupType.Civilian);
            }
            return((TaskGroupShipControl)groupShipControl);
        }
Пример #3
0
        public bool IsDesiredGroupTargetTaken(TaskGroupShipControl group, Ship desiredTarget)
        {
            int num = CombatAI.AssessGroupStrength(group.GetShips());

            foreach (TaskGroupShipControl shipControl in this.m_ShipControls)
            {
                if (shipControl != group && shipControl.GroupPriorityTarget == desiredTarget)
                {
                    if (CombatAI.AssessGroupStrength(shipControl.GetShips()) >= num)
                    {
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }
Пример #4
0
 private void AssignShipsToAttackObjective()
 {
     if (this.m_Objective != null && this.m_Objective.m_TargetEnemyGroup == null)
     {
         this.m_RequestedObjectiveType = ObjectiveType.PATROL;
     }
     else if (this.m_Type == TaskGroupType.Police || this.m_CommanderAI.GetAIType() == OverallAIType.PIRATE)
     {
         this.m_ShipControls.Add(this.CreatePursueAttackGroup(this.m_Ships));
     }
     else
     {
         Vector3     objectiveLocation = this.m_Objective.GetObjectiveLocation();
         float       groupRadius       = this.m_Objective.m_TargetEnemyGroup.GetGroupRadius();
         List <Ship> shipList1         = new List <Ship>();
         List <Ship> shipList2         = new List <Ship>();
         int[]       numArray          = new int[14];
         foreach (Ship ship in this.m_Ships)
         {
             float num = groupRadius + TaskGroup.ATTACK_GROUP_RANGE + ship.SensorRange;
             if ((double)(objectiveLocation - ship.Maneuvering.Position).LengthSquared < (double)num * (double)num)
             {
                 shipList1.Add(ship);
                 ++numArray[(int)ship.RealShipClass];
             }
             else
             {
                 shipList2.Add(ship);
             }
         }
         int num1 = CombatAI.AssessGroupStrength(this.m_Objective.m_TargetEnemyGroup.m_Ships);
         int num2 = CombatAI.AssessGroupStrength(shipList1);
         if (num2 > num1 && this.m_Type != TaskGroupType.Civilian)
         {
             List <Ship> list = shipList1.Where <Ship>((Func <Ship, bool>)(x =>
             {
                 if (x.RealShipClass != RealShipClasses.Leviathan)
                 {
                     return(x.RealShipClass == RealShipClasses.Dreadnought);
                 }
                 return(true);
             })).ToList <Ship>();
             foreach (Ship ship in list)
             {
                 shipList1.Remove(ship);
             }
             if (list.Count > 0)
             {
                 this.m_ShipControls.Add(this.CreateStandOffAttackGroup(list));
             }
             if (shipList1.Count > 0)
             {
                 float num3 = 5f;
                 float num4 = Math.Min(Math.Max((float)((double)shipList1.Count / 5.0 - 1.0), 0.0f), 1f) * 5f;
                 float num5 = 0.0f;
                 if ((double)this.m_CommanderAI.AIRandom.NextInclusive(0.0f, num3 + num4 + num5) <= (double)num3)
                 {
                     List <Ship> ships    = new List <Ship>();
                     int         maxValue = Math.Max(shipList1.Count - 5, 0);
                     if (maxValue > 0 && this.m_Type != TaskGroupType.Civilian)
                     {
                         for (int index1 = 1; index1 > 0 && maxValue > 0; maxValue = Math.Max(shipList1.Count - 5, 0))
                         {
                             index1 = this.m_CommanderAI.AIRandom.NextInclusive(0, maxValue);
                             for (int index2 = 0; index2 < index1; ++index2)
                             {
                                 ships.Add(shipList1[index2]);
                             }
                             if (ships.Count != 0)
                             {
                                 foreach (Ship ship in ships)
                                 {
                                     shipList1.Remove(ship);
                                 }
                                 this.m_ShipControls.Add(this.CreateStandOffAttackGroup(ships));
                             }
                             else
                             {
                                 break;
                             }
                         }
                     }
                     this.m_ShipControls.Add(this.CreateFlyByAttackGroup(shipList1));
                 }
                 else if (shipList1.Count > 0)
                 {
                     bool    flag              = false;
                     int     num6              = Math.Min(shipList1.Count, 6);
                     int     val1              = (int)Math.Ceiling((double)shipList1.Count / (double)num6);
                     float   radians           = MathHelper.DegreesToRadians(360f / (float)num6);
                     float   num7              = (float)-((double)radians * 0.5);
                     Vector3 baseGroupPosition = this.GetBaseGroupPosition();
                     Vector3 forward           = objectiveLocation - baseGroupPosition;
                     forward.Y = 0.0f;
                     double num8  = (double)forward.Normalize();
                     Matrix world = Matrix.CreateWorld(baseGroupPosition, forward, Vector3.UnitY);
                     for (int index1 = 0; index1 < num6; ++index1)
                     {
                         float       num9   = index1 % 2 == 0 ? -1f : 1f;
                         float       num10  = (float)Math.Floor((double)(index1 % num6 + 1) * 0.5);
                         Matrix      matrix = Matrix.CreateRotationYPR(num9 * radians * num10 + num7, 0.0f, 0.0f) * world;
                         List <Ship> ships  = new List <Ship>();
                         int         num11  = shipList1.Count <= num6 - index1 ? 1 : Math.Min(val1, shipList1.Count - 1);
                         for (int index2 = 0; index2 < num11; ++index2)
                         {
                             ships.Add(shipList1[index2]);
                         }
                         foreach (Ship ship in ships)
                         {
                             shipList1.Remove(ship);
                         }
                         if (flag)
                         {
                             this.m_ShipControls.Add(this.CreateFlankAttackGroups(ships, matrix.Forward));
                         }
                         else
                         {
                             this.m_ShipControls.Add(this.CreateSurroundAttackGroups(ships, matrix.Forward));
                         }
                         if (shipList1.Count == 0)
                         {
                             break;
                         }
                     }
                 }
             }
         }
         else if (num2 * 2 < num1)
         {
             this.m_ShipControls.Add(this.CreateStandOffAttackGroup(shipList1));
         }
         else
         {
             this.m_ShipControls.Add(this.CreatePursueAttackGroup(shipList1));
         }
         TaskGroupShipControl shipControl1 = this.m_ShipControls[0];
         foreach (Ship ship1 in shipList2)
         {
             bool flag = false;
             foreach (TaskGroupShipControl shipControl2 in this.m_ShipControls)
             {
                 if (shipControl2 != shipControl1)
                 {
                     foreach (Ship ship2 in shipControl2.GetShips())
                     {
                         if ((double)(ship2.Maneuvering.Position - ship1.Maneuvering.Position).LengthSquared < (double)TaskGroup.ATTACK_GROUP_RANGE * (double)TaskGroup.ATTACK_GROUP_RANGE)
                         {
                             shipControl2.AddShip(ship1, false);
                             flag = true;
                             break;
                         }
                     }
                     if (flag)
                     {
                         break;
                     }
                 }
             }
             if (!flag)
             {
                 this.m_ShipControls.Add(this.CreateSupportGroup(new List <Ship>()
                 {
                     ship1
                 }, this.m_ShipControls[0]));
             }
         }
     }
 }