本文整理汇总了C#中Part类的典型用法代码示例。如果您正苦于以下问题:C# Part类的具体用法?C# Part怎么用?C# Part使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Part类属于命名空间,在下文中一共展示了Part类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: buyPart
void buyPart(Part part)
{
if (mobo != null)
{
if (part.price < funds)
{
if (mobo.plugIn(part))
{
funds -= part.price;
print("Part purchased! Remaining Funds: " + funds);
storeFront.Remove(part);
}
else
{
print("Your motherboard's interface is not compatible with this!");
}
}
else
{
print("You must construct additional cash piles!");
}
}
else
{
print("You have no motherboard on which to plug things in to test if they work!");
}
}
开发者ID:rhyok,项目名称:hue-r,代码行数:28,代码来源:Player.cs
示例2: AnimatedNode
public AnimatedNode(AttachNode node, Transform node_transform, Part part)
{
this.node = node;
this.part = part;
nT = node_transform;
pT = part.partTransform;
}
开发者ID:kevin-ye,项目名称:hangar,代码行数:7,代码来源:AnimatedNode.cs
示例3: FlyingCamera
public FlyingCamera(Part thatPart, RenderTexture screen, float aspect)
{
ourVessel = thatPart.vessel;
ourPart = thatPart;
screenTexture = screen;
cameraAspect = aspect;
}
开发者ID:Tahvohck,项目名称:RasterPropMonitor,代码行数:7,代码来源:FlyingCamera.cs
示例4: EngineModuleWrapper
public EngineModuleWrapper(Part part, string engineID)
{
ModuleEngines _engine = null;
foreach (PartModule pm in part.Modules)
{
_engine = pm as ModuleEngines;
if (_engine != null && _engine.engineID.ToLowerInvariant() == engineID.ToLowerInvariant())
break;
}
if (_engine != null)
{
engine = _engine;
if (part.Modules.Contains("ModuleEnginesRF"))
engineType = EngineModuleType.REALENGINE;
else if (part.Modules.Contains("ModuleEngines"))
engineType = EngineModuleType.ENGINE;
else if (part.Modules.Contains("ModuleEnginesFX"))
engineType = EngineModuleType.ENGINEFX;
else
engineType = EngineModuleType.UNKNOWN;
_minFuelFlow = engine.minFuelFlow;
_maxFuelFlow = engine.maxFuelFlow;
}
else
{
engineType = EngineModuleType.UNKNOWN;
}
}
开发者ID:Corax,项目名称:TestFlight,代码行数:29,代码来源:EngineModuleWrapper.cs
示例5: HasDeactivatedEngineOrTankDescendant
//detect if a part is above a deactivated engine or fuel tank
public static bool HasDeactivatedEngineOrTankDescendant(Part p)
{
if ((p.State == PartStates.DEACTIVATED) && (p is FuelTank || p.IsEngine()) && !p.IsSepratron())
{
return true; // TODO: yet more ModuleEngine lazy checks
}
//check if this is a new-style fuel tank that's run out of resources:
bool hadResources = false;
bool hasResources = false;
foreach (PartResource r in p.Resources)
{
if (r.name == "ElectricCharge") continue;
if (r.maxAmount > 0) hadResources = true;
if (r.amount > 0) hasResources = true;
}
if (hadResources && !hasResources) return true;
if (p.IsEngine() && !p.EngineHasFuel()) return true;
foreach (Part child in p.children)
{
if (HasDeactivatedEngineOrTankDescendant(child)) return true;
}
return false;
}
开发者ID:KaiSforza,项目名称:MechJeb2,代码行数:27,代码来源:MechJebModuleStagingController.cs
示例6: GoAwayEventCallback
/// <summary>
/// Catch the event of the part disappearing, from crashing or
/// from unloading from distance or scene change, and ensure
/// the window closes if it was open when that happens:
/// </summary>
/// <param name="whichPartWentAway">The callback is called for EVERY part
/// that ever goes away, so we have to check if it's the right one</param>
public void GoAwayEventCallback(Part whichPartWentAway)
{
if (whichPartWentAway != attachedModule.part)
return;
Close();
}
开发者ID:Whitecaribou,项目名称:KOS,代码行数:14,代码来源:KOSNameTagWindow.cs
示例7: OnPartDie
private void OnPartDie(Part part)
{
if (autoAbort && part.vessel == vessel) {
Debug.Log ("LEST: Part Failure - " + part.partInfo.title);
vessel.ActionGroups.SetGroup (KSPActionGroup.Abort, true);
}
}
开发者ID:Kerbas-ad-astra,项目名称:RATPack,代码行数:7,代码来源:ModuleLESTrigger.cs
示例8: GetRandomPart
public static void GetRandomPart()
{
int numberOfAvailableParts = 7;
System.Random r = new System.Random();
switch (r.Next(numberOfAvailableParts))
{
case 0:
CurrPart = new I_Detail((int)Spawn.x, (int)Spawn.z);
break;
case 1:
CurrPart = new J_Detail((int)Spawn.x, (int)Spawn.z);
break;
case 2:
CurrPart = new L_Detail((int)Spawn.x, (int)Spawn.z);
break;
case 3:
CurrPart = new O_Detail((int)Spawn.x, (int)Spawn.z);
break;
case 4:
CurrPart = new S_Detail((int)Spawn.x, (int)Spawn.z);
break;
case 5:
CurrPart = new T_Detail((int)Spawn.x, (int)Spawn.z);
break;
case 6:
CurrPart = new Z_Detail((int)Spawn.x, (int)Spawn.z);
break;
default:
break;
}
}
开发者ID:NikiforovAll,项目名称:TetrisGame,代码行数:32,代码来源:Controller.cs
示例9: TranslatePart
public static void TranslatePart(GameObject[] partUnity, Part<SimpleCube> part)
{
for (int i = 0; i < partUnity.Length; i++)
{
Translate(partUnity[i], part.GetCubes[i]);
}
}
开发者ID:NikiforovAll,项目名称:TetrisGame,代码行数:7,代码来源:Controller.cs
示例10: GetScienceCount
private int GetScienceCount(Part part, bool IsCapacity)
{
try
{
int scienceCount = 0;
int capacity = 0;
foreach (PartModule pm in part.Modules)
{
// Containers.
if (pm is ModuleScienceContainer)
{
scienceCount += ((ModuleScienceContainer)pm).GetScienceCount();
capacity += ((ModuleScienceContainer)pm).capacity;
}
else if (pm is ModuleScienceExperiment)
{
scienceCount += ((ModuleScienceExperiment)pm).GetScienceCount();
capacity += 1;
}
}
if (IsCapacity)
return capacity;
else
return scienceCount;
}
catch (Exception ex)
{
ManifestUtilities.LogMessage(string.Format(" in GetScienceCount. Error: {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
return 0;
}
}
开发者ID:ragzilla,项目名称:ShipManifest,代码行数:32,代码来源:TransferController.cs
示例11: OnPartDie
void OnPartDie(Part p)
{
if(gameObject.activeInHierarchy)
{
StartCoroutine(DelayedCleanJammerListRoutine());
}
}
开发者ID:tetryds,项目名称:BDArmory,代码行数:7,代码来源:VesselECMJInfo.cs
示例12: calculateCoM
protected override void calculateCoM(Part part)
{
if (part.GroundParts ()) {
return;
}
Vector3 com;
if (!part.GetCoM (out com)) {
return;
}
/* add resource mass */
for (int i = 0; i < part.Resources.Count; i++) {
PartResource res = part.Resources [i];
if (!Resource.ContainsKey (res.info.name)) {
Resource [res.info.name] = new DCoMResource (res);
} else {
Resource [res.info.name].amount += res.amount;
}
}
/* calculate DCoM */
float m = part.GetSelectedMass();
vectorSum += com * m;
totalMass += m;
}
开发者ID:FormalRiceFarmer,项目名称:KerbalMods,代码行数:27,代码来源:DCoMMarker.cs
示例13: CanBeXferred
public static bool CanBeXferred(Part SelectedPart)
{
bool results = false;
try
{
if (SelectedPart == ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource)
{
// Source to target
// Are the parts capable of holding kerbals and are there kerbals to move?
if ((ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget != null && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource != ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget) && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource.protoModuleCrew.Count > 0)
{
// now, are the parts connected to each other in the same living space?
results = IsCLS();
}
}
else //SelectedPart must be SeletedPartTarget
{
// Target to Source
if ((ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource != null && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource != ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget) && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget.protoModuleCrew.Count > 0)
{
// now, are the parts connected to each other in the same living space?
results = IsCLS();
}
}
}
catch (Exception ex)
{
ManifestUtilities.LogMessage(string.Format(" in CanBeXferred. Error: {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
}
return results;
}
开发者ID:RealGrep,项目名称:ShipManifest,代码行数:32,代码来源:ShipManifestModule.cs
示例14: HackStrutCData
private static void HackStrutCData(ShipConstruct ship, Part p,
int part_base)
{
//Debug.Log (String.Format ("[EL] before {0}", p.customPartData));
string[] Params = p.customPartData.Split (';');
for (int i = 0; i < Params.Length; i++) {
string[] keyval = Params[i].Split (':');
string Key = keyval[0].Trim ();
string Value = keyval[1].Trim ();
if (Key == "tgt") {
string[] pnameval = Value.Split ('_');
string pname = pnameval[0];
int val = int.Parse (pnameval[1]);
if (val == -1) {
Strut strut = new Strut (p, Params);
if (strut.target != null) {
val = ship.parts.IndexOf (strut.target);
}
}
if (val != -1) {
val += part_base;
}
Params[i] = "tgt: " + pname + "_" + val.ToString ();
break;
}
}
p.customPartData = String.Join ("; ", Params);
//Debug.Log (String.Format ("[EL] after {0}", p.customPartData));
}
开发者ID:GlassFragments,项目名称:Extraplanetary-Launchpads,代码行数:29,代码来源:StrutFixer.cs
示例15: Set
protected virtual void Set(Part p, ReentrySimulation.SimCurves _simCurves)
{
Rigidbody rigidbody = p.rb;
totalMass = rigidbody == null ? 0 : rigidbody.mass; // TODO : check if we need to use this or the one without the childMass
shieldedFromAirstream = p.ShieldedFromAirstream;
noDrag = rigidbody == null && !PhysicsGlobals.ApplyDragToNonPhysicsParts;
hasLiftModule = p.hasLiftModule;
bodyLiftMultiplier = p.bodyLiftMultiplier * PhysicsGlobals.BodyLiftMultiplier;
simCurves = _simCurves;
cubes = new DragCubeList();
CopyDragCubesList(p.DragCubes, cubes);
// Rotation to convert the vessel space vesselVelocity to the part space vesselVelocity
vesselToPart = Quaternion.LookRotation(p.vessel.GetTransform().InverseTransformDirection(p.transform.forward), p.vessel.GetTransform().InverseTransformDirection(p.transform.up)).Inverse();
//DragCubeMultiplier = PhysicsGlobals.DragCubeMultiplier;
//DragMultiplier = PhysicsGlobals.DragMultiplier;
//if (p.dragModel != Part.DragModel.CUBE)
// MechJebCore.print(p.name + " " + p.dragModel);
//oPart = p;
}
开发者ID:CliftonMarien,项目名称:MechJeb2,代码行数:29,代码来源:SimulatedPart.cs
示例16: IsConnectedToModule
public static bool IsConnectedToModule(this Part currentPart, String partmodule, int maxChildDepth, Part previousPart = null)
{
bool found = currentPart.Modules.Contains(partmodule);
if (found)
return true;
if (currentPart.parent != null && currentPart.parent != previousPart)
{
bool foundPart = IsConnectedToModule(currentPart.parent, partmodule, maxChildDepth, currentPart);
if (foundPart)
return true;
}
if (maxChildDepth > 0)
{
foreach (var child in currentPart.children.Where(c => c != null && c != previousPart))
{
bool foundPart = IsConnectedToModule(child, partmodule, (maxChildDepth - 1), currentPart);
if (foundPart)
return true;
}
}
return false;
}
开发者ID:Kerbas-ad-astra,项目名称:KSPInterstellar,代码行数:25,代码来源:PartExtensions.cs
示例17: onPartDie
/// <summary>
/// If a part dies, rebuild the sphere
/// </summary>
void onPartDie(Part part)
{
// If there's no part or vessel, abort
if (part == null || part.vessel == null)
return;
// Get the CelestialBody
CelestialBody body = part.vessel.mainBody;
// Get the Vessel
Vessel vessel = part.vessel;
// Create the Deformation
Deformation deformation = new Deformation
{
position = Utility.LLAtoECEF(vessel.latitude, vessel.longitude, vessel.terrainAltitude, body.Radius),
vPos = vessel.vesselTransform.position,
altitude = vessel.terrainAltitude + body.Radius,
body = body,
surfaceSpeed = vessel.srfSpeed,
mass = part.mass + part.GetResourceMass(),
srfAngle = Vector3d.Angle(Vector3d.up, vessel.vesselTransform.forward)
};
deformations.Enqueue(deformation);
}
开发者ID:ThomasKerman,项目名称:Kerbal-Terrain-System,代码行数:28,代码来源:Controller.cs
示例18: GetThrustTorque
public static double GetThrustTorque(Part p, Vessel vessel)
{
if (p.State == PartStates.ACTIVE)
{
var gimbal = p.Modules.OfType<ModuleGimbal>().FirstOrDefault();
if (gimbal != null && !gimbal.gimbalLock)
{
var engine = p.Modules.OfType<ModuleEngines>().FirstOrDefault();
var fxengine = p.Modules.OfType<ModuleEnginesFX>().FirstOrDefault();
var magnitude = (p.Rigidbody.worldCenterOfMass - vessel.CoM).magnitude;
var gimbalRange = Math.Sin(Math.Abs(gimbal.gimbalRange));
var engineActive = engine != null && engine.isOperational;
var enginefxActive = fxengine != null && fxengine.isOperational;
if (engineActive)
{
return gimbalRange * engine.finalThrust * magnitude;
}
if (enginefxActive)
{
return gimbalRange * fxengine.finalThrust * magnitude;
}
}
}
return 0;
}
开发者ID:jwvanderbeck,项目名称:KOS_old,代码行数:29,代码来源:SteeringHelper.cs
示例19: TargetHelper
/// <param name="from">Object of comparison</param>
public TargetHelper(Part from)
{
selfPart = from;
self = selfPart.gameObject;
for (int i = 0; i < 100; i++)
moveToTargetSteps.Add(false);
}
开发者ID:hvacengi,项目名称:DockingCam,代码行数:8,代码来源:TargetHelper.cs
示例20: createGroup
public static bool createGroup(Part part, FXGroup group, string name, float distance, float spread, bool isloop, bool isLinearRolloff, bool bypassEffects)
{
if (name != string.Empty) {
if (!GameDatabase.Instance.ExistsAudioClip (name)) {
Debug.LogError ("[DynamicSFX] AudioFile " + name + " not found");
return false;
}
if(part == null)
{
group.audio = Camera.main.gameObject.AddComponent<AudioSource>();
}else{
group.audio = part.gameObject.AddComponent<AudioSource> ();
}
group.audio.dopplerLevel = 0f;
group.audio.panLevel = 1f;
group.audio.clip = GameDatabase.Instance.GetAudioClip (name);
group.audio.loop = isloop;
group.audio.maxDistance = distance;
group.audio.spread = spread;
group.audio.playOnAwake = false;
group.audio.bypassEffects = bypassEffects;
if (isLinearRolloff == true) {
group.audio.rolloffMode = AudioRolloffMode.Linear;
} else {
group.audio.rolloffMode = AudioRolloffMode.Logarithmic;
}
Debug.Log("[DynamicSFX] Added " + name + ".* in FXGroup " + group.name + " for Part = " + part.name);
return true;
}
return false;
}
开发者ID:ensou04,项目名称:DynamicSFX,代码行数:34,代码来源:AudioUtils.cs
注:本文中的Part类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论