YourList.OrderBy(x => rnd.Next()).Take(8)
public static List<T> GetRandomElements<T>(this IEnumerable<T> list, int elementsCount)
{
return list.OrderBy(arg => Guid.NewGuid()).Take(elementsCount).ToList();
}
var pack = player.Backpack();
var seed = randomstring.GetHashCode();
var random = new Random(seed);
var types = new List<Type>() { typeof(Shoe), typeof(Cloak), typeof(Dagger), typeof(Sword), typeof(MagicStaff), etc... };
var toGive = types.OrderBy(x => random.Next())Take(8).ToList();
foreach (Type t in toGive)
{
Item item = (Item)Activator.CreateInstance(t);
if (item != null) pack.DropItem(item);
}
var toGive = types.OrderBy(x => random.Next())Take(8).ToList();
var pack = m.Backpack();
var seed = randomstring.GetHashCode();
var random = new Random(seed);
var types = new List<Type>() { typeof(Shoe), typeof(Cloak), typeof(Dagger), typeof(Sword), typeof(MagicStaff)};
var toGive = types.OrderBy(x => random.Next())Take(8).ToList();
foreach (Type t in toGive)
{
Console.WriteLine("Debug line Type t in toGive");
Item item = (Item)Activator.CreateInstance(t);
if (item != null) pack.DropItem(item);
}
var pack = m.Backpack(); //line 606
var seed = randomstring.GetHashCode(); /line 607
We use essential cookies to make this site work, and optional cookies to enhance your experience.