本文整理汇总了C#中Vector.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Distance方法的具体用法?C# Vector.Distance怎么用?C# Vector.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.Distance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(float timeDelta)
{
if (EnemiesGenerationPoints.Count == 0)
{
return;
}
if (World.Enemies.Count < MaxEnemiesCount)
{
// todo need refactoring here
m_timeDelta += timeDelta;
if (m_timeDelta < EnemyGenerationPeriod)
{
return;
}
m_timeDelta = 0.0f;
int randPosition = m_random.Next(0, (EnemiesGenerationPoints.Count));
var selectedPoint = EnemiesGenerationPoints[randPosition];
var location = new Vector(selectedPoint.X, selectedPoint.Y);
if (World.Enemies.Count == 0)
{
AddEnemy(selectedPoint);
}
else
{
bool ok = true;
foreach (var enemy in World.Enemies)
{
if (location.Distance(enemy.Location) < 1.0)
{
ok = false;
}
}
if (ok)
{
AddEnemy(selectedPoint);
}
}
}
}
示例2: FillCircle
/// <summary>
/// Fill Circle
/// </summary>
/// <param name="Center"></param>
/// <param name="Radius"></param>
/// <param name="Value"></param>
public void FillCircle(Vector.FxVector2f center, float radius, float Value)
{
// Create a rectangle that we are going to fill
FxVector2i StartVect = new FxVector2i(center.x - radius, center.y - radius);
FxVector2i EndVect = new FxVector2i(center.x + radius, center.y + radius);
for (int x = StartVect.x; x < EndVect.x; x++)
for (int y = StartVect.y; y < EndVect.y; y++)
{
if (x >= 0 && x < Width && y >= 0 && y < Height)
{
float dist = center.Distance(x, y);
if (dist < radius)
{
float a = (radius - dist) / radius;
this[x, y] = a * Value;
}
}
}
}
示例3: TestOrthogonalDistance
public void TestOrthogonalDistance()
{
var v1 = new Vector<string, double> { { "x", 1 } };
var v2 = new Vector<string, double> { { "y", 1 } };
v1.Distance(v2).ShouldEqual(1.0);
}
示例4: TestSelfDistance
public void TestSelfDistance()
{
var v = new Vector<string, double> { { "x", 1 } };
v.Distance(v).ShouldEqual(0);
}
示例5: TestOppositeDistance
public void TestOppositeDistance()
{
var v1 = new Vector<string, double> { { "x", 1 } };
var v2 = new Vector<string, double> { { "x", -1 } };
v1.Distance(v2).ShouldEqual(2.0);
}