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


C# ShipConstruct.GetShipCosts方法代码示例

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


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

示例1: KCT_BuildListVessel

        public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL)
        {
            ship = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float dry, fuel;
            s.GetShipCosts(out dry, out fuel);
            cost = dry + fuel;
            TotalMass = 0;
            foreach (Part p in s.Parts)
            {
                TotalMass += p.mass;
                TotalMass += p.GetResourceMass();
            }

            launchSite = ls;
            buildPoints = bP;
            progress = 0;
            flag = flagURL;
            if (launchSite == "LaunchPad")
                type = ListType.VAB;
            else
                type = ListType.SPH;
            InventoryParts = new Dictionary<string, int>();
            id = Guid.NewGuid();
            cannotEarnScience = false;
        }
开发者ID:fingerboxes,项目名称:KCT,代码行数:28,代码来源:KCT_BuildListVessel.cs

示例2: KCT_BuildListVessel

        public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL)
        {
            ship = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float dry, fuel;
            s.GetShipCosts(out dry, out fuel);
            cost = dry + fuel;

            launchSite = ls;
            buildPoints = bP;
            progress = 0;
            flag = flagURL;
            if (launchSite == "LaunchPad")
                type = ListType.VAB;
            else
                type = ListType.SPH;
            InventoryParts = new List<string>();
            id = Guid.NewGuid();
            cannotEarnScience = false;
        }
开发者ID:ntwest,项目名称:KCT,代码行数:22,代码来源:KCT_BuildListVessel.cs

示例3: KCT_BuildListVessel

        public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL)
        {
            ship = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float fuel;
            cost = s.GetShipCosts(out emptyCost, out fuel);
            TotalMass = s.GetShipMass(out emptyMass, out fuel);

            launchSite = ls;
            buildPoints = bP;
            progress = 0;
            flag = flagURL;
            if (s.shipFacility == EditorFacility.VAB)
                type = ListType.VAB;
            else if (s.shipFacility == EditorFacility.SPH)
                type = ListType.SPH;
            else
                type = ListType.None;
            InventoryParts = new Dictionary<string, int>();
            id = Guid.NewGuid();
            cannotEarnScience = false;
        }
开发者ID:Kerbas-ad-astra,项目名称:KCT,代码行数:24,代码来源:KCT_BuildListVessel.cs

