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


C# Race.Create方法代码示例

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


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

示例1: CreateRace

 public ActionResult CreateRace(int id, Race race)
 {
     ViewData["tournamentID"] = id;
     ViewData["tourneyname"] = Tournament.Detail(id).Tournament.TournamentName;
     race.EventID = id;
     race.Create();
     Heat.CreateHeatsForRace(race);
     return RedirectToAction("Index", new { id = id });
 }
开发者ID:two4suited,项目名称:FlyballStats,代码行数:9,代码来源:TournamentRaceController.cs

示例2: AddRaceData

        public ActionResult AddRaceData(AddEditRaceViewModel vModel)
        {
            string message = string.Empty;
            var authedUser = UserManager.FindById(User.Identity.GetUserId());

            var newObj = new Race();
            newObj.Name = vModel.NewName;

            if (vModel.NewArmsID > 0 && vModel.NewArmsAmount > 0)
            {
                var arm = DataWrapper.GetOne<InanimateData>(vModel.NewArmsID);

                if (arm != null)
                    newObj.Arms = new Tuple<IInanimateData, short>(arm, vModel.NewArmsAmount);
            }

            if (vModel.NewLegsID > 0 && vModel.NewLegsAmount > 0)
            {
                var leg = DataWrapper.GetOne<InanimateData>(vModel.NewLegsID);

                if (leg != null)
                    newObj.Legs = new Tuple<IInanimateData, short>(leg, vModel.NewLegsAmount);
            }

            if (vModel.NewTorsoId > 0)
            {
                var torso = DataWrapper.GetOne<InanimateData>(vModel.NewTorsoId);

                if (torso != null)
                    newObj.Torso = torso;
            }

            if (vModel.NewHeadId > 0)
            {
                var head = DataWrapper.GetOne<InanimateData>(vModel.NewHeadId);

                if (head != null)
                    newObj.Head = head;
            }

            if (vModel.NewStartingLocationId > 0)
            {
                var room = DataWrapper.GetOne<RoomData>(vModel.NewStartingLocationId);

                if (room != null)
                    newObj.StartingLocation = room;
            }

            if (vModel.NewRecallLocationId > 0)
            {
                var room = DataWrapper.GetOne<RoomData>(vModel.NewRecallLocationId);

                if (room != null)
                    newObj.EmergencyLocation = room;
            }

            if (vModel.NewBloodId > 0)
            {
                var blood = ReferenceWrapper.GetOne<Material>(vModel.NewBloodId);

                if (blood != null)
                    newObj.SanguinaryMaterial = blood;
            }

            newObj.VisionRange = new Tuple<short, short>(vModel.NewVisionRangeLow, vModel.NewVisionRangeHigh);
            newObj.TemperatureTolerance = new Tuple<short, short>(vModel.NewTemperatureToleranceLow, vModel.NewTemperatureToleranceHigh);

            newObj.Breathes = (RespiratoryType)vModel.NewBreathes;
            newObj.DietaryNeeds = (DietType)vModel.NewDietaryNeeds;
            newObj.TeethType = (DamageType)vModel.NewTeethType;

            if (vModel.NewExtraPartsId != null)
            {
                int partIndex = 0;
                var bodyBits = new List<Tuple<IInanimateData, short, string>>();
                foreach (var id in vModel.NewExtraPartsId)
                {
                    if (id > 0)
                    {
                        if (vModel.NewExtraPartsAmount.Count() <= partIndex || vModel.NewExtraPartsName.Count() <= partIndex)
                            break;

                        var currentName = vModel.NewExtraPartsName[partIndex];
                        var currentAmount = vModel.NewExtraPartsAmount[partIndex];
                        var partObject = DataWrapper.GetOne<InanimateData>(id);

                        if (partObject != null && currentAmount > 0 && !string.IsNullOrWhiteSpace(currentName))
                            bodyBits.Add(new Tuple<IInanimateData, short, string>(partObject, currentAmount, currentName));
                    }

                    partIndex++;
                }

                newObj.BodyParts = bodyBits;
            }

            if (newObj.Create() == null)
                message = "Error; Creation failed.";
            else
            {
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:NetMud,代码行数:101,代码来源:GameAdminController.cs


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