示例#1
0
        public void Start()
        {
            GameEvents.onVesselChange.Add(OnVesselChange);
            GameEvents.onSetSpeedMode.Add(OnSetSpeedMode);
            //GameEvents.OnGameSettingsApplied.Add(OnGameSettingsApplied);
            //GameEvents.OnGameSettingsWritten.Add(OnGameSettingsWritten);
            GameEvents.onGameUnpause.Add(OnGameUnpause);

            display   = GameObject.FindObjectOfType <SpeedDisplay>();
            settings  = HighLogic.CurrentGame.Parameters.CustomParams <SpeedUnitAnnexSettings>();
            settings2 = HighLogic.CurrentGame.Parameters.CustomParams <SpeedUnitAnnexSettings2>();

            if (settings.overrideFAR)
            {
                CreateFARReflections();
                ToggleFARDisplay();
            }

            display.textSpeed.enableWordWrapping = false;
            display.textTitle.enableWordWrapping = false;

            display.textTitle.fontSize = display.textTitle.fontSize / 1.15f;

            SetFinalName(FlightGlobals.speedDisplayMode);



            //Log("Font: "+display.textSpeed.font);
            // NotoSans-Regular SDF
        }
示例#2
0
 public void OnGUI()
 {
     if (display == null)
     {
         display = GameObject.FindObjectOfType <SpeedDisplay>();
         if (display != null)
         {
             display.textTitle.fontSize /= 1.15f;
         }
     }
 }
示例#3
0
    private void Start()
    {
        groundChecker = GetComponentInChildren <GroundCheck>();
        try
        {
            speedDisplayObj = FindObjectOfType <SpeedDisplay>();
        }
        catch (NullReferenceException e)
        { }

        wallChecker = GetComponentInChildren <WallCheck>();
    }
示例#4
0
        public void Start()
        {
            //Log("OnStart()");

            display  = GameObject.FindObjectOfType <SpeedDisplay>();
            settings = HighLogic.CurrentGame.Parameters.CustomParams <SpeedUnitAnnexSettings>();

            display.textSpeed.enableWordWrapping = false;
            display.textTitle.enableWordWrapping = false;

            display.textTitle.fontSize = display.textTitle.fontSize / 1.15f;
        }
示例#5
0
 /// <summary>
 /// Called when drawn
 /// </summary>
 public void OnGUI()
 {
     if (display == null)
     {
         display = GameObject.FindObjectOfType <SpeedDisplay>();
         if (display != null)
         {
             stockSpeedFontSize = display.textSpeed.fontSize;
             stockTitleFontSize = display.textTitle.fontSize;
         }
     }
     if (ToolBarEnabled)
     {
         ConfigurationWindow = GUI.Window(100, ConfigurationWindow, OnWindow, "Speed Unit Changer", HighLogic.Skin.window);
     }
 }
示例#6
0
        public void Start()
        {
            GameEvents.onVesselChange.Add(onVesselChange);
            GameEvents.onSetSpeedMode.Add(onSetSpeedMode);
            GameEvents.OnGameSettingsApplied.Add(OnGameSettingsApplied);

            display  = GameObject.FindObjectOfType <SpeedDisplay>();
            settings = HighLogic.CurrentGame.Parameters.CustomParams <SpeedUnitAnnexSettings>();

            display.textSpeed.enableWordWrapping = false;
            display.textTitle.enableWordWrapping = false;

            display.textTitle.fontSize = display.textTitle.fontSize / 1.15f;

            SetFinalName(FlightGlobals.speedDisplayMode);

            //Log("Font: "+display.textSpeed.font);
            // NotoSans-Regular SDF
        }
        public void ChangeSurfVelocity()
        {
            // No need to build the string
            if (!(allEnabled && enabled))
            {
                return;
            }

            active = false;
            //DaMichel: Avoid conflict between multiple vessels in physics range. We only want to show the speed of the active vessel.
            if (FlightGlobals.ActiveVessel != _vessel)
            {
                return;
            }
            //DaMichel: Keep our fingers off of this also if there is no atmosphere (staticPressure <= 0)
            if (FlightGlobals.speedDisplayMode != FlightGlobals.SpeedDisplayModes.Surface || _vessel.atmDensity <= 0)
            {
                return;
            }

            if (SpeedDisplay.Instance == null)
            {
                return;
            }

            double unitConversion = 1;
            string unitString; // = "m/s";
            string caption;

            if (unitMode == SurfaceVelUnit.KNOTS)
            {
                unitConversion = 1.943844492440604768413343347219;
                unitString     = surfUnit_str[1];
            }
            else if (unitMode == SurfaceVelUnit.KM_H)
            {
                unitConversion = 3.6;
                unitString     = surfUnit_str[3];
            }
            else if (unitMode == SurfaceVelUnit.MPH)
            {
                unitConversion = 2.236936;
                unitString     = surfUnit_str[2];
            }
            else
            {
                unitString = surfUnit_str[0];
            }
            if (velMode == SurfaceVelMode.TAS)
            {
                caption   = surfModel_str[0];
                velString = (_vessel.srfSpeed * unitConversion).ToString("F1") + unitString;
            }
            else
            {
                if (velMode == SurfaceVelMode.IAS)
                {
                    caption = surfModel_str[1];
                    //double densityRatio = (FARAeroUtil.GetCurrentDensity(_vessel) / 1.225);

                    velString = (CalculateIAS() * unitConversion).ToString("F1") + unitString;
                }
                else if (velMode == SurfaceVelMode.EAS)
                {
                    caption   = surfModel_str[2];
                    velString = (CalculateEAS() * unitConversion).ToString("F1") + unitString;
                }
                else // if (velMode == SurfaceVelMode.MACH)
                {
                    caption   = surfModel_str[3];
                    velString = _vessel.mach.ToString("F3");
                }
            }
            active = true;

            SpeedDisplay UI = SpeedDisplay.Instance;

            if (UI.textSpeed == null || UI.textTitle == null)
            {
                return;
            }

            UI.textTitle.text = caption;
            UI.textSpeed.text = velString;
        }
