예제 #1
0
        /// <summary>
        /// 初始化角色七维
        /// </summary>
        /// <returns></returns>
        public PlayerSpecial InitPlayerSpecial()
        {
            PlayerSpecial ps = new PlayerSpecial
            {
                Strength     = RandMethod.GetRandNumber(),
                Perception   = RandMethod.GetRandNumber(),
                Endurance    = RandMethod.GetRandNumber(),
                Charisma     = RandMethod.GetRandNumber(),
                Intelligence = RandMethod.GetRandNumber(),
                Agility      = RandMethod.GetRandNumber(),
                Luck         = RandMethod.GetRandNumber()
            };

            return(ps);
        }
        public string CreatedNewPlayer(PlayerInfoCreatedModel model)
        {
            //创建基本信息
            var vm = CreateVM <PlayerInfoApiVM>();

            vm.Entity = new PlayerInfo()
            {
                Name       = model.Name,
                NickName   = model.NickName,
                IsAlive    = true,
                BirthPlace = model.BirthPlace,
                ID         = Guid.NewGuid(),
                Sect       = 0,
                Sex        = model.Sex
            };
            string newplayerID = vm.Entity.ID.ToString();

            vm.DoAdd();

            //生成七维属性

            var ps = new PlayerInitialization().InitPlayerSpecial();

            ps.FK_PlayerGuId = newplayerID;
            DC.AddEntity(ps);

            //生成人物核心属性 PlayerAttribute

            //灵根
            DC.AddEntity(new PlayerAttribute()
            {
                AttributeType = (int)EnumAttrbuteType.Core,
                AttrName      = PlayerFields.BodySprit,
                AttrValue     = model.BodySprit,
                FK_PlayerGuid = newplayerID
            });
            //体魄
            DC.AddEntity(new PlayerAttribute()
            {
                AttributeType = (int)EnumAttrbuteType.Core,
                AttrName      = PlayerFields.Defense,
                AttrValue     = ps.Endurance * 49,
                FK_PlayerGuid = newplayerID
            });
            //血量
            DC.AddEntity(new PlayerAttribute()
            {
                AttributeType = (int)EnumAttrbuteType.Core,
                AttrName      = PlayerFields.Hp,
                AttrValue     = (ps.Endurance * 2 + ps.Strength * 3) * 9,
                FK_PlayerGuid = newplayerID
            });
            //神识
            DC.AddEntity(new PlayerAttribute()
            {
                AttributeType = (int)EnumAttrbuteType.Core,
                AttrName      = PlayerFields.Mind,
                AttrValue     = ps.Perception * 49,
                FK_PlayerGuid = newplayerID
            });
            //真元
            DC.AddEntity(new PlayerAttribute()
            {
                AttributeType = (int)EnumAttrbuteType.Core,
                AttrName      = PlayerFields.Mp,
                AttrValue     = (ps.Strength * 2 + ps.Perception * 3) * 9,
                FK_PlayerGuid = newplayerID
            });

            //初始化角色状态--境界、经验、寿元、精力、灵石仙玉
            var playerState = new PlayerState()
            {
                StateLevel  = SimpleState.Default.GetDescription() + SmallState.Inferior.GetDescription(),
                LevelExp    = 0,
                LifeRemark  = GlobalConsts.LifeDefaultRemark,
                CurrentLife = 15,
                MaxLifeTime = RandMethod.GetRandNumber(20, 80),
                Energy      = 100,
                Gold        = 0,
                Money       = 0,
            };

            playerState.FK_PlayerGuId = newplayerID;
            playerState.LifeRemark    = PlayerBaseLogic.PlayerLifeRemark(playerState.CurrentLife, playerState.MaxLifeTime);
            //重定义人物宗门、境界 ,可不从练气初期开局--TODO

            DC.AddEntity(playerState);

            //分配人物初始资产 PlayerProperty
            DC.AddEntity(new PlayerProperty()
            {
                FK_PlayerGuId = newplayerID,
                ItemName      = "道元真解",
                Level         = RandMethod.GetRandNumber(0, 50),
                Value         = RandMethod.GetRandNumber(0, 20000),
                TypeId        = 1
            });

            //添加新手礼包

            //生成随机词条 --TODO

            //生成特质 --TODO

            DC.SaveChanges();
            //返回角色ID
            return(newplayerID);
        }