当前位置: 首页>>代码示例>>C#>>正文


C# ShipConstruct.GetTotalMass方法代码示例

本文整理汇总了C#中ShipConstruct.GetTotalMass方法的典型用法代码示例。如果您正苦于以下问题:C# ShipConstruct.GetTotalMass方法的具体用法?C# ShipConstruct.GetTotalMass怎么用?C# ShipConstruct.GetTotalMass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShipConstruct的用法示例。


在下文中一共展示了ShipConstruct.GetTotalMass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CostOfSimulation

        public static float CostOfSimulation(CelestialBody body, string simulationLength, ShipConstruct ship, int SimCount, bool landed)
        {
            if (simulationLength == "" || simulationLength == "-1")
                simulationLength = "31536000000"; //1000 Earth years
            CelestialBody Kerbin = Planetarium.fetch.Home;

            double length = MagiCore.Utilities.ParseTimeString(simulationLength, false);
            length = Math.Min(length, 31536000000.0);
            if (length == 0)
                length = 31536000000.0;
            if (length < 0) //An error while parsing the value
                return -1;
            Dictionary<string, string> vars = new Dictionary<string, string>();
            vars.Add("L", length.ToString()); //Sim length in seconds
            vars.Add("M", body.Mass.ToString()); //Body mass
            vars.Add("KM", Kerbin.Mass.ToString()); //Kerbin mass
            vars.Add("A", body.atmosphere ? "1" : "0"); //Presence of atmosphere
            vars.Add("S", (body != Planetarium.fetch.Sun && body.referenceBody != Planetarium.fetch.Sun) ? "1" : "0"); //Is a moon (satellite)

            float out1, out2;
            vars.Add("m", ship.GetTotalMass().ToString()); //Vessel loaded mass
            vars.Add("C", ship.GetShipCosts(out out1, out out2).ToString()); //Vessel loaded cost

            vars.Add("s", SimCount.ToString()); //Number of times simulated this editor session

            CelestialBody Parent = body;
            if (Parent != Planetarium.fetch.Sun)
            {
                while (Parent.referenceBody != Planetarium.fetch.Sun)
                {
                    Parent = Parent.referenceBody;
                }
            }
            double orbitRatio = 1;
            if (Parent.orbit != null)
            {
                if (Parent.orbit.semiMajorAxis >= Kerbin.orbit.semiMajorAxis)
                    orbitRatio = Parent.orbit.semiMajorAxis / Kerbin.orbit.semiMajorAxis;
                else
                    orbitRatio = Kerbin.orbit.semiMajorAxis / Parent.orbit.semiMajorAxis;
            }
            vars.Add("SMA", orbitRatio.ToString());
            vars.Add("PM", Parent.Mass.ToString());

            if ((body == Kerbin) && landed)
            {
                return (float)(KCT_MathParsing.GetStandardFormulaValue("KerbinSimCost", vars));
            }
            else
            {
                return (float)(KCT_MathParsing.GetStandardFormulaValue("SimCost", vars));
            }

            /*float timeMultiplier = 13;
            if (TimeMultipliers.ContainsKey(simulationLength))
                 timeMultiplier = TimeMultipliers[simulationLength];

            if (orbitBody == Planetarium.fetch.Sun)
                return 10000 * timeMultiplier;

            float atmosphereMult = orbitBody.atmosphere ? 1.1f : 1f;
            bool isMoon = orbitBody.referenceBody != Planetarium.fetch.Sun;
            CelestialBody Parent = orbitBody;
            while (Parent.referenceBody != Planetarium.fetch.Sun)
            {
                Parent = Parent.referenceBody;
            }

            CelestialBody Kerbin = GetBodyByName("Kerbin");
            if (Kerbin == null)
                Kerbin = GetBodyByName("Earth");

            double orbitRatio = 1;
            if (Parent.orbit.semiMajorAxis >= Kerbin.orbit.semiMajorAxis)
                orbitRatio = Parent.orbit.semiMajorAxis / Kerbin.orbit.semiMajorAxis;
            else
                orbitRatio = Kerbin.orbit.semiMajorAxis / Parent.orbit.semiMajorAxis;

            double cost = Math.Pow(orbitRatio,2) * 500 * (Parent.atmosphere ? 1.1 : 1);
            if (isMoon)
                cost *= atmosphereMult * 1.1;

            cost *= timeMultiplier;
            return (float)cost;*/
        }
