Exemple #1
0
 void Awake()
 {
     // Check to see if controls have already been setup, if not then create them.
     // This is really only for use when using the Unity Editor since it's more then likely
     // that you havn't gone through the splash screen which is where the controls are setup
     if (!ControlsManager.bHasLoadedControls)
     {
         ControlsManager.SetDefaultControls();
     }
     IM.Initialize();
 }
Exemple #2
0
    public static void SetDefaultControls()
    {
        controls.Clear();
        IM.Initialize();

        controls.AddRange(new Control[]
        {
            new ActionControl("Thrust", Scope.All)
            .AddBinding(Binding.Space)
            .AddBinding(Binding.JoystickButton0),     // A
            new ActionControl("Fire", Scope.All)
            .AddBinding(Binding.LeftShift)
            .AddBinding(Binding.JoystickButton2),     // X
            new ActionControl("Absorb", Scope.All)
            .AddBinding(Binding.LeftControl)
            .AddBinding(Binding.JoystickButton1),     // B
            new ActionControl("CameraToggle", Scope.All)
            .AddBinding(Binding.C)
            .AddBinding(Binding.JoystickButton3),     // Y
            new ActionControl("LookBehind", Scope.All)
            .AddBinding(Binding.X)
            .AddBinding(Binding.JoystickButton4),     // Shoulder Left
            new ActionControl("Special", Scope.All)
            .AddBinding(Binding.Z)
            .AddBinding(Binding.JoystickButton5),     // Shoulder Right
            new ActionControl("Pause", Scope.All)
            .AddBinding(Binding.Escape)
            .AddBinding(Binding.JoystickButton7),     // Start
            new AxisControl("Steer")
            .AddBinding(Binding.LeftArrow, -1f)
            .AddBinding(Binding.RightArrow, 1f)
            .AddBinding(Binding.LeftX, 1f)
            .AddBinding(Binding.DPadLeft, -1f)
            .AddBinding(Binding.DPadRight, 1f),
            new AxisControl("Pitch")
            .AddBinding(Binding.DownArrow, -1f)
            .AddBinding(Binding.UpArrow, 1f)
            .AddBinding(Binding.LeftY, 1f)
            .AddBinding(Binding.DPadDown, -1f)
            .AddBinding(Binding.DPadUp, 1),
            new AxisControl("LeftAirbrake")
            .AddBinding(Binding.Q, -1f)
            .AddBinding(Binding.TriggerLeft, -1f),
            new AxisControl("RightAirbrake")
            .AddBinding(Binding.E, 1f)
            .AddBinding(Binding.TriggerRight, 1f)
        });

        IM.controls.AddRange(controls);
    }
Exemple #3
0
    private void GetPlayerInput()
    {
        // Get the input axis
        inputSteer         = IM.GetAxis("Steer").value;
        inputPitch         = IM.GetAxis("Pitch").value;
        inputLeftAirbrake  = IM.GetAxis("LeftAirbrake").value;
        inputRightAirbrake = IM.GetAxis("RightAirbrake").value;

        // Get whether the player is accelerating
        btnThruster = false;
        if (IM.GetAction("Thrust").state == State.Held)
        {
            btnThruster = true;
        }

        // Reset sideshift inputs
        ssLeft  = false;
        ssRight = false;

        // Left airbrake tap
        if ((inputLeftAirbrake != 0 && inputRightAirbrake == 0) && !ssLeftPressed)
        {
            ssLeft        = true;
            ssLeftPressed = true;
            ssRight       = false;
        }

        // Right airbrake tap
        if ((inputRightAirbrake != 0 && inputLeftAirbrake == 0) && !ssRightPressed)
        {
            ssRight        = true;
            ssRightPressed = true;
            ssLeft         = false;
        }

        // No airbrake taps
        if (inputLeftAirbrake == 0 && inputRightAirbrake == 0)
        {
            ssLeftPressed  = false;
            ssRightPressed = false;
        }

        SideshiftInput();

        // Vibrate the controller when starting to thrust
        if (IM.GetAction("Thrust").state == State.Down)
        {
            GetComponent <FFManager>().timerMotor    = 1.2f;
            GetComponent <FFManager>().vibLeftMotor  = 0.4f;
            GetComponent <FFManager>().vibRightMotor = 0.4f;
        }

        // Thruster Events
        if (IM.GetAction("Thrust").state == State.Down)
        {
            GetComponent <ShipAVManager>().ThrusterDown();
        }

        if (IM.GetAction("Thrust").state == State.Up)
        {
            GetComponent <ShipAVManager>().ThrusterUp();
            GetComponent <FFManager>().timerMotor    = 1.2f;
            GetComponent <FFManager>().vibLeftMotor  = 0.3f;
            GetComponent <FFManager>().vibRightMotor = 0.3f;
        }

        // Braking vibration
        if (GetComponent <ShipSimulator>().bShipIsBraking)
        {
            GetComponent <FFManager>().timerMotor    = 1.2f;
            GetComponent <FFManager>().vibLeftMotor  = 0.1f;
            GetComponent <FFManager>().vibRightMotor = 0.1f;
        }

        // Camera Change
        if (IM.GetAction("CameraToggle").state == State.Down)
        {
            GetComponent <ShipSimulator>().UpdateCamera();
        }

        // Look Behind
        if (IM.GetAction("LookBehind").state == State.Held)
        {
            GetComponent <ShipSimulator>().bLookingBehind = true;
        }
        else
        {
            GetComponent <ShipSimulator>().bLookingBehind = false;
        }
    }