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


C# Dice.rollRange方法代码示例

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


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

示例1: genRandomSysName

 /// <summary>
 /// This generates a random name for a star system
 /// </summary>
 /// <param name="prefix">The prefix for the generator</param>
 /// <param name="ourDice">Dice used in rolling</param>
 /// <returns>A random name for a star system</returns>
 public static string genRandomSysName(string prefix, Dice ourDice)
 {
     return (prefix + Math.Round(ourDice.rollRange(0, 1) * 1000000000, 0));
 }
开发者ID:KoihimeNakamura,项目名称:CelestialNavigation,代码行数:10,代码来源:libStarGen.cs

示例2: placeOurStars

        /// <summary>
        /// This places our stars around the primary, as well as creating the secondary stars if called for
        /// </summary>
        /// <param name="ourSystem">The star system to be added to.</param>
        /// <param name="velvetBag">Our dice object.</param>
        public static void placeOurStars(StarSystem ourSystem, Dice velvetBag)
        {
            int roll = 0;

                //initiate the variables we need to ensure distances are kept
                double minOrbitalDistance = 0.0, maxOrbitalDistance = 600.0, tempVal = 0.0;
                int starLimit = ourSystem.sysStars.Count;
                for (int i = 1; i < starLimit; i++)
                {
                    int modifiers = 0;
                    minOrbitalDistance = ourSystem.sysStars[i - 1].orbitalRadius;

                    //set the min and max conditions for the first star here.
                    if (ourSystem.sysStars[i].parentID == 0 || ourSystem.sysStars[i].parentID == Star.IS_PRIMARY)
                    {
                        //apply modifiers
                        if (ourSystem.sysStars[i].selfID == Star.IS_TRINARY) modifiers = modifiers + 6;
                        if (OptionCont.forceGardenFavorable && ourSystem.sysStars[i].parentID == Star.IS_PRIMARY) modifiers = modifiers + 4;

                        if (minOrbitalDistance == 600.0)
                        {
                            //in this situation, orbital 3 or so can't be safely placed because the range is 0.
                            // so we autogenerate it.
                            tempVal = velvetBag.rollRange(25, 25);
                            ourSystem.sysStars[i].orbitalSep = 5;
                            ourSystem.sysStars[ourSystem.star2index].orbitalRadius = ourSystem.sysStars[ourSystem.star2index].orbitalRadius - tempVal;
                            ourSystem.sysStars[i].orbitalRadius = 600 + tempVal;
                            ourSystem.sysStars[i].distFromPrimary = ourSystem.sysStars[i].orbitalRadius;
                            minOrbitalDistance = ourSystem.sysStars[i].orbitalRadius;
                        }
                        else
                        {
                            do
                            {
                                double lowerBound = 0.0;
                                double higherBound = 0.0;

                                //roll the dice and generate the orbital radius
                                do
                                {
                                    roll = velvetBag.gurpsRoll(modifiers);
                                    if (roll <= 6) ourSystem.sysStars[i].orbitalSep = Star.ORBSEP_VERYCLOSE;
                                    if (roll >= 7 && roll <= 9) ourSystem.sysStars[i].orbitalSep = Star.ORBSEP_CLOSE;
                                    if (roll >= 10 && roll <= 11) ourSystem.sysStars[i].orbitalSep = Star.ORBSEP_MODERATE;
                                    if (roll >= 12 && roll <= 14) ourSystem.sysStars[i].orbitalSep = Star.ORBSEP_WIDE;
                                    if (roll >= 15) ourSystem.sysStars[i].orbitalSep = Star.ORBSEP_DISTANT;
                                    tempVal = velvetBag.rng(2, 6) * libStarGen.getSepModifier(ourSystem.sysStars[i].orbitalSep);
                                } while (tempVal <= minOrbitalDistance);

                                //if (ourSystem.sysStars[i].selfID == 2) tempVal = this.velvetBag.six(1, 7) * ourSystem.sysStars[i].getSepModifier();
                                lowerBound = tempVal - .5 * libStarGen.getSepModifier(ourSystem.sysStars[i].orbitalSep);
                                higherBound = .5 * libStarGen.getSepModifier(ourSystem.sysStars[i].orbitalSep) + tempVal;

                                //set for constraints
                                if (lowerBound < minOrbitalDistance) lowerBound = minOrbitalDistance;
                                if (higherBound > maxOrbitalDistance) higherBound = maxOrbitalDistance;

                                ourSystem.sysStars[i].orbitalRadius = tempVal;
                                ourSystem.sysStars[i].distFromPrimary = ourSystem.sysStars[i].orbitalRadius;

                            } while (ourSystem.sysStars[i].orbitalRadius <= minOrbitalDistance);

                            //let's see if it has a subcompanion
                            if (ourSystem.sysStars[i].orbitalSep == Star.ORBSEP_DISTANT)
                            {
                                roll = velvetBag.gurpsRoll();
                                if (roll >= 11)
                                {
                                    //generate the subcompanion
                                    int order = 0;

                                    if (ourSystem.sysStars[i].selfID == Star.IS_SECONDARY) order = Star.IS_SECCOMP;
                                    if (ourSystem.sysStars[i].selfID == Star.IS_TRINARY) order = Star.IS_TRICOMP;

                                    //add the star
                                    ourSystem.addStar(order, ourSystem.sysStars[i].selfID, (i + 1));

                                    ourSystem.sysStars[starLimit].name = Star.genGenericName(ourSystem.sysName, (i + 1));

                                    //set the name, then generate the star
                                    ourSystem.sysStars[starLimit].parentName = ourSystem.sysStars[i].name;
                                    libStarGen.generateAStar(ourSystem.sysStars[starLimit], velvetBag, ourSystem.sysStars[i].currMass, ourSystem.sysName);
                                    starLimit++; //increment the total number of stars we have generated
                                }

                            }
                        }
                    }
                    else
                    {
                        minOrbitalDistance = 0;
                        maxOrbitalDistance = ourSystem.sysStars[ourSystem.getStellarParentID(ourSystem.sysStars[i].parentID)].orbitalRadius;
                        //roll for seperation
                        do
                        {
//.........这里部分代码省略.........
开发者ID:KoihimeNakamura,项目名称:CelestialNavigation,代码行数:101,代码来源:libStarGen.cs

示例3: updateTidalLock

        /// <summary>
        /// Updates a satellite for tidal lock
        /// </summary>
        /// <param name="s">The satelite </param>
        /// <param name="ourBag">Our dice object</param>
        public static void updateTidalLock(Satellite s, Dice ourBag)
        {
            int atmDesc = s.getAtmCategory();

            if (atmDesc == Satellite.ATM_PRES_NONE || atmDesc == Satellite.ATM_PRES_TRACE)
            {
                s.updateAtmPres(0.00);
                s.hydCoverage = 0.0;
                s.dayFaceMod = 1.2;
                s.nightFaceMod = .1;
            }

            if (atmDesc == Satellite.ATM_PRES_VERYTHIN)
            {
                s.updateAtmPres(0.01);
                s.hydCoverage = 0.0;
                s.dayFaceMod = 1.2;
                s.nightFaceMod = .1;
            }

            if (atmDesc == Satellite.ATM_PRES_THIN)
            {
                s.updateAtmPres(ourBag.rollRange(.01, .49));

                s.hydCoverage = s.hydCoverage - .5;
                if (s.hydCoverage < 0) s.hydCoverage = 0.0;

                s.dayFaceMod = 1.16;
                s.nightFaceMod = .67;
            }

            if (atmDesc == Satellite.ATM_PRES_STANDARD)
            {
                s.hydCoverage = s.hydCoverage - .25;
                if (s.hydCoverage < 0) s.hydCoverage = 0.0;

                s.dayFaceMod = 1.12;
                s.nightFaceMod = .80;
            }

            if (atmDesc == Satellite.ATM_PRES_DENSE)
            {
                s.hydCoverage = s.hydCoverage - .1;
                if (s.hydCoverage < 0) s.hydCoverage = 0.0;
                s.dayFaceMod = 1.09;
                s.nightFaceMod = .88;
            }

            if (atmDesc == Satellite.ATM_PRES_VERYDENSE)
            {
                s.dayFaceMod = 1.05;
                s.nightFaceMod = .95;
            }

            if (atmDesc == Satellite.ATM_PRES_SUPERDENSE)
            {
                s.dayFaceMod = 1.0;
                s.nightFaceMod = 1.0;
            }
        }
开发者ID:KoihimeNakamura,项目名称:CelestialNavigation,代码行数:65,代码来源:libStarGen.cs


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