开发者ID:Kerbas-ad-astra,项目名称:KCT,代码行数:85,代码来源:KCT_Utilities.cs

示例2: OnVesselLaunched

        void OnVesselLaunched(ShipConstruct vVessel)
        {
            if (DebugMode) Debug.Log("KK: OnVesselLaunched");

            if (!MiscUtils.CareerStrategyEnabled(HighLogic.CurrentGame))
            {
                return;
            }
            else
            {
                if (DebugMode) Debug.Log("KK: OnVesselLaunched is Career");

                PersistenceUtils.savePersistenceBackup();
                string sitename = EditorLogic.fetch.launchSiteName;

                if (sitename == "Runway") return;
                if (sitename == "LaunchPad") return;
                if (sitename == "KSC") return;
                if (sitename == "") return;

                LaunchSite lsSite = LaunchSiteManager.getLaunchSiteByName(sitename);
                float fMissionCount = lsSite.missioncount;
                lsSite.missioncount = fMissionCount + 1;

                double dSecs = HighLogic.CurrentGame.UniversalTime;

                double hours = dSecs / 60.0 / 60.0;
                double kHours = Math.Floor(hours % 6.0);
                double kMinutes = Math.Floor((dSecs / 60.0) % 60.0);
                double kSeconds = Math.Floor(dSecs % 60.0);
                double kYears = Math.Floor(hours / 2556.5402) + 1; // Kerbin year is 2556.5402 hours
                double kDays = Math.Floor(hours % 2556.5402 / 6.0) + 1;

                string sDate =  "Y" + kYears.ToString() + " D" + kDays.ToString() + " " + " " + kHours.ToString("00") + ":" + kMinutes.ToString("00") + ":" + kSeconds.ToString("00");

                string sCraft = vVessel.shipName;
                string sWeight = vVessel.GetTotalMass().ToString();
                string sLogEntry = lsSite.missionlog + sDate + ", Launched " + sCraft + ", Mass " +sWeight + " t|";
                lsSite.missionlog = sLogEntry;

                List<LaunchSite> sites = LaunchSiteManager.getLaunchSites();
                PersistenceFile<LaunchSite>.SaveList(sites, "LAUNCHSITES", "KK");

                VesselLaunched = true;

                float dryCost = 0f;
                float fuelCost = 0f;
                float total = vVessel.GetShipCosts(out dryCost, out fuelCost);

                var cm = CurrencyModifierQuery.RunQuery(TransactionReasons.VesselRollout, total, 0f, 0f);
                total += cm.GetEffectDelta(Currency.Funds);

                double launchcost = total;
                float fRefund = 0f;
                LaunchSiteManager.getSiteLaunchRefund((string)EditorLogic.fetch.launchSiteName, out fRefund);

                if (fRefund < 1) return;

                RefundAmount = (launchcost / 100) * fRefund;
                VesselCost = launchcost - (RefundAmount);
                if (fRefund > 0)
                {
                    string sMessage = "This launch normally costs " + launchcost.ToString("#0") +
                        " but " + sitename + " provides a " + fRefund + "% refund. \n\nSo " + RefundAmount.ToString("#0") + " funds has been credited to you. \n\nEnjoy and thanks for using " +
                        sitename + ". Have a safe flight.";
                    MiscUtils.PostMessage("Launch Refund", sMessage, MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.ALERT);
                    Funding.Instance.AddFunds(RefundAmount, TransactionReasons.Cheating);
                }
            }
        }
开发者ID:AlphaAsh,项目名称:Kerbal-Konstructs_DEV,代码行数:70,代码来源:KerbalKonstructs.cs


注:本文中的ShipConstruct.GetTotalMass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。