Exemple #1
0
        protected override void Initialize()
        {
            Controller = GetComponentInParent <IAgentController>();
            Dynamics   = GetComponentInParent <IVehicleDynamics>();
            Actions    = GetComponentInParent <VehicleActions>();

            Debug.Assert(Dynamics != null);
            Debug.Assert(SimulatorManager.Instance != null);

            Controls = new KeyboardControlInputs();

            Controls.VehicleKeyboard.Direction.started         += DirectionStarted;
            Controls.VehicleKeyboard.Direction.performed       += DirectionPerformed;
            Controls.VehicleKeyboard.Direction.canceled        += DirectionCanceled;
            Controls.VehicleKeyboard.ShiftFirst.performed      += ShiftFirstPerformed;
            Controls.VehicleKeyboard.ShiftReverse.performed    += ShiftReversePerformed;
            Controls.VehicleKeyboard.ParkingBrake.performed    += ParkingBrakePerformed;
            Controls.VehicleKeyboard.Ignition.performed        += IgnitionPerformed;
            Controls.VehicleKeyboard.HeadLights.performed      += HeadLightsPerformed;
            Controls.VehicleKeyboard.IndicatorLeft.performed   += IndicatorLeftPerformed;
            Controls.VehicleKeyboard.IndicatorRight.performed  += IndicatorRightPerformed;
            Controls.VehicleKeyboard.IndicatorHazard.performed += IndicatorHazardPerformed;
            Controls.VehicleKeyboard.FogLights.performed       += FogLightsPerformed;
            Controls.VehicleKeyboard.InteriorLight.performed   += InteriorLightPerformed;

            Controls.Enable();
        }
Exemple #2
0
        protected override void Deinitialize()
        {
            if (Controls != null)
            {
                Controls.Disable();
                Controls.Dispose();

                Controls = null;
            }
        }