public void CancelTakeOff(Airstrip airStrip)
    {
        if (airStrip.vehicleAttached == null || airStrip.vehicleIsDeploying == false)
        {
            return;
        }

        airStrip.CancelTakeOff();
    }
Example #2
0
    private IEnumerator TakeOffVehicleTactic(Track track)
    {
        Vehicle  interceptor            = null;
        Airstrip interceptorTookOffFrom = null;

        while (track.target != null && track.isLost == false)
        {
            bool isThreat = (Vehicle.sVehicleCanEngage[track.vehicleTypeName][(int)Vehicle.VehicleType.Surf] == true ||
                             Vehicle.sVehicleCanEngage[track.vehicleTypeName][(int)Vehicle.VehicleType.Sub] == true);
            if ((isThreat && Vehicle.sVehicleTypes[track.vehicleTypeName] == VehicleType.Air && autoDealWithAirThreats == false) ||
                (isThreat && Vehicle.sVehicleTypes[track.vehicleTypeName] == VehicleType.Sub && autoDealWithSubThreats == false) ||
                (isThreat == false && Vehicle.sVehicleTypes[track.vehicleTypeName] == VehicleType.Air && autoEngageAirTracks == false) ||
                (isThreat == false && Vehicle.sVehicleTypes[track.vehicleTypeName] == VehicleType.Surf && autoEngageSurfTracks == false) ||
                (isThreat == false && Vehicle.sVehicleTypes[track.vehicleTypeName] == VehicleType.Sub && autoEngageSubTracks == false))
            {
                yield return(new WaitForSeconds(1.0f));

                continue;
            }

            if (UnityEngine.Random.Range(0f, 100f) < 50f)
            {
                if (interceptorTookOffFrom != null && interceptorTookOffFrom.vehicleAttached == interceptor)
                {
                    // We've got the interceptor on the deck awaiting take-off.
                    interceptorTookOffFrom.TakeOff();
                    if (interceptorTookOffFrom.vehicleIsLaunching)
                    {
                        interceptorTookOffFrom = null;
                    }
                }
            }
            if (UnityEngine.Random.Range(0f, 100f) < 40f)
            {
                if (interceptor == null || interceptor.isDead || (interceptor is Aircraft && (interceptor as Aircraft).isRTB))
                {
                    string chosenInterceptor = airstripCtrl.FindBestVehicleFor(track);
                    if (chosenInterceptor != "")
                    {
                        Airstrip airStrip;
                        if (airstripCtrl.PrepareForTakeOff(chosenInterceptor, out airStrip))
                        {
                            interceptor            = airStrip.vehicleAttached;
                            interceptorTookOffFrom = airStrip;
                            yield return(new WaitForSeconds(UnityEngine.Random.Range(0.4f, 0.5f)));
                        }
                    }
                    else
                    {
                        yield return(new WaitForSeconds(5f));
                    }
                }
            }
            yield return(new WaitForSeconds(1f));
        }

        // The track is dead/lost. We should recover our interceptor back to the hangar if it has not taken-off yet.
        if (interceptor != null && interceptorTookOffFrom != null)
        {
            while (true)
            {
                if (interceptorTookOffFrom.vehicleIsDeploying && interceptorTookOffFrom.vehicleIsUndeploying == false && interceptorTookOffFrom.vehicleProgress == 100f)
                {
                    interceptorTookOffFrom.CancelTakeOff();
                    break;
                }

                yield return(new WaitForSeconds(1f));
            }
        }
    }