本文整理汇总了C#中ICollection.Random方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.Random方法的具体用法?C# ICollection.Random怎么用?C# ICollection.Random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.Random方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveTo
/// <summary>
/// Moves all of the Danmaku in the collection to random 2D points specified by a array of 2D positions.
/// </summary>
/// <remarks>
/// Positions are chosen randomly and independently for each Danmaku from a uniform distribution.
/// This function is not thread-safe: it can only be called from the Unity main thread as it utilizes Unity API calls.
/// All contained null objects will be ignored.
/// See: <see cref="Danmaku.Position"/>
/// </remarks>
/// <param name="danmakus">The enumerable collection of Danmaku. Will throw NullReferenceException if null.</param>
/// <param name="positions">the potential positions to move the contained danmaku to, in absolute world coordinates.</param>
/// <exception cref="ArgumentNullException">Thrown if the position array is null.</exception>
public static IEnumerable<Danmaku> MoveTo(this IEnumerable<Danmaku> danmakus, ICollection<Vector2> positions, Func<Danmaku, bool> filter = null)
{
if (positions == null)
throw new ArgumentNullException("positions");
return danmakus.ForEach(x => x.Position = positions.Random(), filter);
}
示例2: Color
public static IEnumerable<Danmaku> Color(this IEnumerable<Danmaku> danmakus, ICollection<Color> colors, Func<Danmaku, bool> filter = null)
{
if (colors == null)
throw new ArgumentNullException("colors");
return danmakus.ForEach(x => x.Color = colors.Random(), filter);
}
示例3: Damage
public static IEnumerable<Danmaku> Damage(this IEnumerable<Danmaku> danmakus, ICollection<int> damages, Func<Danmaku, bool> filter = null)
{
return danmakus.ForEach(x => x.AngularSpeed = damages.Random(), filter);
}
示例4: AngularSpeed
public static IEnumerable<Danmaku> AngularSpeed(this IEnumerable<Danmaku> danmakus,
ICollection<float> angularSpeeds,
Func<Danmaku, bool> filter = null)
{
return danmakus.ForEach(x => x.AngularSpeed = angularSpeeds.Random(), filter);
}
示例5: Speed
public static IEnumerable<Danmaku> Speed(this IEnumerable<Danmaku> danmakus, ICollection<float> speeds, Func<Danmaku, bool> filter = null)
{
if (speeds == null)
throw new ArgumentNullException("speeds");
return danmakus.ForEach(x => x.Speed = speeds.Random(), filter);
}
示例6: RotateTo
public static IEnumerable<Danmaku> RotateTo(this IEnumerable<Danmaku> danmakus,
ICollection<float> rotations,
Func<Danmaku, bool> filter = null)
{
if (rotations == null)
throw new ArgumentNullException("rotations");
return danmakus.ForEach(x => x.Rotation = rotations.Random(), filter);
}