本文整理汇总了C#中Dice.rng方法的典型用法代码示例。如果您正苦于以下问题:C# Dice.rng方法的具体用法?C# Dice.rng怎么用?C# Dice.rng使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dice
的用法示例。
在下文中一共展示了Dice.rng方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
{
//.........这里部分代码省略.........
示例2: getOrbitalRatio
/// <summary>
/// deteremine the orbital ratio between planets
/// </summary>
/// <param name="myDice">Dice object</param>
/// <returns>The orbital ratio between planets</returns>
public static double getOrbitalRatio(Dice myDice)
{
double ratio = 0;
int roll = myDice.gurpsRoll();
if (roll == 3 || roll == 4)
{
ratio = 1.4 + (myDice.rng(1, 5) * .01);
}
if (roll == 5 || roll == 6)
{
ratio = 1.5 + (myDice.rng(1, 10, -5) * .01);
}
if (roll == 7 || roll == 8)
{
ratio = 1.6 + (myDice.rng(1, 10, -5) * .01);
}
if (roll == 9 || roll == 10 || roll == 11 || roll == 12)
{
ratio = 1.7 + (myDice.rng(1, 10, -5) * .01);
}
if (roll == 13 || roll == 14)
{
ratio = 1.8 + (myDice.rng(1, 10, -5) * .01);
}
if (roll == 15 || roll == 16)
{
ratio = 1.9 + (myDice.rng(1, 10, -5) * .01);
}
if (roll == 17 || roll == 18)
{
ratio = 2.0 + (myDice.rng(1, 10, -5) * .01);
}
return ratio;
}
示例3: determineGeologicValues
/// <summary>
/// Determines RVM, and geologic values for a satelite
/// </summary>
/// <param name="s">The satelite</param>
/// <param name="ourBag">Dice object</param>
/// <param name="sysAge">System Age</param>
/// <param name="isGasGiantMoon">Is this a moon of a gas giant?</param>
public static void determineGeologicValues(Satellite s, Dice ourBag, double sysAge, bool isGasGiantMoon)
{
//volcanic set first.
double addVal = (s.gravity / sysAge) * 40;
if (s.majorMoons.Count == 1) addVal = addVal + 5;
if (s.majorMoons.Count == 2) addVal = addVal + 10;
if (s.SatelliteType == Satellite.SUBTYPE_SULFUR) addVal = addVal + 60;
if (isGasGiantMoon) addVal = addVal + 5;
int roll = ourBag.gurpsRoll();
addVal = addVal + roll;
if (addVal <= 16.5) s.volActivity = Satellite.GEOLOGIC_NONE;
if (addVal > 16.5 && addVal <= 20.5) s.volActivity = Satellite.GEOLOGIC_LIGHT;
if (addVal > 20.5 && addVal <= 26.5) s.volActivity = Satellite.GEOLOGIC_MODERATE;
if (addVal > 26.5 && addVal <= 70.5) s.volActivity = Satellite.GEOLOGIC_HEAVY;
if (addVal > 70.5) s.volActivity = Satellite.GEOLOGIC_EXTREME;
roll = ourBag.gurpsRoll();
if (s.volActivity == Satellite.GEOLOGIC_HEAVY && s.SatelliteType == Satellite.SUBTYPE_GARDEN && roll <= 8)
{
roll = ourBag.rng(6);
if (roll <= 3) s.addAtmCategory(Satellite.ATM_MARG_POLLUTANTS);
if (roll >= 4) s.addAtmCategory(Satellite.ATM_MARG_SULFUR);
}
roll = ourBag.gurpsRoll();
if (s.volActivity == Satellite.GEOLOGIC_EXTREME && s.SatelliteType == Satellite.SUBTYPE_GARDEN && roll <= 14)
{
roll = ourBag.rng(6);
if (roll <= 3) s.addAtmCategory(Satellite.ATM_MARG_POLLUTANTS);
if (roll >= 4) s.addAtmCategory(Satellite.ATM_MARG_SULFUR);
}
//tectonic next
roll = ourBag.gurpsRoll();
//negative mods
if (s.hydCoverage == 0) roll = roll - 4;
if (s.hydCoverage > 0 && s.hydCoverage < .5) roll = roll - 2;
if (s.volActivity == Satellite.GEOLOGIC_NONE) roll = roll - 8;
if (s.volActivity == Satellite.GEOLOGIC_LIGHT) roll = roll - 4;
//postive mods
if (s.volActivity == Satellite.GEOLOGIC_HEAVY) roll = roll + 4;
if (s.volActivity == Satellite.GEOLOGIC_EXTREME) roll = roll + 8;
if (s.majorMoons.Count == 1) roll = roll + 2;
if (s.majorMoons.Count > 1) roll = roll + 4;
//nullers.
if (s.SatelliteSize == Satellite.SIZE_TINY) roll = 0;
if (s.SatelliteSize == Satellite.SIZE_SMALL) roll = 0;
if (roll <= 6.5) s.tecActivity = Satellite.GEOLOGIC_NONE;
if (roll > 6.5 && roll <= 10.5) s.tecActivity = Satellite.GEOLOGIC_LIGHT;
if (roll > 10.5 && roll <= 14.5) s.tecActivity = Satellite.GEOLOGIC_MODERATE;
if (roll > 14.5 && roll <= 18.5) s.tecActivity = Satellite.GEOLOGIC_HEAVY;
if (roll > 18.5) s.tecActivity = Satellite.GEOLOGIC_EXTREME;
//update RVM
if (!OptionCont.highRVMVal) roll = ourBag.gurpsRoll();
if (OptionCont.highRVMVal) roll = ourBag.rng(1, 6, 10);
if (s.volActivity == Satellite.GEOLOGIC_NONE) roll = roll - 2;
if (s.volActivity == Satellite.GEOLOGIC_LIGHT) roll = roll - 1;
if (s.volActivity == Satellite.GEOLOGIC_HEAVY) roll = roll + 1;
if (s.volActivity == Satellite.GEOLOGIC_EXTREME) roll = roll + 2;
if (s.baseType == Satellite.BASETYPE_ASTEROIDBELT)
{
if (s.SatelliteSize == Satellite.SIZE_TINY) roll = roll - 1;
if (s.SatelliteSize == Satellite.SIZE_MEDIUM) roll = roll + 2;
if (s.SatelliteSize == Satellite.SIZE_LARGE) roll = roll + 4;
}
//set stable activity here:
if (OptionCont.stableActivity && s.SatelliteSize >= Satellite.SIZE_SMALL &&
(s.baseType == Satellite.BASETYPE_MOON || s.baseType == Satellite.BASETYPE_TERRESTIAL))
{
s.volActivity = Satellite.GEOLOGIC_MODERATE;
s.tecActivity = Satellite.GEOLOGIC_MODERATE;
}
s.populateRVM(roll);
}
示例4: genSystemAge
/// <summary>
/// This function generates a random age per GURPS Space 4e rules.
/// </summary>
/// <param name="ourDice">The dice this rolls</param>
/// <returns>The system age</returns>
public static double genSystemAge(Dice ourDice)
{
//get first roll
int roll;
roll = ourDice.gurpsRoll();
if (OptionCont.getSystemAge() != -1)
return OptionCont.getSystemAge();
if (roll == 3)
return 0.01;
if (roll >= 4 && roll <= 6)
return (.1 + (ourDice.rng(1, 6, -1) * .3) + (ourDice.rng(1, 6, -1) * .05));
if (roll >= 7 && roll <= 10)
return (2 + (ourDice.rng(1, 6, -1) * .6) + (ourDice.rng(1, 6, -1) * .1));
if (roll >= 11 && roll <= 14)
return (5.6 + (ourDice.rng(1, 6, -1) * .6) + (ourDice.rng(1, 6, -1) * .1));
if (roll >= 15 && roll <= 17)
return (8 + (ourDice.rng(1, 6, -1) * .6) + (ourDice.rng(1, 6, -1) * .1));
if (roll == 18)
return (10 + (ourDice.rng(1, 6, -1) * .6) + (ourDice.rng(1, 6, -1) * .1));
return 13.8;
}
示例5: rollStellarMass
/// <summary>
/// This function rolls for mass on a star.
/// </summary>
/// <param name="velvetBag">The dice object</param>
/// <param name="orderID">The order ID of the star</param>
/// <param name="maxMass">the maximum mass. Has a default value of 0.0, indicating no max mass (may be left out)</param>
/// <returns>The rolled mass of a star</returns>
public static double rollStellarMass(Dice velvetBag, int orderID, double maxMass = 0.0)
{
int rollA, rollB; //roll integers
double tmpRoll; //test value.
if (maxMass == 0.0)
{
if (!OptionCont.stellarMassRangeSet)
{
if (orderID == Star.IS_PRIMARY && OptionCont.forceGardenFavorable)
{
rollA = velvetBag.rng(6);
if (rollA == 1) rollA = 5;
if (rollA == 2) rollA = 6;
if (rollA == 3 || rollA == 4) rollA = 7;
if (rollA == 5 || rollA == 6) rollA = 8;
return Star.getMassByRoll(rollA, velvetBag.gurpsRoll());
}
else
{
return Star.getMassByRoll(velvetBag.gurpsRoll(), velvetBag.gurpsRoll());
}
}
else
{
return velvetBag.rollInRange(OptionCont.minStellarMass, OptionCont.maxStellarMass);
}
}
else
{
int currPos = Star.getStellarMassPos(maxMass);
//error bound checking. The entire program is kinda predicated aroudn the idea you won't have this happen.
//IF IT DOES, then do the simple method.
if (currPos == -1)
{
do
{
tmpRoll = Star.getMassByRoll(velvetBag.gurpsRoll(), velvetBag.gurpsRoll());
} while (tmpRoll > maxMass);
return tmpRoll;
}
//else, roll for the new index.
rollA = velvetBag.gurpsRoll();
rollB = velvetBag.rng(rollA, 6);
//get the new index
if (currPos - rollB <= 0) currPos = 0;
else currPos = currPos - rollB;
return Star.getMassByIndex(currPos);
}
}