Exemplo n.º 1
0
        private void Update()
        {
            if (dataSource == DataSource.VehicleChanger)
            {
                vehicleController = VehicleChanger.ActiveVehicleController;
            }

            if (_prevVc != vehicleController && vehicleController != null)
            {
                _tcsModule = vehicleController.GetComponent <TCSModuleWrapper>()?.module;
                _absModule = vehicleController.GetComponent <ABSModuleWrapper>()?.module;
            }

            if (vehicleController != null && _update)
            {
                if (useAnalogRpmGauge)
                {
                    analogRpmGauge.Value = vehicleController.powertrain.engine.RPM;
                }

                if (useDigitalRpmGauge)
                {
                    digitalRpmGauge.numericalValue = vehicleController.powertrain.engine.RPM;
                }

                if (useAnalogSpeedGauge)
                {
                    analogSpeedGauge.Value = vehicleController.Speed * 3.6f;
                }

                if (useDigitalSpeedGauge)
                {
                    digitalSpeedGauge.numericalValue = vehicleController.Speed * 3.6f;
                }

                if (useDigitalGearGauge)
                {
                    digitalGearGauge.stringValue = vehicleController.powertrain.transmission.GearName;
                }

                if (useLeftBlinkerDashLight)
                {
                    leftBlinkerDashLight.Active = vehicleController.effectsManager.lightsManager.leftBlinkers.On;
                }

                if (useRightBlinkerDashLight)
                {
                    rightBlinkerDashLight.Active = vehicleController.effectsManager.lightsManager.rightBlinkers.On;
                }

                if (useLowBeamDashLight)
                {
                    lowBeamDashLight.Active = vehicleController.effectsManager.lightsManager.lowBeamLights.On;
                }

                if (useHighBeamDashLight)
                {
                    highBeamDashLight.Active = vehicleController.effectsManager.lightsManager.highBeamLights.On;
                }

                if (useTcsDashLight)
                {
                    if (_tcsModule != null)
                    {
                        tcsDashLight.Active = _tcsModule.active;
                    }
                }

                if (useAbsDashLight)
                {
                    if (_absModule != null)
                    {
                        absDashLight.Active = _absModule.active;
                    }
                }


                if (useCheckEngineDashLight)
                {
                    checkEngineDashLight.Active = vehicleController.damageHandler.Damage > 0.9999f;
                }
            }
            else
            {
                if (useAnalogRpmGauge)
                {
                    analogRpmGauge.Value = 0;
                }

                if (useAnalogSpeedGauge)
                {
                    analogSpeedGauge.Value = 0;
                }

                if (useDigitalSpeedGauge)
                {
                    digitalSpeedGauge.numericalValue = 0;
                }

                if (useDigitalGearGauge)
                {
                    digitalGearGauge.stringValue = "";
                }

                if (useLeftBlinkerDashLight)
                {
                    leftBlinkerDashLight.Active = false;
                }

                if (useRightBlinkerDashLight)
                {
                    rightBlinkerDashLight.Active = false;
                }

                if (useLowBeamDashLight)
                {
                    lowBeamDashLight.Active = false;
                }

                if (useHighBeamDashLight)
                {
                    highBeamDashLight.Active = false;
                }

                if (useTcsDashLight)
                {
                    tcsDashLight.Active = false;
                }

                if (useAbsDashLight)
                {
                    absDashLight.Active = false;
                }

                if (useCheckEngineDashLight)
                {
                    checkEngineDashLight.Active = false;
                }
            }

            _prevVc = vehicleController;
        }
Exemplo n.º 2
0
        void Update()
        {
            _vc = VehicleChanger.ActiveVehicleController;

            promptText.text = "";

            if (UnityEngine.Input.GetKeyDown(KeyCode.Tab))
            {
                _canvas.enabled = !_canvas.enabled;
            }

            if (CharacterVehicleChanger.Instance != null && CharacterVehicleChanger.Instance.nearVehicle)
            {
                promptText.text = "Press V to enter the vehicle.";
            }

            if (_vc == null)
            {
                return;
            }

            if (_vc != _prevVc)
            {
                _trailerHitchModule = VehicleChanger.ActiveVehicleController.moduleManager.GetModule <TrailerHitchModule>();
                _flipOverModule     = VehicleChanger.ActiveVehicleController.moduleManager.GetModule <FlipOverModule>();
                _absModule          = VehicleChanger.ActiveVehicleController.moduleManager.GetModule <ABSModule>();
                _tcsModule          = VehicleChanger.ActiveVehicleController.moduleManager.GetModule <TCSModule>();
                _escModule          = VehicleChanger.ActiveVehicleController.moduleManager.GetModule <ESCModule>();
                _aeroModule         = VehicleChanger.ActiveVehicleController.moduleManager.GetModule <AerodynamicsModule>();
            }

            throttleSlider.value        = Mathf.Clamp01(_vc.input.states.vertical);
            brakeSlider.value           = Mathf.Clamp01(-_vc.input.states.vertical);
            clutchSlider.value          = Mathf.Clamp01(_vc.powertrain.clutch.clutchEngagement);
            handbrakeSlider.value       = Mathf.Clamp01(_vc.input.states.handbrake);
            horizontalLeftSlider.value  = Mathf.Clamp01(-_vc.input.Horizontal);
            horizontalRightSlider.value = Mathf.Clamp01(_vc.input.Horizontal);

            if (_trailerHitchModule != null && _trailerHitchModule.trailerInRange && !_trailerHitchModule.attached)
            {
                promptText.text = "Press T to attach the trailer.";
            }

            if (_flipOverModule != null && _flipOverModule.manual && _flipOverModule.flippedOver)
            {
                promptText.text = "Press P to recover the vehicle.";
            }

            if (_absModule != null)
            {
                absButton.targetGraphic.color = _absModule.IsEnabled ? enabledColor : disabledColor;
            }

            if (_tcsModule != null)
            {
                tcsButton.targetGraphic.color = _tcsModule.IsEnabled ? enabledColor : disabledColor;
            }

            if (_escModule != null)
            {
                escButton.targetGraphic.color = _escModule.IsEnabled ? enabledColor : disabledColor;
            }

            if (_aeroModule != null)
            {
                aeroButton.targetGraphic.color = _aeroModule.IsEnabled ? enabledColor : disabledColor;
            }

            damageButton.targetGraphic.color = _vc.damageHandler.Active ? enabledColor : disabledColor;
            animationHealth    = _vc.damageHandler.Damage;
            liveConverter      = _vc.damageHandler.Damage;
            live               = -_vc.damageHandler.Damage;
            damageSlider.value = live;


            _prevVc = _vc;
        }