public bool OrderReception(LFAI.Order order) { switch (order.orderType) { case LFAI.OrderType.patrol: if (ship.radar.radarBogies.Count == 0 && !ship.fuelIsBingo) { flightStatus = FlightStatus.patrolling; } else { return(false); } break; case LFAI.OrderType.intercept: if (ship.radar.radarBogies.Count == 0 && !ship.fuelIsBingo) { flightStatus = FlightStatus.intercepting; } else { return(false); } break; case LFAI.OrderType.moveToDefend: if (ship.radar.radarBogies.Count == 0) { flightStatus = FlightStatus.sentry; } else { return(false); } break; case LFAI.OrderType.regroup: if (flightStatus != FlightStatus.retreating) { flightStatusIsChanging = true; flightStatus = FlightStatus.retreating; } break; } return(true); }
private void DefendBase() { if (teamMood == TeamMood.noContact) { 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) { Debug.Log("All don't have WP"); // List<RAMP.Route> routes = new List<RAMP.Route>(formations.Count); Vector3 objectivePos = new Vector3(0f, 0f, 0f); if (objective.objectiveObject) { objectivePos = objective.objectiveObject.transform.position; } bool CW = false; for (int j = 0; j < formations.Count; j++) { LFAI.Order order = new LFAI.Order( LFAI.OrderType.patrol, RAMP.PlanPatrols( objectivePos, likelyHostilePos, 50f, j + 1, CW )); CW = !CW; formations[j].Lead.GetComponent <VesselAI>().GiveOrder(order); formations[j].hasWPs = formations[j].Lead.GetComponent <VesselAI>().ReportHasWp(); /* * for (int i = 0; i < order.route.wpList.Count; i++) * { * * Vector3 debugPoint = new Vector3(order.route.wpList[i].wpCoordinates.x, order.route.wpList[i].wpCoordinates.y,0f); * GameObject bug = Instantiate(debugWPPreset, debugPoint, Quaternion.identity) as GameObject; * bug.transform.parent = bug.transform; * * Debug.Log("WP painted: " + debugPoint); * } */ } } } }
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; } }
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; } }