本文整理汇总了C#中Dice.rollInRange方法的典型用法代码示例。如果您正苦于以下问题:C# Dice.rollInRange方法的具体用法?C# Dice.rollInRange怎么用?C# Dice.rollInRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dice
的用法示例。
在下文中一共展示了Dice.rollInRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generateAStar
/// <summary>
/// This function fills in the details of the star.
/// </summary>
/// <param name="s">The star to be filled in</param>
/// <param name="ourDice">The dice object used</param>
/// <param name="maxMass">Max mass of the system</param>
/// <param name="sysName">The name of the system</param>
public static void generateAStar(Star s, Dice ourDice, double maxMass, string sysName)
{
//check mass first - if unset, set it.
if (s.currMass == 0)
{
if (s.orderID == Star.IS_PRIMARY)
{
s.updateMass(libStarGen.rollStellarMass(ourDice, s.orderID));
maxMass = s.currMass;
}
else
s.updateMass(libStarGen.rollStellarMass(ourDice, s.orderID, maxMass));
}
//if we are in the white dwarf branch, reroll mass.
if (s.evoLine.findCurrentAgeGroup(s.starAge) == StarAgeLine.RET_COLLASPEDSTAR)
s.updateMass(ourDice.rollInRange(0.9, 1.4),true);
//set the generic name
s.name = Star.genGenericName(sysName, s.orderID);
//initalize the luminosity first, then update it given the current age, status and mass.
s.setLumin();
s.currLumin = Star.getCurrLumin(s.evoLine, s.starAge, s.currMass);
//determine the temperature
s.effTemp = Star.getInitTemp(s.currMass);
s.effTemp = Star.getCurrentTemp(s.evoLine, s.currLumin, s.starAge, s.currMass, ourDice);
//DERIVED STATS: RADIUS, Spectral Type
s.radius = Star.getRadius(s.currMass, s.effTemp, s.currLumin, s.evoLine.findCurrentAgeGroup(s.starAge));
s.setSpectralType();
s.starColor = Star.setColor(ourDice, s.effTemp);
//set flare status.
libStarGen.setFlareStatus(s, ourDice);
//end this here. We will hand orbital mechanics elsewhere.
}
示例2: 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);
}
}