本文整理匯總了C#中System.Random.Pick方法的典型用法代碼示例。如果您正苦於以下問題:C# Random.Pick方法的具體用法?C# Random.Pick怎麽用?C# Random.Pick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Random
的用法示例。
在下文中一共展示了Random.Pick方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GenerateSuffix
private string GenerateSuffix(Random rand)
{
return rand.Pick<string>(new List<string>() { "Ages", "Bane", "Catastrophe", "Chaos", "Darkness", "Death", "Demons", "Despair", "Destruction", "Devils", "Disease", "Doom", "Eternal Night", "Eternity", "Hatred", "Horror", "Illusion", "Insanity", "Lost Souls", "Madness", "Magic", "Might", "Misery", "Mortality", "Nightmares", "No Escape", "Power", "Ruin", "Screams", "Secrets", "Shadows", "Sorrow", "Spite", "Suffering", "Valor", "War", "Winter", "Woe", "Worms", "Worry" });
}
示例2: GenerateLocation
private string GenerateLocation(Random rand)
{
return rand.Pick<string>(new List<string>() { "Catacomb", "Cave", "Caverns", "Chamber", "Chambers", "Crypt", "Den", "Dungeon", "Grotto", "Hill", "Hills", "Hole", "Labyrinth", "Lair", "Mausoleum", "Maze", "Mortuary", "Mount", "Mountain", "Mountains", "Pit", "Quarter", "Realm", "Tomb", "Tunnel", "Tunnels", "Vault", "Vaults", "Ways" });
}
示例3: GeneratePrefix
private string GeneratePrefix(Random rand)
{
return rand.Pick<string>(new List<string>() { "Amazing", "Amethyst", "Black", "Boiling", "Brilliant", "Broad", "Brutal", "Chaotic", "Crazy", "Cursed", "Dagger", "Dangerous", "Deadly", "Decayed", "Deep", "Dire", "Dying", "Emerald", "Eternal", "Evil", "False", "Forgotten", "Ghostly", "Giant", "Great", "Green", "Grizzly", "Haunted", "Hellish", "Hidden", "Icy", "Infernal", "Jade", "Lawful", "Mighty", "Misty", "Mysterious", "Rancid", "Red", "Rough", "Royal", "Scary", "Secluded", "Sword", "Tiny", "True", "Twisted", "Uncanny", "Unholy", "Unnamed", "Valiant", "Viscious", "Wailing", "Whispering" });
}
示例4: frmGame_Load
private void frmGame_Load(object sender, EventArgs e)
{
Rand = new Random();
// create the player.
Player = new Player();
// first, generate a name.
// name generator's...names from: http://www.goodsandgoodies.com/wq/bashwe-dungeonnames.pdf
switch (Rand.Pick<NameStructure>(new List<NameStructure>() { NameStructure.Prefix, NameStructure.Prefix2x, NameStructure.Suffix,
NameStructure.PrefixAndSuffix, NameStructure.Prefix2xAndSuffix }))
{
case NameStructure.Prefix:
this.Name = "The {0} {1}".FormatBy(GeneratePrefix(Rand), GenerateLocation(Rand));
break;
case NameStructure.Prefix2x:
this.Name = "The {0}-{1} {2}".FormatBy(GeneratePrefix(Rand), GeneratePrefix(Rand), GenerateLocation(Rand));
break;
case NameStructure.Suffix:
this.Name = "The {0} of {1}".FormatBy(GenerateLocation(Rand), GenerateSuffix(Rand));
break;
case NameStructure.PrefixAndSuffix:
this.Name = "The {0} {1} of {2}".FormatBy(GeneratePrefix(Rand), GenerateLocation(Rand), GenerateSuffix(Rand));
break;
case NameStructure.Prefix2xAndSuffix:
this.Name = "The {0}-{1} {2} of {3}".FormatBy(GeneratePrefix(Rand), GeneratePrefix(Rand), GenerateLocation(Rand), GenerateSuffix(Rand));
break;
}
// pick whether the dungeon is ascending or descending.
Direction = Rand.Pick<FloorDirection>(new List<FloorDirection>() { FloorDirection.Ascending, FloorDirection.Descending });
SetFloor();
SetPoints();
// set the grid up.
MapCells = new Cell[15, 10];
for (int x = 0; x < 15; x++)
{
for (int y = 0; y < 10; y++)
{
Label lbl = new Label();
lbl.Text = " ";
lbl.AutoSize = false;
lbl.Size = new System.Drawing.Size(46, 46);
lbl.Location = new Point(46 * x, 46 * y);
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Font = new System.Drawing.Font("Segoe UI", 16);
pnlGame.Controls.Add(lbl);
MapCells[x, y] = new Cell(lbl);
}
}
// play a random song.
PlayRandomSong();
// generate a new map and display.
GenerateNewMap();
Update();
}