本文整理汇总了C#中Vector3D.SetDim方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3D.SetDim方法的具体用法?C# Vector3D.SetDim怎么用?C# Vector3D.SetDim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3D
的用法示例。
在下文中一共展示了Vector3D.SetDim方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AcquireTarget
public void AcquireTarget(ZACommons commons)
{
// Find the sole text panel
var panelGroup = commons.GetBlockGroupWithName("CM Target");
if (panelGroup == null)
{
throw new Exception("Missing group: CM Target");
}
var panels = ZACommons.GetBlocksOfType<IMyTextPanel>(panelGroup.Blocks);
if (panels.Count == 0)
{
throw new Exception("Expecting at least 1 text panel");
}
var panel = panels[0] as IMyTextPanel; // Just use the first one
var targetString = panel.GetPublicText();
// Parse target info
var parts = targetString.Split(';');
if (parts.Length != 3)
{
throw new Exception("Expecting exactly 3 parts to target info");
}
Target = new Vector3D();
for (int i = 0; i < 3; i++)
{
Target.SetDim(i, double.Parse(parts[i]));
}
}
示例2: Init
public void Init(ZACommons commons, EventDriver eventDriver)
{
var previous = commons.GetValue(LOSMinerKey);
if (previous != null)
{
var parts = previous.Split(';');
if (parts.Length == 13)
{
// Resume original mode and line-of-sight vector
var newMode = int.Parse(parts[0]);
StartPoint = new Vector3D();
StartDirection = new Vector3D();
StartUp = new Vector3D();
StartLeft = new Vector3D();
for (int i = 0; i < 3; i++)
{
StartPoint.SetDim(i, double.Parse(parts[i+1]));
StartDirection.SetDim(i, double.Parse(parts[i+4]));
StartUp.SetDim(i, double.Parse(parts[i+7]));
StartLeft.SetDim(i, double.Parse(parts[i+10]));
}
if (newMode == MINING)
{
Start((ShipControlCommons)commons, eventDriver);
}
else if (newMode == REVERSING)
{
StartReverse((ShipControlCommons)commons, eventDriver);
}
}
}
}
示例3: ParseVector
private bool ParseVector(out Vector3D position, string x, string y, string z)
{
position = new Vector3D(0);
string[] args = { x, y, z };
double d;
for (int i = 0; i < 3; i++)
{
if (double.TryParse(args[i], out d))
{
position.SetDim(i, d);
}
else
{
Log.Error("Invalid double value: " + args[i]);
return false;
}
}
return true;
}
示例4: Init
public void Init(ZACommons commons, EventDriver eventDriver)
{
UndockTarget = null;
var previousTarget = commons.GetValue(UndockTargetKey);
if (previousTarget != null)
{
var parts = previousTarget.Split(';');
if (parts.Length == 9)
{
var newTarget = new Vector3D();
UndockForward = new Vector3D();
UndockUp = new Vector3D();
for (int i = 0; i < 3; i++)
{
newTarget.SetDim(i, double.Parse(parts[i]));
UndockForward.SetDim(i, double.Parse(parts[3+i]));
UndockUp.SetDim(i, double.Parse(parts[6+i]));
}
UndockTarget = newTarget; // Set only if all successfully parsed
}
}
UndockBackward = null;
var backwardString = commons.GetValue(BackwardKey);
if (backwardString != null)
{
// Enum.Parse apparently works, but I don't trust Keen
// not breaking it in the future (by making typeof() illegal)
//UndockBackward = (Base6Directions.Direction)Enum.Parse(typeof(Base6Directions.Direction), backwardString);
UndockBackward = (Base6Directions.Direction)byte.Parse(backwardString);
}
Mode = IDLE;
var modeString = commons.GetValue(ModeKey);
if (modeString != null)
{
Mode = int.Parse(modeString);
switch (Mode)
{
case IDLE:
break;
case UNDOCKING:
if (UndockTarget != null && UndockBackward != null)
{
BeginUndock(commons, eventDriver);
}
else ResetMode(commons);
break;
case RETURNING:
if (UndockTarget != null)
{
BeginReturn(commons, eventDriver);
}
else ResetMode(commons);
break;
case ORIENTING:
if (UndockTarget != null)
{
ReorientStart(commons, eventDriver);
}
else ResetMode(commons);
break;
}
}
}
示例5: AcquireTarget
// Acquire target from CM Target text panel. If anything's wrong,
// return null.
private Vector3D? AcquireTarget(ZACommons commons)
{
// Find the sole text panel
var panelGroup = commons.GetBlockGroupWithName("CM Target");
if (panelGroup == null) return null;
var panels = ZACommons.GetBlocksOfType<IMyTextPanel>(panelGroup.Blocks);
if (panels.Count == 0) return null;
var panel = panels[0] as IMyTextPanel; // Just use the first one
var targetString = panel.GetPublicText();
// Parse target info
var parts = targetString.Split(';');
if (parts.Length != 3) return null;
var target = new Vector3D();
for (int i = 0; i < 3; i++)
{
double coord;
if (!double.TryParse(parts[i], out coord)) return null;
target.SetDim(i, coord);
}
return target;
}