//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);
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        tiltController = GameObject.FindGameObjectWithTag("Player").GetComponent <TiltController>();

        vip = GameObject.FindGameObjectWithTag("VIP");
        this.transform.position = vip.transform.position;
        this.transform.rotation = vip.transform.rotation;
    }
示例#3
0
 private void Awake()
 {
     s_instance = this;
     controller = new TiltController(transform);
     animator   = GetComponent <Animator>();
     state      = GetComponent <PlayerState>();
     effects    = GetComponent <PlayerEffects>();
     manaPool   = new ManaPool(manaFill);
 }
示例#4
0
    // Use this for initialization
    void Start()
    {
        //vip = GameObject.FindGameObjectWithTag("VIP");
        rb   = this.GetComponent <Rigidbody>();
        coll = this.GetComponent <Collider>();
        //vip_Parent = GameObject.FindGameObjectWithTag("VIP Parent").transform;

        player      = GameObject.FindGameObjectWithTag("Player").GetComponent <TiltController>();
        vip_Tracker = GameObject.FindGameObjectWithTag(vip_tracker_tag).GetComponent <VIPTracker>();
        stomper     = GameObject.FindGameObjectWithTag("Stomper_Parent").GetComponent <Stomper>();
    }
示例#5
0
        public void TiltController_GetTiltResults_WhenXRotationInvalid_ThrowsInvalidOperationException(double xRotation)
        {
            // Arrange
            var tiltSensor = new Mock <ITiltSensor>();

            tiltSensor.Setup(_ => _.GetRotationResult()).Returns(new RotationResult {
                XRotation = xRotation
            });

            var testee = new TiltController(tiltSensor.Object);

            // Act
            Action a = () => testee.GetTiltResult();

            // Assert
            a.Should().Throw <InvalidOperationException>();
        }
示例#6
0
        public void TiltController_GetTiltResults_WhenXRotationValid_ReturnsExpectedTiltResult(double xRotation, OrientationInformation expectedOrientationInformation)
        {
            // Arrange
            var tiltSensor = new Mock <ITiltSensor>();

            tiltSensor.Setup(_ => _.GetRotationResult()).Returns(new RotationResult {
                XRotation = xRotation
            });

            var testee = new TiltController(tiltSensor.Object);

            // Act
            var result = testee.GetTiltResult();

            // Assert
            result.OrientationInformation.Should().Be(expectedOrientationInformation);
        }
 private void Awake()
 {
     tiltController = GetComponent <TiltController>();
     lastMessage    = new Message_EngineTiltUpdate(networkUID, 0);
 }
示例#8
0
 public void Reset()
 {
     AllLightsOff();
     TiltController?.Reset();
     MotionComponent?.Stop();
 }
