length() public static method

public static length ( double m ) : string
m double
return string
示例#1
0
        public override string GetInfo()
        {
            string text = "";

            if (antennaRange0 != antennaRange1)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Antenna range: " + RTUtils.length(this.antennaRange0 * 1000) + "m / " + RTUtils.length(this.antennaRange1 * 1000) + "m";
            }
            else if (antennaRange > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Antenna range: " + RTUtils.length(antennaRange * 1000) + "m";
            }

            if (dishRange0 != dishRange1)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Dish range: " + RTUtils.length(dishRange0 * 1000) + "m / " + RTUtils.length(dishRange1 * 1000) + "m";
            }
            else if (dishRange > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Dish range: " + RTUtils.length(dishRange * 1000) + "m";
            }

            if (EnergyDrain0 != EnergyDrain1)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Energy req.: " + RTUtils.eCost(EnergyDrain0) + " / " + RTUtils.eCost(EnergyDrain1); // NK
            }
            else if (this.EnergyDrain > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Energy req.: " + RTUtils.eCost(EnergyDrain); // NK
            }

            return(text);
        }
        public override string GetInfo()
        {
            string text = "";

            if (antennaRange0 != antennaRange1)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Antenna range: " + RTUtils.length(this.antennaRange0 * 1000) + "m / " + RTUtils.length(this.antennaRange1 * 1000) + "m";
            }
            else if (antennaRange > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Antenna range: " + RTUtils.length(antennaRange * 1000) + "m";
            }

            if (dishRange0 != dishRange1)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Dish range: " + RTUtils.length(dishRange0 * 1000) + "m / " + RTUtils.length(dishRange1 * 1000) + "m";
            }
            else if (dishRange > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Dish range: " + RTUtils.length(dishRange * 1000) + "m";
            }

            if (EnergyDrain0 != EnergyDrain1)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Energy req.: " + (EnergyDrain0 * 60).ToString("0.00") + "/min. / " + (EnergyDrain1 * 60).ToString("0.00") + "/min.";
            }
            else if (this.EnergyDrain > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Energy req.: " + (EnergyDrain * 60).ToString("0.00") + "/min.";
            }

            return(text);
        }
示例#3
0
        public override string GetInfo()
        {
            string text = "";

            if (this.antennaRange > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Antenna range: " + RTUtils.length(this.antennaRange * 1000) + "m";
            }
            if (this.dishRange > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Dish range: " + RTUtils.length(this.dishRange * 1000) + "m";
            }
            if (this.EnergyDrain > 0)
            {
                if (text.Length > 0)
                {
                    text += "\n";
                }
                text += "Energy req.: " + RTUtils.eCost(EnergyDrain); // NK
            }

            //if (this.EnergyDrain0 > 0)
            //    text += "\nInactive energy req.: " + (Math.Round(this.EnergyDrain0 * 60, 1) == 0 ? Math.Round(this.EnergyDrain0 * 60, 2) : Math.Round(this.EnergyDrain0 * 60, 1)) + "/min.";
            //if (this.EnergyDrain1 > 0)
            //    text += "\nEnergy req.: " + (Math.Round(this.EnergyDrain1 * 60, 1) == 0 ? Math.Round(this.EnergyDrain1 * 60, 2) : Math.Round(this.EnergyDrain1 * 60, 1)) + "/min.";

            return(text);
        }
示例#4
0
        public void UpdatePA()
        {
            target = new Target(pointedAt);

            string targetName = target.GUIname;

            if (this.dishRange > 0)
            {
                if (Events["setTarget"].active)
                {
                    Events["setTarget2"].guiName      = "Target: " + targetName;
                    Events["OverrideTarget2"].guiName = "Override " + Events["setTarget2"].guiName;
                    Events["setTarget"].active        = Events["OverrideTarget"].active = false;
                    Events["setTarget2"].active       = Events["OverrideTarget2"].active = true;
                }
                else
                {
                    Events["setTarget"].guiName      = "Target: " + targetName;
                    Events["OverrideTarget"].guiName = "Override " + Events["setTarget"].guiName;
                    Events["setTarget"].active       = Events["OverrideTarget"].active = true;
                    Events["setTarget2"].active      = Events["OverrideTarget2"].active = false;
                }
            }
            else
            {
                Events["setTarget"].active = Events["OverrideTarget"].active = Events["setTarget2"].active = Events["OverrideTarget2"].active = false;
            }


            if (!showStats)
            {
                Fields["Dish_Range"].guiActive = Fields["Antenna_Range"].guiActive = false;
                return;
            }

            if (dishRange > 0)
            {
                Dish_Range = RTUtils.length(dishRange * 1000) + "m";

                Fields["Dish_Range"].guiName = "";

                if (showAntennaName)
                {
                    Fields["Dish_Range"].guiName += antennaName;
                }
                if (showType)
                {
                    Fields["Dish_Range"].guiName += showAntennaName ? " dish " : "Dish ";
                }
                Fields["Dish_Range"].guiName += (showAntennaName || showType) ? "range" : "Range";

                Fields["Dish_Range"].guiActive = true;
            }
            else
            {
                Fields["Dish_Range"].guiActive = false;
            }


            if (this.antennaRange > 0)
            {
                Antenna_Range = RTUtils.length(antennaRange * 1000) + "m";

                Fields["Antenna_Range"].guiName = "";

                if (showAntennaName)
                {
                    Fields["Antenna_Range"].guiName += antennaName;
                }
                if (showType)
                {
                    Fields["Antenna_Range"].guiName += showAntennaName ? " antenna " : "Antenna ";
                }
                Fields["Antenna_Range"].guiName += (showAntennaName || showType) ? "range" : "Range";

                Fields["Antenna_Range"].guiActive = true;
            }
            else
            {
                Fields["Antenna_Range"].guiActive = false;
            }
        }
