跳到主要内容

Class Randomizer

Represents a random number generator.

Constructors

Randomizer(int seed)

public Randomizer(int seed)

Methods

Bool()

Returns a random bool value.

public bool Bool()

Range(int baseValue, int interval)

Returns a random int value in the range [baseValue-interval, baseValue+interval].

public int Range(int baseValue, int interval)

Int(int max)

Returns a random int value in the range [0, max).

public int Int(int max)

Int(int min, int max)

Returns a random int value in the range [min, max).

public int Int(int min, int max)

Int(Vector2Int range)

Returns a random int value in the range [range.x, range.y].

public int Int(Vector2Int range)

Pick<T>(T object1, T object2)

Randomly select one from object1 and object2.

public T Pick<T>(T object1, T object2)

Shuffle<T>(IList<T> list)

Shuffle the elements of a list. This method ensures that each element is no longer in its original position.

public void Shuffle<T>(IList<T> list)

Vector3(float min, float max)

Returns a random UnityEngine.Vector3.

public Vector3 Vector3(float min, float max)

Vector3(Vector3 min, Vector3 max)

Returns a random UnityEngine.Vector3.

public Vector3 Vector3(Vector3 min, Vector3 max)

Vector2(float min, float max)

Returns a random UnityEngine.Vector2.

public Vector2 Vector2(float min, float max)

Direction()

Returns a random 3D direction.

public Vector3 Direction()

Direction(Vector3 startDirection, float maxAngle, Vector3 axis)

public Vector3 Direction(Vector3 startDirection, float maxAngle, Vector3 axis)

Direction(Vector3 startDirection, Vector3 endDirection, [bool safe = true])

Returns a random 3D direction between startDirection and endDirection.

public Vector3 Direction(Vector3 startDirection, Vector3 endDirection, [bool safe = true])

Direction2D()

Returns a random 2D direction.

public Vector2 Direction2D()

Direction2D(Vector2 direction, float maxAngle, [bool safe = true])

Returns a random 2D direction by rotating direction by a random angle within the range [-maxAngle, +maxAngle].

public Vector2 Direction2D(Vector2 direction, float maxAngle, [bool safe = true])

Direction2D(Vector2 startDirection, Vector2 endDirection, [bool safe = true])

Returns a random 2D direction between startDirection and endDirection.

public Vector2 Direction2D(Vector2 startDirection, Vector2 endDirection, [bool safe = true])

Range(float baseValue, float interval)

Returns a random System.Single value in the range [baseValue-interval, baseValue+interval].

public float Range(float baseValue, float interval)

Float01()

Returns a random System.Single value in the range [0, 1).

public virtual float Float01()

Float(float max)

Returns a random System.Single value in the range [0, max].

public float Float(float max)

Float(float min, float max)

Returns a random System.Single value in the range [min, max].

public float Float(float min, float max)

Float(Vector2 range)

Returns a random System.Single value in the range [range.x, range.y].

public float Float(Vector2 range)

FloatNormalized()

Returns a random System.Single value in the range [-1, 1].

public float FloatNormalized()