本文整理汇总了C#中Results.Total方法的典型用法代码示例。如果您正苦于以下问题:C# Results.Total方法的具体用法?C# Results.Total怎么用?C# Results.Total使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Results
的用法示例。
在下文中一共展示了Results.Total方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public Results Run()
{
decimal firstCnt = 0;
decimal secondCnt = 0;
decimal bothHit = 0;
for (int t = 0; t < NUMBER_TRIALS; t++)
{
// get roll results
int roll1 = Utility.Global.MyRandom.Next(1, DICE_SIZE + 1);
int roll2 = Utility.Global.MyRandom.Next(1, DICE_SIZE + 1);
int roll3 = Utility.Global.MyRandom.Next(1, DICE_SIZE + 1);
List<int> rolls = new List<int>();
rolls.Add(roll1);
rolls.Add(roll2);
rolls.Add(roll3);
rolls.Sort();
int highRoll = rolls[2];
int secondRoll = rolls[1];
// create first possible result
int highTotal = MyConfig.Strike1 + highRoll;
int lowTotal = MyConfig.Strike2 + secondRoll;
Results res1 = new Results();
if (highTotal >= MyConfig.Armor1)
res1.HitFirst++;
if (lowTotal >= MyConfig.Armor2)
res1.HitSecond++;
if (highTotal >= MyConfig.Armor1 && lowTotal >= MyConfig.Armor2)
res1.HitBoth++;
// create second possible result
highTotal = MyConfig.Strike1 + secondRoll;
lowTotal = MyConfig.Strike2 + highRoll;
Results res2 = new Results();
if (highTotal >= MyConfig.Armor1)
res2.HitFirst++;
if (lowTotal >= MyConfig.Armor2)
res2.HitSecond++;
if (highTotal >= MyConfig.Armor1 && lowTotal >= MyConfig.Armor2)
res2.HitBoth++;
// pick the best result
if (res1.Total() > res2.Total())
{
if (res1.HitFirst == 1)
firstCnt++;
if (res1.HitSecond == 1)
secondCnt++;
if (res1.HitBoth == 1)
bothHit++;
}
else
{
if (res2.HitFirst == 1)
firstCnt++;
if (res2.HitSecond == 1)
secondCnt++;
if (res2.HitBoth == 1)
bothHit++;
}
}
Results res = new Results();
res.HitFirst = Math.Round((decimal)firstCnt / NUMBER_TRIALS * 100, 2);
res.HitSecond = Math.Round((decimal)secondCnt / NUMBER_TRIALS * 100, 2);
res.HitBoth = Math.Round((decimal)bothHit / NUMBER_TRIALS * 100, 2);
return res;
}