示例#5
0
        void WindowGUI(int windowID)
        {
            Color    savedColor        = GUI.color;
            Color    savedContentColor = GUI.contentColor;
            bool     CrewControl       = vessel.GetCrewCount() > 0;
            GUIStyle Alarm             = new GUIStyle(GUI.skin.label);

            Alarm.fontStyle        = FontStyle.Bold;
            Alarm.normal.textColor = Color.red;

            if (!powered)
            {
                GUI.DragWindow();

                string alarmMessage = "Out of power";
                if (AlarmTime < Time.time)
                {
                    AlarmTime = Time.time + 1;
                    alarmShow = !alarmShow;
                }
                if (alarmShow)
                {
                    alarmMessage += " !";
                }
                GUILayout.Label(alarmMessage, Alarm);
                return;
            }

            try
            {
                if (InContact)
                {
                    if (GUILayout.Button("Path length: " + RTUtils.length(path.Length) + "m, delay: " + RTUtils.time(path.ControlDelay) +
                                         (RTGlobals.AdvInfo ?
                                          "\nRelay path: " + path.ToString() :
                                          ""),
                                         GUI.skin.label, GUILayout.ExpandWidth(true)))
                    {
                        RTGlobals.AdvInfo = !RTGlobals.AdvInfo;
                    }
                }
                else
                {
                    string alarmMessage = "Out of contact";
                    if (AlarmTime < Time.time)
                    {
                        AlarmTime = Time.time + 1;
                        alarmShow = !alarmShow;
                    }
                    if (alarmShow)
                    {
                        alarmMessage += " !";
                    }
                    GUILayout.Label(alarmMessage, Alarm);
                }
            }
            catch (NullReferenceException)
            {
                RTGlobals.network = new RelayNetwork();
                path = RTGlobals.network.GetCommandPath(Rnode);
            }
            GUI.color = savedColor;

            GUILayout.BeginHorizontal();

            RTGlobals.listComsats = GUILayout.Toggle(RTGlobals.listComsats, "List comsats", GUI.skin.button, GUILayout.Height(20));


            if (!CrewControl && !(MechJeb && InContact))
            {
                GUI.contentColor = Color.red;
            }
            localControl = GUILayout.Toggle(localControl, (!CrewControl && MechJeb) ? "MechJeb Control" : "Local Control", GUI.skin.button, GUILayout.Height(20));
            if (!CrewControl && !(MechJeb && InContact))
            {
                localControl     = false;
                GUI.contentColor = savedContentColor;
            }


            RTGlobals.showPathInMapView = GUILayout.Toggle(RTGlobals.showPathInMapView, "Show path on map", GUI.skin.button, GUILayout.Height(20));

            RTGlobals.showFC = GUILayout.Toggle(RTGlobals.showFC, "Flight Computer", GUI.skin.button, GUILayout.Height(20));

            GUILayout.EndHorizontal();

            if (RTGlobals.listComsats)
            {
                if (!LCoLF)
                {
                    Thread thread = new Thread(new ThreadStart(GetCommandPath));
                    thread.Start();
                    LCoLF = true;
                }


                if (!InControl)
                {
                    GUI.contentColor = Color.red;
                }
                if (GUILayout.Button(Rnode.descript, new GUIStyle(GUI.skin.button)) && InControl)
                {
                    settings.Open(Rnode);
                }
                if (!InControl)
                {
                    GUI.contentColor = savedContentColor;
                }

                RTGlobals.comsatListScroll = GUILayout.BeginScrollView(RTGlobals.comsatListScroll, false, true);

                //compiles a list of comsat vessels that are in the current RelayNetwork, Coloring the ones in the current RelayPath green.
                if (InContact || Rnode.HasCommand)
                {
                    foreach (RelayNode node in RTGlobals.network.all)
                    {
                        if (!node.Equals(Rnode) && node.Vessel != null)
                        {
                            GUILayout.BeginHorizontal();
                            bool connection = InContactWith(node);

                            if (!connection)
                            {
                                if (GUI.contentColor != Color.red)
                                {
                                    GUI.contentColor = Color.red;
                                }
                            }
                            else
                            if (InContact && path.nodes.Contains(node))
                            {
                                if (GUI.contentColor != Color.green)
                                {
                                    GUI.contentColor = Color.green;
                                }
                            }
                            else if (GUI.contentColor != Color.white)
                            {
                                GUI.contentColor = Color.white;
                            }
                            if (GUILayout.Button(node.descript, new GUIStyle(GUI.skin.button), GUILayout.Height(50.0F)) && connection)
                            {
                                settings.Open(node);
                            }
                            if ((InContact || Rnode.HasCommand) && connection && node.Vessel.loaded && (RTGlobals.extPack ? Vector3d.Distance(vessel.transform.position, node.Vessel.transform.position) < 2000 : !node.Vessel.packed))
                            {
                                if (GUILayout.Button("Ctrl", new GUIStyle(GUI.skin.button), GUILayout.Width(50.0F), GUILayout.Height(50.0F)))
                                {
                                    bool isThere        = false;
                                    int  ATid           = this.flightComputerGUI.ATTITUDE_ID + 1,
                                         THid           = this.flightComputerGUI.THROTTLE_ID + 1;
                                    GUIcontainer remove = new GUIcontainer();
                                    foreach (GUIcontainer c in this.otherGUI)
                                    {
                                        if (c.gui == RTGlobals.coreList[node.Vessel].flightComputerGUI)
                                        {
                                            isThere = true;
                                            remove  = c;
                                            break;
                                        }
                                        ATid = c.ATTITUDE_ID + 1;
                                        THid = c.THROTTLE_ID + 1;
                                    }

                                    if (isThere)
                                    {
                                        otherGUI.Remove(remove);
                                        if (RTGlobals.extPack && otherGUI.Count == 0 && RTGlobals.Manager != null)
                                        {
                                            RTGlobals.Manager.distantLandedPartPackThreshold   = 350;
                                            RTGlobals.Manager.distantLandedPartUnpackThreshold = 200;
                                            RTGlobals.Manager.distantPartPackThreshold         = 5000;
                                            RTGlobals.Manager.distantPartUnpackThreshold       = 200;
                                        }
                                    }
                                    else
                                    {
                                        otherGUI.Add(new GUIcontainer(RTGlobals.coreList[node.Vessel].flightComputerGUI, ATid, THid));
                                    }
                                }
                            }

                            GUILayout.EndHorizontal();
                        }
                    }
                }
                else
                {
                    GUI.contentColor = Color.red;
                    foreach (RelayNode node in RTGlobals.network.all)
                    {
                        if (!node.Equals(Rnode) && node.Vessel != null)
                        {
                            GUILayout.Label(node.descript, new GUIStyle(GUI.skin.button));
                        }
                    }
                }

                GUI.color        = savedColor;
                GUI.contentColor = savedContentColor;
                GUILayout.EndScrollView();
            }

            GUI.DragWindow();
        }
示例#6
0
        public void SettingsGUI(int windowID)
        {
            try
            {
                this.vesselName = GUILayout.TextField(this.vesselName);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Save & Close", new GUIStyle(GUI.skin.button)))
                {
                    SaveAndClose();
                }
                if (GUILayout.Button("Close without saving", new GUIStyle(GUI.skin.button)))
                {
                    Close();
                }
                GUILayout.EndHorizontal();


                SettingListScroll = GUILayout.BeginScrollView(SettingListScroll, false, true);

                foreach (SatSettingNode setupnode in settingNodes)
                {
                    setupnode.SubmenuOpen = GUILayout.Toggle(setupnode.SubmenuOpen, setupnode.antennaName + "(" + RTUtils.length(setupnode.dishRange * 1000) + "m) Pointed At: " + setupnode.pointedAt.Name, new GUIStyle(GUI.skin.button));

                    if (setupnode.SubmenuOpen)
                    {
                        setupnode.ListTargets();
                    }
                }

                GUILayout.EndScrollView();
                GUI.DragWindow();
            }
            catch (NullReferenceException)
            { this.Close(); }
        }