本文整理汇总了C#中System.Random.NextVector2D方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextVector2D方法的具体用法?C# Random.NextVector2D怎么用?C# Random.NextVector2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.NextVector2D方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
private void Start()
{
// Initialize our rng
_random = new Random(Environment.TickCount + SeedAddition);
if (SpawnInitial)
{
// Spawn in a bunch of instances initially
var retryCount = 0;
while (_instances.Count < Count)
{
var pos = _random.NextVector2D(TargetCamera.position.Xyn(0), Distance);
// Make sure the instance can be spawned here
if (!IsValidSpawnPosition(pos))
{
retryCount++;
if (retryCount > 10)
{
Debug.LogWarning("Had to early-bail on spawning.");
break;
}
continue;
}
// Actually spawn the instance
var obj = Instantiate(Prefab);
obj.transform.position = pos;
obj.transform.parent = gameObject.transform;
_instances.Add(obj);
}
}
}
示例2: Transform1D
public void Transform1D()
{
// Transform forward and inverse and compare with initial values.
var random = new Random(1234567);
var s = new Vector2D[16];
var t = new Vector2D[16];
for (int i = 0; i < s.Length; i++)
{
s[i] = random.NextVector2D(-10, 10);
t[i] = s[i];
}
FastFourierTransformD.Transform1D(t, true);
FastFourierTransformD.Transform1D(t, false);
for (int i = 0; i < s.Length; i++)
Assert.IsTrue(Vector2D.AreNumericallyEqual(s[i], t[i]));
}
示例3: Transform1DAs2DColumn
public void Transform1DAs2DColumn()
{
// Result of 2D with one row/column must be the same as 1D.
var fft = new FastFourierTransformD(16);
var random = new Random(1234567);
var s1D = new Vector2D[16];
var s2D = new Vector2D[16, 1];
for (int i = 0; i < s1D.Length; i++)
{
s1D[i] = random.NextVector2D(-10, 10);
s2D[i, 0] = s1D[i];
}
FastFourierTransformD.Transform1D(s1D, true);
fft.Transform2D(s2D, true);
for (int i = 0; i < s1D.Length; i++)
Assert.AreEqual(s1D[i], s2D[i, 0]);
}
示例4: Transform2D
public void Transform2D()
{
// Transform forward and inverse and compare with initial values.
var random = new Random(1234567);
var s = new Vector2D[16, 8];
var t = new Vector2D[16, 8];
for (int i = 0; i < s.GetLength(0); i++)
{
for (int j = 0; j < s.GetLength(1); j++)
{
s[i, j] = random.NextVector2D(-10, 10);
t[i, j] = s[i, j];
}
}
var fft = new FastFourierTransformD(16);
fft.Transform2D(t, true);
Assert.IsFalse(Vector2D.AreNumericallyEqual(s[0, 0], t[0, 0]));
fft.Transform2D(t, false);
for (int i = 0; i < s.GetLength(0); i++)
for (int j = 0; j < s.GetLength(1); j++)
Assert.IsTrue(Vector2D.AreNumericallyEqual(s[i, j], t[i, j]));
}