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


C# Random.getInt方法代码示例

本文整理汇总了C#中System.Random.getInt方法的典型用法代码示例。如果您正苦于以下问题:C# Random.getInt方法的具体用法?C# Random.getInt怎么用?C# Random.getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Random的用法示例。


在下文中一共展示了Random.getInt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateLotsOfStitchMaps

 public void GenerateLotsOfStitchMaps()
 {
     Random random = new Random();
     for (int i = 0; i < NumberOfMapsToGenerate; i++)
     {
         StitchtogeatherMapGenerator generator = new StitchtogeatherMapGenerator(random); 
         Map map = generator.GenerateMap(null, random.getInt(0, MaxLevelOfLevelToGenerate));
         Assert.IsNotNull(map);
     }
 }
开发者ID:donblas,项目名称:magecrawl,代码行数:10,代码来源:MapGenerationTests.cs

示例2: WelcomeWindow

        public WelcomeWindow()
        {
            m_dialogHelper = new DialogColorHelper();
            m_console = TCODConsole.root;
            m_random = new Random();
            m_windowResult = new Result();

            m_currentElementPointedTo = (MagicTypes)m_random.getInt(0, 6);    // Pick a random element to start on.

            m_flavorText = new Dictionary<MagicTypes, string>();
            m_flavorText[MagicTypes.Fire] = "Passionate fire-based magic. Aggressive front loaded damage. Weaker in magic requiring more finesse.";
            m_flavorText[MagicTypes.Water] = "As seen in the seas, water can both protect and destory life with ease. Icey effects also slow and disable.";
            m_flavorText[MagicTypes.Air] = "Born from the wind, air-based magic can enchant, entice, and when necessary strike with thunder and hail.";
            m_flavorText[MagicTypes.Earth] = "Sturdy and dependable, the earth excels in defense and striking nearby foes with the force of a landslide.";
            m_flavorText[MagicTypes.Light] = "Gifted from the Creator. Light magic is best at mending wounds, summoning aid and protection. Strong at smiting unholy abominations.";
            m_flavorText[MagicTypes.Darkness] = "Darkness magic is drawn from a pure lust for power. A mockery of the light, capable of producing much pain, summoning forbidden aid, and raising the dead to serve.";
            m_flavorText[MagicTypes.Arcane] = "Arcane magic is born from altering the fabric of reality. Infinitely flexible and neutral to all other school of magic.";

            m_mainText = new Dictionary<MagicTypes, string>();
            m_mainText[MagicTypes.Fire] = "It is our passions that seperate us from the other schools, our passion for life, our passion for knowledges, our passion for power.\n\nIt is your fiery passion that brought you to this school. Your instructors will shape your unrefined passion into power. Power to shape even the very flames beneath this mountain. \n\nTo be a pyromancer is to be channel forces so great as to be nearly out of control and yet hold onto it with your very will.\n\nRemember this as you enter these halls, as many have before you.\n\n\n\n\n\n\nSenior Pyromancer Nathan\nWelcoming Ceremony\n372 CT";
            m_mainText[MagicTypes.Water] = "And this exhibit is the famous painting of the battle of Hillsbrad Harbor. During the 2nd revolution in CT 291, this town was stormed by a small navy backed up by a large elemental force, as you can see here.\n\nWater wisps, ice demons, and even elder water elementals were summoned by the Archmage Danel II. Look at the exquisite detail of the background storm. The full force a hurricane force winds were leveled against the defenders, and is captured here.\n\nIt was painted at the height of the artist's career. Now on the left is...\n\n\n\n\n\nExcerpt from a tour\nRoyal Museum of Art, Dalundor\nCT 382";
            m_mainText[MagicTypes.Air] = "While traveling via the sea, many remember to visit the Brotherhood of Water for charms and scrolls to speed their journey. You would be wise not to forget the power of the wind. Even with a calm sea, the wind is what truly carries you.\nSome the the product we offer the public inclued:\n\n\nScroll of Strengthen Wind......50G\n\nScroll of Witch Wind..........100G\n\nWand of Calm Storm............275G\n\nWand of Lightning Bolt........500G\n\nServices of Air Mage......500G/day\n\n\nCome see us today!\n\nAirbone Services\nLocated in Arcane district next to the west gate.";
            m_mainText[MagicTypes.Earth] = "Tips when traveling to planes of Earth\n\n* 37 planes of earth have been mapped sufficiently well enough that bringing a map will do more help than harm.\n\n* Seven of these planes are partially molten, so bring a fire mage or resist elements scrolls.\n\n* While many will travel in search of precious metals and gems, removal of large quantites of materal can rouse angry elementals.\n\n* Bring scrolls of fresh air and potions of burrowing in case of cave-ins.\n\n* Remember a light source that doesn't require air, such as glowstones or coldfire torches.\n\n\nGuild of Earth Mages";
            m_mainText[MagicTypes.Light] = "In the beginning the Creator created many worlds. Some demi-planes of raw elements, others fully formed and seeded with life. While mages from all schools have explored a few of these planes, many questions remain.\n\nWhy are some more formed than others? Why did the Creator leave His fingerprints on creation so obviously, and then never act again?\n\nThe tenants of the school of light magic are based upon what we can glean about the Creator and planes of positive energy.\n\nHowever, unless the Creator returns to impart knowledge about itself, there is precious little we can know for certain.\n\n\n\nThoughts on Creation\nAugus\nCT 169";
            m_mainText[MagicTypes.Darkness] = "Jonathan,\n\n     You were right, those hidden manuscripts we found were truthful. While I have not found the tomb yet, this swamp is full of power. The dead walk, wondering (patrolling?) near this bog, the very air is filled with a dread power stronger than anything at the academy.\n\nOnce I find the tomb, the spellbooks of the Lich Algmon shall be ours. With them, the power to shape the world. Those fools who speak of restraint or treaties lack the will to act. That is one thing we do not lack.\n\nAs soon as you can slip away, locate me using the charm attached. We can continue the search.\n\n\n\nMarie\nCT 381";
            m_mainText[MagicTypes.Arcane] = "Magic in its purest form is a sentient being pressing their will against nature. More accurately, their will distorts the weave of creation. By understanding this weave, a student of the arcane can wield force alone as their weapon, as opposed to crude elemental magics.\n\nWith study, the amount of distortion one can force into the weave before it \"snaps\" back and ruins a spell increases.\n\nThis textbook will provide an introduction to Arcane magic. The study of the arcane provides both an excellent foundation for future studies in other areas and a path to high magic in itself.\n\n\nModern Exploration of the Weave: An Introduction to Modern Arcane theory\nPage 3\nDavid C. Fellow";

            m_spellLists = new Dictionary<MagicTypes, List<string>>();
            m_spellLists[MagicTypes.Fire] = new List<string>() { "Firebolt", "Warmth", "Fireblast", "Fireball", "Wall Of Fire", "Firestorm" };
            m_spellLists[MagicTypes.Water] = new List<string>() { "Cold Snap", "Icy Armor", "Frigid Aura", "Ice Bolt", "Shatter", "Cone Of Cold" };
            m_spellLists[MagicTypes.Air] = new List<string>() { "Shock", "Swiftness", "Confuse", "Lightning Bolt", "Storm Armor", "Hurricane" };
            m_spellLists[MagicTypes.Earth] = new List<string>() { "Stone Armor", "Aftershock", "Strength Of The Earth", "Stoneskin", "Summon Earth Elemental", "Earthquake" };
            m_spellLists[MagicTypes.Light] = new List<string>() { "Mend", "Smite", "Armor of Light", "Heal", "Summon Archon", "Wrath" };
            m_spellLists[MagicTypes.Darkness] = new List<string>() { "Pain", "Drain Life", "Raise Dead", "Darkness", "Summon Wraith", "Lich Form" };
            m_spellLists[MagicTypes.Arcane] = new List<string>() { "Force Bolt", "Arcane Armor", "Blink", "Slow", "Destructive Teleport", "Wave of Force" };

            GetListOfSaveFiles();
            m_lowerRange = 0;
            m_cursorPosition = -1;
            m_isScrollingNeeded = m_fileNameList.Count > NumberOfSaveFilesToList;
        }
