Ejemplo n.º 1
0
    void Awake()
    {
        /* Create the player controller object in the code, linking the Unity
         * Engine input system to script functions */
        controls = new PlayerControls();

        /* context refers to any input data when a controlpad button is pressed,
         * providng input information which can be used */
        controls.ControllerInput.RightThumbstick.performed += context =>
                                                              MoveUiJoystick(context.ReadValue <Vector2>());
        controls.ControllerInput.RudderLeftDown.performed += context =>
                                                             ControlsUtilityMethods.PedalDownKeyboard("left");
        controls.ControllerInput.RudderLeftUp.performed += context =>
                                                           ControlsUtilityMethods.PedalBothUp();
        controls.ControllerInput.RudderRightDown.performed += context =>
                                                              ControlsUtilityMethods.PedalDownKeyboard("right");
        controls.ControllerInput.RudderRightUp.performed += context =>
                                                            ControlsUtilityMethods.PedalBothUp();
        controls.ControllerInput.FlapsDown.performed += context =>
                                                        ControlsUtilityMethods.MoveFlapsDown();
        controls.ControllerInput.FlapsUp.performed += context =>
                                                      ControlsUtilityMethods.MoveFlapsUp();
        controls.ControllerInput.LeftThumbstick.performed += context =>
                                                             ControlsUtilityMethods.MoveUiThrottle(context.ReadValue <Vector2>());
    }
 // Awake method called when game loads
 void Awake()
 {
     /* Get a reference to the Unity engine Player Controls.
      * Unity Input system maps performed function to key press */
     controls = new PlayerControls();
     // Each keyboard input is mapped to a function call Rudder Keys
     controls.KeyboardInput.RudderLeftDown.performed += context =>
                                                        ControlsUtilityMethods.PedalDownKeyboard("left");
     controls.KeyboardInput.RudderLeftUp.performed += context =>
                                                      ControlsUtilityMethods.PedalBothUp();
     controls.KeyboardInput.RudderRightDown.performed += context =>
                                                         ControlsUtilityMethods.PedalDownKeyboard("right");
     controls.KeyboardInput.RudderRightUp.performed += context =>
                                                       ControlsUtilityMethods.PedalBothUp();
     // Elevator Keys
     controls.KeyboardInput.ElevatorsUp.performed += context =>
                                                     ButtonJoystickMoveElevators("down");
     controls.KeyboardInput.ElevatorsDown.performed += context =>
                                                       ButtonJoystickMoveElevators("up");
     controls.KeyboardInput.ElevatorsUpReverse.performed += context =>
                                                            ButtonJoystickMoveElevators("reverse");
     controls.KeyboardInput.ElevatorsDownReverse.performed += context =>
                                                              ButtonJoystickMoveElevators("reverse");
     // Aileron Keys
     controls.KeyboardInput.AileronsUp.performed += context =>
                                                    ButtonJoystickMoveAilerons("up");
     controls.KeyboardInput.AileronsDown.performed += context =>
                                                      ButtonJoystickMoveAilerons("down");
     controls.KeyboardInput.AileronsUpReverse.performed += context =>
                                                           ButtonJoystickMoveAilerons("reverse");
     controls.KeyboardInput.AileronsDownReverse.performed += context =>
                                                             ButtonJoystickMoveAilerons("reverse");
     // Flaps Keys
     controls.KeyboardInput.FlapsDown.performed += context =>
                                                   ControlsUtilityMethods.MoveFlapsDown();
     controls.KeyboardInput.FlapsUp.performed += context =>
                                                 ControlsUtilityMethods.MoveFlapsUp();
     // Throttle Keys
     controls.KeyboardInput.ThrottleDown.performed += context =>
                                                      MoveThrottle("down");
     controls.KeyboardInput.ThrottleUp.performed += context =>
                                                    MoveThrottle("up");
 }