Ejemplo n.º 1
0
 public Order(OrderType type, RAMP.Route Route, GameObject orderObject)
 {
     orderType = type; route = Route; targetObject = orderObject;
 }
Ejemplo n.º 2
0
 public Order(OrderType type, RAMP.Route Route)
 {
     orderType = type; route = Route;
 }
Ejemplo n.º 3
0
    private void DestroyVessels()
    {
        if (teamMood == TeamMood.noContact)
        {
            if (capitalShips.Count == 0)
            {
                bool allHaveAWP = true;

                // Check if all flights have intercept WPs
                foreach (LFAI.Formation f in formations)
                {
                    if (!f.hasWPs)
                    {
                        allHaveAWP = false;
                    }
                }



                // if there's no contact and even one of the flights has no intercept order, give new to all
                if (!allHaveAWP)
                {
                    // Create list of Flight lead GO-s
                    List <GameObject> leads = new List <GameObject>(formations.Count);
                    foreach (LFAI.Formation f in formations)
                    {
                        leads.Add(f.Lead);
                    }
                    // foreach (GameObject p in players) { leads.Add(p);                   }

                    // Get list of routes i.e wplists
                    List <RAMP.Route> routes = new List <RAMP.Route>(formations.Count);
                    routes = RAMP.PlanDestroyVessels(likelyHostilePos, leads);

                    for (int i = 0; i < formations.Count; i++)
                    {
                        formations[i].Lead.GetComponent <VesselAI>().GiveOrder(new LFAI.Order(LFAI.OrderType.intercept, routes[i]));
                        //Debug.Log(i.ToString() + routes[i].route[0].wpCoordinates + " " + routes[i].route[1].wpCoordinates);
                    }
                }
            }
            else
            {
                bool hasWP = true;

                if (capitalShips[0].GetComponent <VesselAI>().wpList.Count == 0)
                {
                    hasWP = false;
                }

                if (!hasWP)
                {
                    RAMP.Route route = new RAMP.Route(1);

                    RAMP.Waypoint wp = new RAMP.Waypoint(
                        new Vector2(likelyHostilePos.x, likelyHostilePos.y),
                        20f,
                        false,
                        false
                        );

                    route.wpList.Add(wp);

                    capitalShips[0].GetComponent <VesselAI>().GiveOrder(new LFAI.Order(LFAI.OrderType.intercept, route));
                }
            }
        }
        else
        {
        }
    }
Ejemplo n.º 4
0
    private void Escort()
    {
        Debug.Log("Escort");
        switch (teamMood)
        {
        case TeamMood.noContact:

            if (objective.objectiveObject)
            {
                // Give waypoints to the escortable
                if (!objective.objectiveObject.GetComponent <VesselAI>().ReportHasWp())
                {
                    objective.objectiveObject.GetComponent <VesselAI>().teamManager = gameObject.GetComponent <TeamManager>();

                    GameObject civWp = Instantiate(BlueWpPrefab, escortDestination, Quaternion.identity) as GameObject;
                    civWp.transform.parent = civWp.transform;

                    RAMP.Route route = RAMP.GetEscortableRoute(objective.objectiveObject.transform.position, escortDestination, likelyHostilePos);


                    LFAI.Order order = new LFAI.Order(LFAI.OrderType.patrol, route);

                    objective.objectiveObject.GetComponent <VesselAI>().GiveOrder(order);
                }

                // Instantiate the escort formation and attach it to the escortable, if it has none
                if (escortFormation == null)
                {
                    escortFormation = Instantiate(EscortFormationPrefab, objective.objectiveObject.transform.position, Quaternion.identity) as GameObject;
                    escortFormation.transform.parent        = objective.objectiveObject.transform;
                    escortFormation.transform.localPosition = new Vector3(0f, 0f, 0f);
                }

                foreach (LFAI.Formation formation in formations)
                {
                    if (formation.Lead.GetComponent <VesselAI>().ReportFlightStatus() != VesselAI.FlightStatus.sentry)
                    {
                        GameObject orderObj = null;

                        for (int i = 0; i < escortFormation.GetComponent <FormationScript>().positions.Count; i++)
                        {
                            if (!escortFormation.GetComponent <FormationScript>().positions[i].GetComponent <Position>().posOccupied)
                            {
                                orderObj = escortFormation.GetComponent <FormationScript>().positions[i];
                                escortFormation.GetComponent <FormationScript>().positions[i].GetComponent <Position>().posOccupied  = true;
                                escortFormation.GetComponent <FormationScript>().positions[i].GetComponent <Position>().wpAssignedTo = formation.Lead;
                                break;
                            }
                        }

                        LFAI.Order order = new LFAI.Order(LFAI.OrderType.Sentry, orderObj);
                        formation.Lead.GetComponent <VesselAI>().GiveOrder(order);
                    }
                }
            }

            break;

        case TeamMood.offensive:

            break;

        case TeamMood.cautious:

            break;

        case TeamMood.defensive:

            break;
        }
    }