开发者ID:donblas,项目名称:magecrawl,代码行数:41,代码来源:WelcomeWindow.cs

示例3: HandleRandomTeleport

        private bool HandleRandomTeleport(Character caster, int range)
        {
            List<EffectivePoint> targetablePoints = PointListUtils.EffectivePointListFromBurstPosition(caster.Position, range);
            CoreGameEngine.Instance.FilterNotTargetablePointsFromList(targetablePoints, caster.Position, caster.Vision, false);

            // If there's no where to go, we're done
            if (targetablePoints.Count == 0)
                return true;
            Random random = new Random();
            int element = random.getInt(0, targetablePoints.Count - 1);
            EffectivePoint pointToTeleport = targetablePoints[element];
            CoreGameEngine.Instance.SendTextOutput(string.Format("Things become fuzzy as {0} shifts into a new position.", caster.Name));
            m_physicsEngine.WarpToPosition(caster, pointToTeleport.Position);
            return true;
        }
开发者ID:donblas,项目名称:magecrawl,代码行数:15,代码来源:MagicEffectsEngine.cs

示例4: ClearMonstersFromStartingArea

        private void ClearMonstersFromStartingArea(Point initialStairsUpPosition)
        {
            List<Point> monsterFreePoints = PointListUtils.PointListFromBurstPosition(initialStairsUpPosition, 8);

            Random random = new Random();
            bool[,] moveablePoints = m_dungeon[0].CalculateMoveablePointGrid(true, initialStairsUpPosition);
            foreach(Monster monsterToMove in m_dungeon[0].Monsters.Where(m => monsterFreePoints.Contains(m.Position)).OfType<Monster>())
            {
                int attempts = 0;
                while (true)
                {
                    int possibleX = random.getInt(0, m_dungeon[0].Width - 1);
                    int possibleY = random.getInt(0, m_dungeon[0].Height - 1);
                    if (moveablePoints[possibleX, possibleY])
                    {
                        monsterToMove.Position = new Point(possibleX, possibleY);
                        moveablePoints[possibleX, possibleY] = false;
                        break;
                    }
                    else
                    {
                        attempts++;
                    }

                    // If we try 10000 random points and fail, throw an exception, since something is seriously wrong
                    if (attempts > 10000)
                        throw new MapGenerationFailureException("ClearMonstersFromStartingArea can't find spot to move monster");
                }
            }
        }
开发者ID:donblas,项目名称:magecrawl,代码行数:30,代码来源:CoreGameEngine.cs


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