当前位置: 首页>>代码示例>>C#>>正文


C# Random.Pick方法代码示例

本文整理汇总了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" });
 }
开发者ID:CarimA,项目名称:AC22005-Array-Game,代码行数:4,代码来源:frmGame.cs

示例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" });
 }
开发者ID:CarimA,项目名称:AC22005-Array-Game,代码行数:4,代码来源:frmGame.cs

示例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" });
 }
开发者ID:CarimA,项目名称:AC22005-Array-Game,代码行数:4,代码来源:frmGame.cs

示例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();
        }
开发者ID:CarimA,项目名称:AC22005-Array-Game,代码行数:63,代码来源:frmGame.cs


注:本文中的System.Random.Pick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。