//public Animator doorAnimator; //public float doorPosition; void Awake() { aircraft = GetComponent <AIAircraftSpawn>(); pilot = GetComponent <AIPilot>(); rb = GetComponent <Rigidbody>(); //doorAnimator = GetComponentInChildren<Animator>(); gearAnimator = GetComponentInChildren <GearAnimator>(); tailHook = GetComponentInChildren <Tailhook>(); catHook = GetComponentInChildren <CatapultHook>(); refuelPort = GetComponentInChildren <RefuelPort>(); wingRotator = pilot.wingRotator; kPlane = GetComponent <KinematicPlane>(); fuelTank = GetComponent <FuelTank>(); waypoint = new Waypoint(); GameObject waypointObject = new GameObject(); waypointObject.AddComponent <FloatingOriginTransform>(); waypoint.SetTransform(waypointObject.transform); tilter = GetComponent <TiltController>(); normalSpeed = pilot.navSpeed; health = GetComponent <Health>(); health.OnDeath.AddListener(OnDeath); }
public override string SITREP() { AIAircraftSpawn aircraftSpawn = (AIAircraftSpawn)unitSpawn; string output = base.SITREP(); output += "Mode: " + aircraftSpawn.aiPilot.commandState.ToString() + "\n"; output += "Heading: " + Mathf.Round(aircraftSpawn.aiPilot.autoPilot.flightInfo.heading) + "\n"; output += "Pitch: " + Mathf.Round(aircraftSpawn.aiPilot.autoPilot.flightInfo.pitch) + "\n"; output += "Velocity: " + Mathf.Round(aircraftSpawn.aiPilot.autoPilot.flightInfo.surfaceSpeed * 1.94384f) + " knots\n"; output += "Altitude: " + Mathf.Round(aircraftSpawn.aiPilot.autoPilot.flightInfo.altitudeASL * 3.28084f) + " feet\n"; output += Mathf.Round(aircraftSpawn.aiPilot.autoPilot.flightInfo.currentInstantaneousG) + "G\n"; return(output); }
void Spawn() { Debug.Log("Spawning CAP F/A-26B"); gameObject = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("FA-26B AI")); gameObject.AddComponent <FloatingOriginTransform>(); transform = gameObject.transform; aircraft = gameObject.GetComponent <AIAircraftSpawn>(); pilot = gameObject.GetComponent <AIPilot>(); rb = gameObject.GetComponent <Rigidbody>(); rb.interpolation = RigidbodyInterpolation.Interpolate; gameObject.GetComponent <KinematicPlane>().SetToKinematic(); Loadout loadout = new Loadout(); loadout.hpLoadout = new string[] { "af_gun", "af_aim9", "af_aim9", "af_amraamRail", "af_amraam", "af_amraam", "af_amraam", "af_amraam", "af_amraamRail", "af_aim9", "af_aim9", "fa26_droptank", "fa26_droptank", "fa26_droptank", "af_tgp", "" }; loadout.cmLoadout = new int[] { 120, 120 }; loadout.normalizedFuel = 1; gameObject.GetComponent <WeaponManager>().EquipWeapons(loadout); }
public override string Command(PilotCommand command, List <string> args) { AIAircraftSpawn aircraftSpawn = (AIAircraftSpawn)unitSpawn; switch (command) { case PilotCommand.Attack: Actor target = GetActor(args[0]); if (target != null) { aircraftSpawn.AttackTarget(GetUnitReference(target)); return("Attacking " + target.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.Cancel: aircraftSpawn.CancelAttackTarget(); return("Canceling attack."); case PilotCommand.Orbit: Actor target2 = GetActor(args[0]); if (target2 != null) { waypoint.GetTransform().position = target2.position; aircraftSpawn.SetOrbitNow(waypoint, 5000, 5000); return("Orbiting " + target2.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.Formation: Actor target3 = GetActor(args[0]); if (target3 != null) { aircraftSpawn.FormOnPilot(GetUnitReference(target3)); return("Following " + target3.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.TakeOff: aircraftSpawn.TakeOff(); return("Taking off!"); case PilotCommand.RTB: aircraftSpawn.RearmAt(new AirportReference(args[0])); return("Landing!"); case PilotCommand.A2ARefuel: RefuelPlane rp = FindRefuelTanker(); if (rp != null) { aircraftSpawn.RefuelWithUnit(GetUnitReference(rp.actor)); return("Refueling!"); } else { return("Found no refuel plane."); } case PilotCommand.Bomb: Actor target4 = GetActor(args[0]); if (target4 != null) { waypoint.GetTransform().position = target4.position; aircraftSpawn.BombWaypoint(waypoint, UnityEngine.Random.Range(0f, 360f), 5, aircraftSpawn.aiPilot.defaultAltitude); return("Bombing " + target4.name + "!"); } else { return("No such target " + args[0] + " exists."); } case PilotCommand.CM: aircraftSpawn.CountermeasureProgram(true, true, 3, 0.2f); return("Deploying CMs!"); case PilotCommand.Flare: aircraftSpawn.CountermeasureProgram(true, false, 3, 0.2f); return("Deploying flares!"); case PilotCommand.Chaff: aircraftSpawn.CountermeasureProgram(false, true, 3, 0.2f); return("Deploying chaff!"); case PilotCommand.JetisonEmpty: wm.MarkEmptyToJettison(); wm.JettisonMarkedItems(); return("Jettisoning empty!"); case PilotCommand.JetisonFuel: wm.MarkDroptanksToJettison(); wm.JettisonMarkedItems(); return("Jettisoning droptanks!"); case PilotCommand.Jetison: wm.MarkAllJettison(); wm.JettisonMarkedItems(); return("Jettisoning all weapons!"); case PilotCommand.Eject: actor.health.Kill(); return("Punch out!"); case PilotCommand.Kamikaze: Actor target5 = GetActor(args[0]); if (target5 != null) { if (target5.role == Actor.Roles.Ground || target5.role == Actor.Roles.GroundArmor || target5.role == Actor.Roles.Ship) { aircraftSpawn.aiPilot.gunRunMinAltitude = float.MinValue; aircraftSpawn.aiPilot.gunGroundMaxRange = 50; aircraftSpawn.aiPilot.minAltClimbThresh = float.MinValue; aircraftSpawn.aiPilot.minAltitude = float.MinValue; aircraftSpawn.aiPilot.obstacleCheckAheadTime = 0; wm.MarkAllJettison(); wm.JettisonMarkedItems(); aircraftSpawn.AttackTarget(GetUnitReference(target5)); return("BANZAI!"); } else { return("Can only kamikaze ground targets."); } } else { return("No such target " + args[0] + " exists."); } default: return(base.Command(command, args)); } }