Ejemplo n.º 5
0
    private void AttackBase()
    {
        switch (teamMood)
        {
        case TeamMood.noContact:
            if (capitalShips.Count == 0)
            {
                bool allHaveAWP = true;

                // Check if all flights have intercept WPs
                foreach (LFAI.Formation f in formations)
                {
                    if (!f.hasWPs)
                    {
                        allHaveAWP = false;
                    }
                }

                // if there's no contact and even one of the flights has no intercept order, give new to all
                if (!allHaveAWP)
                {
                    // Create list of Flight lead GO-s
                    List <GameObject> leads = new List <GameObject>(formations.Count);
                    foreach (LFAI.Formation f in formations)
                    {
                        leads.Add(f.Lead);
                    }

                    List <RAMP.Route> routes = RAMP.PlanDestroyVessels(likelyHostilePos, leads);

                    for (int i = 0; i < formations.Count; i++)
                    {
                        formations[i].Lead.GetComponent <VesselAI>().GiveOrder(new LFAI.Order(LFAI.OrderType.intercept, routes[i]));
                    }
                }
            }
            else
            {
                bool hasWP = true;

                if (capitalShips[0].GetComponent <VesselAI>().wpList.Count == 0)
                {
                    hasWP = false;
                }

                if (!hasWP)
                {
                    RAMP.Route route = new RAMP.Route(1);

                    RAMP.Waypoint wp = new RAMP.Waypoint(
                        new Vector2(likelyHostilePos.x, likelyHostilePos.y),
                        20f,
                        false,
                        false
                        );

                    route.wpList.Add(wp);

                    capitalShips[0].GetComponent <VesselAI>().GiveOrder(new LFAI.Order(LFAI.OrderType.intercept, route));

                    // Instantiate the escort formation and attach it to the escortable, if it has none
                    if (escortFormation == null)
                    {
                        escortFormation = Instantiate(EscortFormationPrefab, capitalShips[0].transform.position, Quaternion.identity) as GameObject;
                        escortFormation.transform.parent           = capitalShips[0].transform;
                        escortFormation.transform.localPosition    = new Vector3(0f, 0f, 0f);
                        escortFormation.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
                    }

                    foreach (LFAI.Formation formation in formations)
                    {
                        if (formation.Lead.GetComponent <VesselAI>().ReportFlightStatus() != VesselAI.FlightStatus.sentry)
                        {
                            GameObject orderObj = null;

                            for (int i = 0; i < escortFormation.GetComponent <FormationScript>().positions.Count; i++)
                            {
                                if (!escortFormation.GetComponent <FormationScript>().positions[i].GetComponent <Position>().posOccupied)
                                {
                                    orderObj = escortFormation.GetComponent <FormationScript>().positions[i];
                                    escortFormation.GetComponent <FormationScript>().positions[i].GetComponent <Position>().posOccupied  = true;
                                    escortFormation.GetComponent <FormationScript>().positions[i].GetComponent <Position>().wpAssignedTo = formation.Lead;
                                    break;
                                }
                            }

                            LFAI.Order order = new LFAI.Order(LFAI.OrderType.Sentry, orderObj);
                            formation.Lead.GetComponent <VesselAI>().GiveOrder(order);
                        }
                    }
                }
            }
            break;

        case TeamMood.offensive:

            break;

        case TeamMood.cautious:

            break;

        case TeamMood.defensive:

            break;
        }
    }