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


C# Dice.Next方法代码示例

本文整理汇总了C#中Dice.Next方法的典型用法代码示例。如果您正苦于以下问题:C# Dice.Next方法的具体用法?C# Dice.Next怎么用?C# Dice.Next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dice的用法示例。


在下文中一共展示了Dice.Next方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PassengerDetailAsync

        protected async Task<Passenger> PassengerDetailAsync(Dice random, string travelType, bool advancedCharacters)
        {
            var user = await NameService.CreateRandomPersonAsync().ConfigureAwait(false);

            bool isPatron = false;

            var result = new Passenger()
            {
                TravelType = travelType,
                Name = $"{user.FirstName} {user.LastName}",
                Gender = user.Gender,
                ApparentAge = 12 + random.D(1, 60),
            };
            Passenger.AddPassengerType(result, random);

            SimpleCharacterEngine.AddTrait(result, random);

            if (!advancedCharacters)
            {
                SimpleCharacterEngine.AddCharacteristics(result, random);
            }
            else
            {
                result.Seed = random.Next();
                var options = new CharacterBuilderOptions() { MaxAge = result.ApparentAge, Name = result.Name, Seed = result.Seed };
                var character = m_CharacterBuilder.Build(options);

                result.Strength += character.Strength;
                result.Dexterity += character.Dexterity;
                result.Endurance += character.Endurance;
                result.Intellect += character.Intellect;
                result.Education += character.Education;
                result.Social += character.SocialStanding;

                result.Skills = string.Join(", ", character.Skills.Where(s => s.Level > 0).Select(s => s.ToString()).OrderBy(s => s));

                result.Title = character.Title;
            }


            if (isPatron)
            {
                //TODO: add support for patron features
            }

            return result;
        }
开发者ID:Grauenwolf,项目名称:TravellerTools,代码行数:47,代码来源:TradeEngine.cs

示例2: PickAdvancement

        static void PickAdvancement(Character result, Dice dice)
        {
            result.UnusedAdvances -= 1;

            if (result.UnusedEdges < 0)
                result.UnusedEdges += 1;
            else if (result.UnusedSkills < 0)
                result.UnusedSkills += 2; //pay back the skill point loan
            else if (result.UnusedSmartSkills < 0)
                result.UnusedSmartSkills += 2; //pay back the skill point loan
            else

            {
                switch (dice.Next(5))
                {
                    case 0:
                        result.UnusedEdges += 1;
                        break;
                    case 1: //increase a high skill

                        {
                            var table = new Table<Skill>();
                            foreach (var skill in result.Skills)
                            {
                                if (skill.Trait >= result.GetAttribute(skill.Attribute) && skill.Trait < 12)
                                    table.Add(skill, skill.Trait.Score);
                            }
                            if (table.Count == 0)
                                goto case 2;
                            table.RandomChoose(dice).Trait += 1;
                            break;
                        }
                    case 2: //increase a low skill

                        {
                            var table = new Table<Skill>();
                            foreach (var skill in result.Skills)
                            {
                                if (skill.Trait < result.GetAttribute(skill.Attribute) && skill.Trait < 12)
                                    table.Add(skill, skill.Trait.Score);
                            }
                            if (table.Count >= 2)
                                goto case 3;
                            table.RandomPick(dice).Trait += 1;
                            table.RandomPick(dice).Trait += 1; //use Pick so we get 2 different skills
                            break;
                        }
                    case 3: //add a new skill

                        {
                            var table = new Table<Skill>();
                            foreach (var skill in result.Skills)
                            {
                                if (skill.Trait == 0)
                                    table.Add(skill, result.GetAttribute(skill.Attribute).Score);
                            }
                            if (table.Count == 0)
                                break; //really?
                            table.RandomChoose(dice).Trait = 4;
                            break;
                        }
                    case 4:
                        result.UnusedAttributes += 1;
                        break;
                }
            }
        }
开发者ID:Grauenwolf,项目名称:SavageTools,代码行数:67,代码来源:CharacterGenerator.cs


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