示例#9
0
    public IEnumerator main()
    {
        Vector3 PitchYawRoll = new Vector3();
        bool    tiltC        = false;

        while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady)
        {
            yield return(null);
        }
        foreach (var thing in FindObjectsOfType <AIPilot>())
        {
            Stuff += thing.gameObject.name + " ";
        }
        goOn = true;
        while (GoOn == false)
        {
            Stuff = "";
            foreach (var thing in FindObjectsOfType <AIPilot>())
            {
                Stuff += thing.gameObject.name + " ";
            }
            yield return(null);
        }
        AIPilot toControl = new AIPilot();
        bool    found     = false;

        AIPilot[] wut = FindObjectsOfType <AIPilot>();
        for (int i = 0; i < wut.Length; i++)
        {
            if (wut[i].gameObject.name.Contains(toEdit))
            {
                toControl = wut[i];
                found     = true;
                break;
            }
        }
        if (!found)
        {
            Debug.LogError("Couldn't find AIPilot, defaulting to 0.");
            toControl = wut[0];
        }
        toControl.commandState = AIPilot.CommandStates.Override;
        foreach (var thing in FindObjectsOfType <AIPilot>())
        {
            Debug.Log(thing);
        }
        GameObject targetVehicle = toControl.gameObject;

        if (targetVehicle != null)
        {
            Debug.Log("GOT THE TARGET VEHICLE!!!");
        }
        TiltController TC = targetVehicle.GetComponent <TiltController>();

        if (TC != null)
        {
            tiltC = true;
        }
        Transform             transform = FlightSceneManager.instance.playerActor.transform;
        FloatingOriginShifter playerfos = transform.GetComponent <FloatingOriginShifter>();

        if (playerfos)
        {
            playerfos.enabled = false;
        }
        GameObject empty       = new GameObject();
        GameObject Cammy       = Instantiate(empty, transform.position, Quaternion.identity);
        Actor      targetActor = targetVehicle.GetComponent <Actor>();
        //  targetActor.team = Teams.Allied;
        Camera         CammyCam = Cammy.AddComponent <Camera>();
        CameraFollowMe cam      = Cammy.AddComponent <CameraFollowMe>();

        cam.targets = new List <Transform>();
        Debug.Log("Target list created.");
        cam.AddTarget(targetActor.transform);
        Debug.Log("Added our actor to the target.");
        if (targetActor.transform == null)
        {
            Debug.LogError("Actor transform is null.");
        }
        if (cam.gameObject == null)
        {
            Debug.LogError("cam gameObject is null.");
        }
        cam.cam = CammyCam;
        cam.gameObject.SetActive(true);
        cam.AddTarget(FlightSceneManager.instance.playerActor.transform);
        GameSettings.SetGameSettingValue("HIDE_HELMET", true, true);
        Debug.Log("Cam should be set.");
        VehicleInputManager control = targetVehicle.AddComponent <VehicleInputManager>();
        AutoPilot           AP      = targetVehicle.GetComponent <AutoPilot>();

        control.pyrOutputs = AP.outputs;
        AP.steerMode       = AutoPilot.SteerModes.Aim;
        List <ModuleEngine> Engines = AP.engines;

        AP.enabled = false;
        control.wheelSteerOutputs = targetVehicle.GetComponents <WheelsController>();
        GearAnimator gear = toControl.gearAnimator;

        targetVehicle.GetComponent <AIPilot>().enabled = false;
        Radar        targetRadar  = toControl.detectionRadar;
        LockingRadar lTargetRadar = new LockingRadar();

        if (targetRadar != null)
        {
            targetRadar.teamsToDetect = Radar.DetectionTeams.Both;
            lTargetRadar = toControl.lockingRadar;
            radarActive  = true;
        }
        if (lTargetRadar != null)
        {
            lockingRadar = true;
        }
        foreach (var thing in targetVehicle.GetComponents(typeof(Component)))
        {
            Debug.Log(thing);
        }
        WeaponManager wm = targetVehicle.GetComponent <WeaponManager>();

        if (wm != null)
        {
            hasWM = true;
            wm.SetMasterArmed(true);
            foreach (var internalBays in wm.internalWeaponBays)
            {
                internalBays.openOnAnyWeaponMatch = true;
            }
        }
        MissileDetector    rwr = toControl.rwr;
        MeasurementManager MM  = MeasurementManager.instance;
        float            t     = 0f;
        float            v     = 0f;
        CameraScreenshot CS    = new CameraScreenshot();

        PitchYawRoll = new Vector3(0f, 0f, 0f);
        FlightInfo FI = targetActor.flightInfo;
        // RefuelPlane rPlane = targetVehicle.GetComponent<RefuelPlane>();
        float x          = 0f;
        float y          = 0f;
        float z          = 0f;
        float flaps      = 0f;
        float brakes     = 0f;
        int   idx        = -1;
        int   p          = 2;
        float headingNum = 0;
        bool  locked     = false;
        bool  tDep       = false;
        bool  hDep       = false;

        if (toControl.tailHook != null)
        {
            tDep = toControl.tailHook.isDeployed;
        }
        if (toControl.catHook != null)
        {
            hDep = toControl.catHook.deployed;
        }
        infAmmo iA = targetVehicle.AddComponent <infAmmo>();

        iA.wepMan  = wm;
        iA.enabled = false;
        Actor lockSelection = new Actor();

        Debug.Log("Controlling " + targetVehicle);
        while (true)
        {
            // Pitch Yaw Roll controls
            if (Input.GetKey(KeyCode.S))
            {
                x = -1f;
            }
            else if (Input.GetKey(KeyCode.W))
            {
                x = 1f;
            }
            else
            {
                x = 0f;
            }
            if (Input.GetKey(KeyCode.A))
            {
                y = -1f;
            }
            else if (Input.GetKey(KeyCode.D))
            {
                y = 1f;
            }
            else
            {
                y = 0f;
            }
            if (Input.GetKey(KeyCode.E))
            {
                z = -1f;
            }
            else if (Input.GetKey(KeyCode.Q))
            {
                z = 1f;
            }
            else
            {
                z = 0f;
            }

            // Tilt Controller
            if (Input.GetKey(KeyCode.Z))
            {
                if (v >= 90)
                {
                }
                else
                {
                    if (TC)
                    {
                        v += 1;
                        TC.SetTiltImmediate(v);
                    }
                }
            }
            if (Input.GetKey(KeyCode.X))
            {
                if (v <= 0)
                {
                }
                else
                {
                    if (tiltC)
                    {
                        v -= 1;
                        TC.SetTiltImmediate(v);
                    }
                }
            }

            // Screen Shot
            if (Input.GetKeyDown(KeyCode.L))
            {
                try
                {
                    if (CS.cam == null)
                    {
                        CS.cam = CameraFollowMe.instance.cam;
                        Debug.Log("NULL in assigning cam to CS");
                    }
                    CS.Screenshot();
                }
                catch (NullReferenceException)
                {
                    Debug.Log("This dude really tried screenshotting without having the debug cam on, LOSER!");
                }
            }

            // WeaponManager code
            if (wm != null)
            {
                if (Input.GetKeyDown(KeyCode.R))
                {
                    wm.CycleActiveWeapons();
                }
                if (iA.enabled)
                {
                    if (Input.GetKey(KeyCode.Space))
                    {
                        if (wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML)
                        {
                            wm.SingleFire();
                        }
                        else
                        {
                            wm.StartFire();
                        }
                    }
                    if (Input.GetKeyUp(KeyCode.Space))
                    {
                        if (!(wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML))
                        {
                            wm.EndFire();
                        }
                    }
                }
                else
                {
                    if (Input.GetKeyDown(KeyCode.Space))
                    {
                        if (wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML)
                        {
                            wm.SingleFire();
                        }
                        else
                        {
                            wm.StartFire();
                        }
                    }
                    if (Input.GetKeyUp(KeyCode.Space))
                    {
                        if (!(wm.currentEquip is HPEquipIRML || wm.currentEquip is HPEquipRadarML))
                        {
                            wm.EndFire();
                        }
                    }
                }
                Weapon = wm.currentEquip.name;
                Ammo   = wm.currentEquip.GetCount().ToString();
            }

            // Gear Toggle
            if (Input.GetKeyDown(KeyCode.G))
            {
                if (gear != null)
                {
                    gear.Toggle();
                }
            }

            // Thrrottle code
            if (Input.GetKey(KeyCode.LeftControl)) // Increase
            {
                if (t > 0)
                {
                    t -= 0.0125f;
                }
            }
            if (Input.GetKey(KeyCode.LeftShift)) // Decrease
            {
                if (t < 1)
                {
                    t += 0.0125f;
                }
            }

            // CMS dispenser
            if (Input.GetKey(KeyCode.C))
            {
                toControl.FireFlares();
                toControl.FireChaff();
            }

            // Radar code
            if (targetRadar != null)
            {
                if (lTargetRadar != null)
                {
                    if (Input.GetKeyDown(KeyCode.M)) // Move right in the array
                    {
                        idx += 1;
                        if (idx > targetRadar.detectedUnits.Count - 1)
                        {
                            idx = targetRadar.detectedUnits.Count - 1;
                        }
                        if (targetRadar.detectedUnits.Count > 0)
                        {
                            lockSelection = targetRadar.detectedUnits[idx];
                            sRadarTargets = lockSelection.actorName;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.N)) // Move left in the array
                    {
                        idx -= 1;
                        if (idx < 0)
                        {
                            idx = 0;
                        }
                        if (targetRadar.detectedUnits.Count > 0)
                        {
                            lockSelection = targetRadar.detectedUnits[idx];
                            sRadarTargets = lockSelection.actorName;
                        }
                    }
                    if (Input.GetKeyDown(KeyCode.J)) // Lock
                    {
                        if (!locked)
                        {
                            if (targetRadar.detectedUnits.Count > 0)
                            {
                                if (idx >= 0)
                                {
                                    if (lTargetRadar.GetLock(lockSelection))
                                    {
                                        lRadarTargets = lockSelection.ToString();
                                        locked        = !locked;
                                    }
                                }
                            }
                        }
                        else
                        {
                            lTargetRadar.Unlock();
                            lRadarTargets = "No lock";
                            locked        = !locked;
                        }
                    }
                    if (!lTargetRadar.IsLocked())
                    {
                        lRadarTargets = "Lock Dropped";
                        if (locked)
                        {
                            locked = !locked;
                        }
                    }
                }
                radarTargets = "";
                foreach (var thing in targetRadar.detectedUnits)
                {
                    headingNum = Mathf.Round(VectorUtils.SignedAngle(Vector3.forward, thing.transform.forward, Vector3.right));
                    if (headingNum < 0)
                    {
                        headingNum += 360;
                    }
                    radarTargets += thing + " " + headingNum.ToString() + " " + MM.ConvertedDistance(Mathf.Round((targetRadar.transform.position - thing.position).magnitude)).ToString() + " " + DistanceLabel() + " " + MM.ConvertedAltitude(Mathf.Round((WaterPhysics.GetAltitude(thing.position)))).ToString() + " " + AltitudeLabel() + "\n";
                }
            }

            // RWR code
            if (rwr != null)
            {
                Missiles = "";
                if (rwr.missileDetected)
                {
                    MissileDetected = true;
                    foreach (var Missile in rwr.detectedMissiles)
                    {
                        headingNum = Mathf.Round(VectorUtils.SignedAngle(Vector3.forward, Missile.transform.forward, Vector3.right));
                        if (headingNum < 0)
                        {
                            headingNum += 360;
                        }
                        Missiles += Missile.ToString() + " " + headingNum.ToString() + " " + MM.ConvertedDistance(Mathf.Round((rwr.transform.position - Missile.transform.position).magnitude)).ToString() + " " + DistanceLabel() + " " + MM.ConvertedAltitude(Mathf.Round((WaterPhysics.GetAltitude(Missile.transform.position)))).ToString() + " " + AltitudeLabel() + "\n";
                    }
                }
            }

            // Flaps
            if (Input.GetKeyDown(KeyCode.F))
            {
                if (flaps == 0f)
                {
                    flaps = .5f;
                }
                else if (flaps == .5f)
                {
                    flaps = 1f;
                }
                else
                {
                    flaps = 0f;
                }
                foreach (var thing in toControl.autoPilot.outputs)
                {
                    thing.SetFlaps(flaps);
                }
            }

            // Brakes
            if (Input.GetKeyDown(KeyCode.B))
            {
                if (brakes == 0f)
                {
                    brakes = 1f;
                }
                else
                {
                    brakes = 0f;
                }
                foreach (var thing in toControl.autoPilot.outputs)
                {
                    thing.SetBrakes(brakes);
                }
            }

            // Wing Folding
            if (Input.GetKeyDown(KeyCode.K))
            {
                if (toControl.wingRotator != null)
                {
                    if (toControl.wingRotator.deployed)
                    {
                        toControl.wingRotator.SetDefault();
                    }
                    else
                    {
                        toControl.wingRotator.SetDeployed();
                    }
                }
            }

            // Tail Hook
            if (Input.GetKeyDown(KeyCode.H))
            {
                if (toControl.tailHook != null)
                {
                    if (tDep)
                    {
                        toControl.tailHook.RetractHook();
                        tDep = !tDep;
                    }
                    else
                    {
                        toControl.tailHook.ExtendHook();
                        tDep = !tDep;
                    }
                }
            }

            //  Launch Bar
            if (Input.GetKeyDown(KeyCode.T))
            {
                if (toControl.catHook != null)
                {
                    if (hDep)
                    {
                        toControl.catHook.Retract();
                        hDep = !hDep;
                    }
                    else
                    {
                        toControl.catHook.Extend();
                        hDep = !hDep;
                    }
                }
            }

            // Debug
            if (Input.GetKeyDown(KeyCode.O))
            {
                iA.enabled = !iA.enabled;
            }

            // Misc Stuff
            PitchYawRoll.Set(x, y, z);
            control.SetJoystickPYR(PitchYawRoll);
            foreach (ModuleEngine Engine in Engines)
            {
                Engine.SetThrottle(t);
            }
            headingNum = VectorUtils.SignedAngle(Vector3.forward, targetActor.transform.forward, Vector3.right);
            if (headingNum < 0f)
            {
                headingNum += 360f;
            }
            heading  = FI.heading.ToString();
            altitude = MM.ConvertedAltitude(FI.altitudeASL).ToString() + " " + AltitudeLabel();
            speed    = MM.ConvertedSpeed(FI.surfaceSpeed).ToString() + " " + SpeedLabel();
            yield return(null);
        }
    }