/// <summary>
/// 固定数组中的不重复随机
/// </summary>
/// <param name="nums">数组</param>
/// <param name="count">要随机的个数</param>
/// <returns></returns>
public List<int> My_Random(List<int> Nums, int Count)
{
if (Count > Nums.Count)
{
//Debug.LogError("要取的个数大于数组长度!");(看需求更改)
// return null;
/Count=Nums.Count-1;
}
List<int> Result = new List<int>();
List<int> Undetermined = new List<int>();
for (int i = 0; i < Nums.Count; i++)
{
Undetermined.Add(i);
}
int Id;
while (Undetermined.Count > Nums.Count - Count)
{
Id = UnityEngine.Random.Range(0, Undetermined.Count);
Result.Add(Nums[Undetermined[Id]]);
Undetermined.Remove(Undetermined[Id]);
}
return (Result);
}