示例4: OnVesselLaunched

        void OnVesselLaunched(ShipConstruct vVessel)
        {
            if (vVessel == null) return;
            if (EditorLogic.fetch.launchSiteName == null) return;

            PersistenceUtils.savePersistenceBackup();

            if (EditorLogic.fetch.launchSiteName == "Runway") return;
            if (EditorLogic.fetch.launchSiteName == "LaunchPad") return;
            if (EditorLogic.fetch.launchSiteName == "KSC") return;

            /* StaticObject soTemp = null;

            foreach (StaticObject soThis in KerbalKonstructs.instance.getStaticDB().getAllStatics())
            {
                if (soThis.getSetting("LaunchSiteName") == null)
                    continue;
                else
                    if ((string)soThis.getSetting("LaunchSiteName") == (string)EditorLogic.fetch.launchSiteName)
                    {
                        soTemp = soThis;
                        break;
                    }
            } */

            // Don't know why newly created launchsites don't appear without a restart of KSP still.
            // This doesn't seem to help.
            /* if (soTemp != null)
            {
                if (DebugMode) Debug.Log("KK: Got launchsite gameobject" + (string)EditorLogic.fetch.launchSiteName);

                soTemp.SetActiveRecursively(soTemp.gameObject, true);
            } */

            if (MiscUtils.CareerStrategyEnabled(HighLogic.CurrentGame))
            {
                VesselLaunched = true;
                string sitename = EditorLogic.fetch.launchSiteName;

                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:Kerbas-ad-astra,项目名称:Kerbal-Konstructs_DEV,代码行数:64,代码来源:KerbalKonstructs.cs

示例5: vesselRolloutEvent

		/// <summary>
		/// Fires when a new vessel is created at the launch pad.
		/// </summary>
		/// <param name="ship">The ship being rolled out.</param>
		public void vesselRolloutEvent(ShipConstruct ship)
		{
			BeanCounter.LogFormatted_DebugOnly("------------- vesselRolloutEvent -------------");

			float dryCost, fuelCost, totalCost;
			totalCost = ship.GetShipCosts (out dryCost, out fuelCost);

			BeanCounter.LogFormatted_DebugOnly("Rollout: {0}", ship.shipName);
			BeanCounter.LogFormatted_DebugOnly("launchID: {0}", HighLogic.fetch.currentGame.launchID);

			Vessel vessel = FlightGlobals.ActiveVessel;
			BeanCounter.LogFormatted_DebugOnly("NEW VESSEL LAUNCH DETECTED: {0}", vessel.vesselName);
			
			BCLaunchData launch = new BCLaunchData(true);
			launch.vesselName = vessel.vesselName;
			launch.missionID = BCUtils.GetVesselMissionID(vessel);
			launch.dryCost = dryCost;
			launch.totalCost = totalCost;
			launch.launchTime = vessel.launchTime;

			// TODO move this to utils?
			List<BCVesselResourceData> resources = new List<BCVesselResourceData>();
			List<BCVesselPartData> parts = new List<BCVesselPartData>();
			float total_resource_cost = 0;
			
            // Iterate over each part so we can log the parts, calculate the vessel resources, and
            // calculate the actual cost of everything
			foreach (Part part in vessel.parts)
			{
				BCVesselPartData part_data = new BCVesselPartData();
				part_data.partName = part.partInfo.name;
				
				float part_full_cost = part.partInfo.cost;
				float part_resource_cost_full = 0;
				float part_resource_cost_actual = 0;
				
				foreach (PartResource res in part.Resources)
				{
					if (res.info.unitCost == 0 || res.amount == 0)
					{
						// Don't need to keep track of free resources
						// Or maybe we should, in case the cost changes due to a mod/game update?
						continue;
					}
					
					part_resource_cost_full += (float)(res.info.unitCost * res.maxAmount);
					part_resource_cost_actual += (float)(res.info.unitCost * res.amount);
					
                    // Either create a new VesselResourceData, or add to the one we already have
                    // TODO perhaps this should be conbined in to a single static method on BCVesselResourceData?
					BCVesselResourceData vr = resources.Find(r => r.resourceName == res.resourceName);
					if (vr == null)
					{
						resources.Add(new BCVesselResourceData(res.info, res.resourceName, res.amount, res.maxAmount));
					}
					else
					{
						vr.Add(res);
					}
				}
				
				float part_dry_cost = part_full_cost - part_resource_cost_full;
				part_data.baseCost = part_dry_cost;
				part_data.moduleCosts = part.GetModuleCosts();
				part_data.status = BCVesselPartStatus.Active;
				part_data.uid = part.flightID;
				parts.Add(part_data);

				total_resource_cost += part_resource_cost_actual;
			}
			
			launch.resources = resources;
			launch.parts = parts;
			launch.resourceCost = total_resource_cost;
			OATBeanCounterData.data.launches.Add(launch);

            // Try to match this to the transaction
            BCTransactionData transaction =
                (from trans in OATBeanCounterData.data.transactions
                 where trans.time == HighLogic.CurrentGame.UniversalTime
                 && trans.reason == TransactionReasons.VesselRollout
                 select trans).SingleOrDefault();
            if (transaction != null)
            {
                BeanCounter.LogFormatted_DebugOnly("Found matching transaction for this rollout: {0}", transaction.id);
                launch.transactionID = transaction.id;
                transaction.dataID = launch.id;
            }

			BeanCounter.LogFormatted_DebugOnly("------------ /vesselRolloutEvent -------------");
		}
开发者ID:OverloadUT,项目名称:OATBeanCounter,代码行数:95,代码来源:BCEvents.cs

示例6: 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

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