本文整理汇总了C#中Components.getJoints方法的典型用法代码示例。如果您正苦于以下问题:C# Components.getJoints方法的具体用法?C# Components.getJoints怎么用?C# Components.getJoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Components
的用法示例。
在下文中一共展示了Components.getJoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanMove
public static bool CanMove(Components.Component c, Vector2 pos)
{
if (c == null) return false;
var s = c.Graphics.GetSizeRotated(c.ComponentRotation);
Rectangle r1 = new Rectangle((int)pos.X, (int)pos.Y, (int)s.X, (int)s.Y);
r1.Inflate(8, 8);
Rectangle r2 = new Rectangle();
var j = c.getJoints();
if (j == null) return false;
List<int> jcw = new List<int>();//joints connected wires
for (int i = 0; i < j.Length; i++)
{
var a = Components.ComponentsManager.GetComponent(j[i]) as Components.Joint;
if (a != null)
{
for (int jj = 0; jj < a.ConnectedWires.Count; jj++)
{
jcw.Add(a.ConnectedWires[jj].ID);
}
}
}
bool b;
foreach (var c2 in Components.ComponentsManager.Components)
{
if (c2 == c || c2 == null || c2 is Components.EmptyComponent)
continue;
if (!c2.Graphics.Visible)
continue;
for (int i = 0; i < j.Length; i++)
if (c2.ID == j[i])
goto EndCheck;
for (int i = 0; i < jcw.Count; i++)
if (c2.ID == jcw[i])
goto EndCheck;
if (c2 is Components.Wire)
if ((c2.Graphics as Components.Graphics.WireGraphics).Intersects(r1))
return false;
s = c2.Graphics.GetSizeRotated(c.ComponentRotation);
r2 = new Rectangle((int)c2.Graphics.Position.X, (int)c2.Graphics.Position.Y, (int)s.X, (int)s.Y);
b = r2.Contains(r1);
if (b && !(c2 is Components.Properties.IContainer))
return false;
if (!b && r1.Intersects(r2))
return false;
if (r1.Contains(r2))
return false;
EndCheck: ;
}
return true;
}