本文整理汇总了C#中Part类的典型用法代码示例。如果您正苦于以下问题:C# Part类的具体用法?C# Part怎么用?C# Part使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Part类属于命名空间,在下文中一共展示了Part类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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!");
}
}
示例2: AnimatedNode
public AnimatedNode(AttachNode node, Transform node_transform, Part part)
{
this.node = node;
this.part = part;
nT = node_transform;
pT = part.partTransform;
}
示例3: FlyingCamera
public FlyingCamera(Part thatPart, RenderTexture screen, float aspect)
{
ourVessel = thatPart.vessel;
ourPart = thatPart;
screenTexture = screen;
cameraAspect = aspect;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
}
示例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]);
}
}
示例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;
}
}
示例11: OnPartDie
void OnPartDie(Part p)
{
if(gameObject.activeInHierarchy)
{
StartCoroutine(DelayedCleanJammerListRoutine());
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}