本文整理汇总了C#中Animal.Increase方法的典型用法代码示例。如果您正苦于以下问题:C# Animal.Increase方法的具体用法?C# Animal.Increase怎么用?C# Animal.Increase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animal
的用法示例。
在下文中一共展示了Animal.Increase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RollOnChart
static void RollOnChart(Animal result, Chart chart, Dice dice, string dieCode = "D6")
{
var option = dice.ChooseByRoll(chart.Option, dieCode);
if (option.Attributes != null)
foreach (var att in option.Attributes)
result.Increase(att.Name, dice.D(att.Bonus));
if (option.Charts != null)
foreach (var subChart in option.Charts)
{
RollOnChart(result, subChart, dice, subChart.Roll);
}
if (option.Features != null)
foreach (var feature in option.Features)
result.Features.Add(feature.Text);
if (option.PostScripts != null)
foreach (var script in option.PostScripts)
result.PostScripts.Add(script.Text);
if (option.Skills != null)
foreach (var skill in option.Skills)
if (skill.ScoreSpecified)
result.Skills.Add(skill.Name, skill.Score);
else
result.Skills.Increase(skill.Name, skill.Bonus);
if (option.Behaviors != null)
foreach (var behaviorMeta in option.Behaviors)
{
var behavior = BehaviorList.SingleOrDefault(x => x.Name == behaviorMeta.Name);
if (behavior == null)
throw new BookException($"Chart {chart.Name} referes to unknown behavior named '{behaviorMeta.Name}'");
result.Behavior = result.Behavior + ", " + behavior.Name;
AddBehavior(result, behavior, dice);
}
}
示例2: BuildAnimal
public static Animal BuildAnimal(string terrainType, string animalClassName = null, int evolutionRolls = 0)
{
var dice = new Dice();
//Options
var selectedTerrainType = TerrainTypeList.Single(x => x.Name == terrainType);
var terrainPenalty = 0;
if (animalClassName == null)
{
var animalClassNotes = dice.ChooseWithOdds(selectedTerrainType.AnimalClasses);
animalClassName = animalClassNotes.AnimalClass;
terrainPenalty = animalClassNotes.Penalty;
}
else
{
var animalClassNotes = selectedTerrainType.AnimalClasses.SingleOrDefault(ac => ac.AnimalClass == animalClassName);
if (animalClassNotes == null)
terrainPenalty = -5; //What is it doing here?
else
terrainPenalty = animalClassNotes.Penalty;
}
var animalClass = AnimalClassList.Single(x => x.Name == animalClassName);
//Type
var result = new Animal() { TerrainType = selectedTerrainType.Name, AnimalClass = animalClassName, EvolutionRolls = evolutionRolls };
var movement = dice.ChooseByRoll(selectedTerrainType.MovementChart, "D6");
result.Movement = !string.IsNullOrWhiteSpace(animalClass.Movement) ? animalClass.Movement : movement.Movement;
result.InitiativeDM += animalClass.InitiativeDM;
//Starting Skills
foreach (var skill in animalClass.Skills)
if (skill.ScoreSpecified)
result.Skills.Add(skill.Name, skill.Score);
else
result.Skills.Increase(skill.Name, skill.Bonus);
//Class features
if (animalClass.Features != null)
foreach (var feature in animalClass.Features)
result.Features.Add(feature.Text);
//Diet
var diet = dice.ChooseWithOdds(animalClass.Diets);
result.Diet = diet.Diet;
if (diet.Skills != null)
foreach (var skill in diet.Skills)
if (skill.ScoreSpecified)
result.Skills.Add(skill.Name, skill.Score);
else
result.Skills.Increase(skill.Name, skill.Bonus);
foreach (var att in diet.Attribute)
result.Increase(att.Name, dice.D(att.Bonus));
var weaponDM = 0;
switch (result.Diet)
{
case "Carnivore":
result.InitiativeDM += 1;
weaponDM = 8;
break;
case "Omnivore":
weaponDM = 4;
break;
case "Herbivore":
result.InitiativeDM += -1;
weaponDM = -6;
break;
}
//Behavior
var behaviorMeta = dice.ChooseByRoll(diet.Behaviors, "1D");
var behavior = BehaviorList.Single(x => x.Name == behaviorMeta.Behavior);
result.Behavior = behaviorMeta.Behavior;
result.Attack = behavior.Attack.ToIntOrNull();
result.Flee = behavior.Flee.ToIntOrNull();
result.InitiativeDM += behavior.InitiativeDM;
//subtract the reaction to make it act like a DM
result.Attack -= behaviorMeta.Reaction;
result.Flee -= behaviorMeta.Reaction;
AddBehavior(result, behavior, dice);
result.QuirkRolls += dice.D("D6") == 6 ? 1 : 0;
//We do this in a loop because each chart can add rolls to other charts
while (result.QuirkRolls > 0 || result.EvolutionRolls > 0 || result.PhysicalSkills > 0 || result.SocialSkills > 0 || result.EvolutionSkills > 0)
{
//Evolution Rolls
while (result.EvolutionRolls > 0)
{
result.EvolutionRolls -= 1;
if (dice.D(2) == 0)
RollOnChart(result, animalClass.Chart.Single(x => x.Name == "AdditionalSkills"), dice, $"1D6+{result.EvolutionDM}");
else
RollOnChart(result, animalClass.Chart.Single(x => x.Name == "OtherBenefits"), dice, $"1D6+{result.EvolutionDM}");
//.........这里部分代码省略.........
示例3: AddBehavior
private static void AddBehavior(Animal result, Behavior behavior, Dice dice)
{
if (behavior.Attributes != null)
foreach (var att in behavior.Attributes)
result.Increase(att.Name, dice.D(att.Bonus));
if (behavior.Features != null)
foreach (var feature in behavior.Features)
result.Features.Add(feature.Text);
if (behavior.Charts != null)
foreach (var chart in behavior.Charts)
RollOnChart(result, chart, dice, chart.Roll);
}