示例#8
0
        public void ChangeSurfVelocity()
        {
            active = false;
            //DaMichel: Avoid conflict between multiple vessels in physics range. We only want to show the speed of the active vessel.
            if (FlightGlobals.ActiveVessel != _vessel)
            {
                return;
            }
            //DaMichel: Keep our fingers off of this also if there is no atmosphere (staticPressure <= 0)
            if (FlightGlobals.speedDisplayMode != FlightGlobals.SpeedDisplayModes.Surface || _vessel.atmDensity <= 0)
            {
                return;
            }

            if (SpeedDisplay.Instance == null)
            {
                return;
            }

            double unitConversion = 1;
            string unitString;// = "m/s";
            string caption;

            if (unitMode == SurfaceVelUnit.KNOTS)
            {
                unitConversion = 1.943844492440604768413343347219;
                unitString     = surfUnit_str[1];
            }
            else if (unitMode == SurfaceVelUnit.KM_H)
            {
                unitConversion = 3.6;
                unitString     = surfUnit_str[3];
            }
            else if (unitMode == SurfaceVelUnit.MPH)
            {
                unitConversion = 2.236936;
                unitString     = surfUnit_str[2];
            }
            else
            {
                unitString = surfUnit_str[0];
            }
            if (velMode == SurfaceVelMode.TAS)
            {
                caption   = surfModel_str[0];
                velString = (_vessel.srfSpeed * unitConversion).ToString("F1") + unitString;
            }
            else
            {
                if (velMode == SurfaceVelMode.IAS)
                {
                    caption = surfModel_str[1];
                    //double densityRatio = (FARAeroUtil.GetCurrentDensity(_vessel) / 1.225);
                    double pressureRatio = FARAeroUtil.RayleighPitotTubeStagPressure(_vessel.mach);     //stag pressure at pitot tube face / ambient pressure

                    double velocity = pressureRatio - 1;
                    velocity *= _vessel.staticPressurekPa * 1000 * 2;
                    velocity /= 1.225;
                    velocity  = Math.Sqrt(velocity);

                    velString = (velocity * unitConversion).ToString("F1") + unitString;
                }
                else if (velMode == SurfaceVelMode.EAS)
                {
                    caption = surfModel_str[2];
                    double densityRatio = (FARAeroUtil.GetCurrentDensity(_vessel) / 1.225);
                    velString = (_vessel.srfSpeed * Math.Sqrt(densityRatio) * unitConversion).ToString("F1") + unitString;
                }
                else// if (velMode == SurfaceVelMode.MACH)
                {
                    caption   = surfModel_str[3];
                    velString = _vessel.mach.ToString("F3");
                }
            }
            active = true;

            SpeedDisplay UI = SpeedDisplay.Instance;

            if (UI.textSpeed == null || UI.textTitle == null)
            {
                return;
            }

            UI.textTitle.text = caption;
            UI.textSpeed.text = velString;
        }
示例#9
0
 void Awake()
 {
     _instance    = this;
     musicManager = this.GetComponent <AudioSource>();
 }