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


C# Animal.Increase方法代码示例

本文整理汇总了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);
                }
        }
开发者ID:Grauenwolf,项目名称:TravellerTools,代码行数:39,代码来源:AnimalBuilderAE.cs

示例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}");
//.........这里部分代码省略.........
开发者ID:Grauenwolf,项目名称:TravellerTools,代码行数:101,代码来源:AnimalBuilderAE.cs

示例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);
        }
开发者ID:Grauenwolf,项目名称:TravellerTools,代码行数:14,代码来源:AnimalBuilderAE.cs


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