コード例 #1
0
        /// <summary>
        /// 添加玩家魂技
        /// </summary>
        /// <param name="abilityId"></param>
        /// <param name="userId"></param>
        public static void AddUserAbility(int abilityId, int userId, int generalID, int position)
        {
            var cacheSetAbility = new GameDataCacheSet <UserAbility>();
            var userAbility     = cacheSetAbility.FindKey(userId.ToString());
            var ability         = userAbility != null && userAbility.AbilityList != null
                              ? userAbility.AbilityList.Find(s => s.AbilityID == abilityId)
                              : null;

            var abilityLv     = new ConfigCacheSet <AbilityLvInfo>().FindKey(abilityId, 1);
            int experienceNum = abilityLv != null ? abilityLv.Experience : 0;

            if (userAbility == null)
            {
                userAbility            = new UserAbility(userId);
                ability                = new Ability();
                userAbility.CreateDate = DateTime.Now;
                ability.UserItemID     = Guid.NewGuid().ToString();
                ability.AbilityID      = abilityId;
                ability.AbilityLv      = 1;
                ability.GeneralID      = generalID;
                ability.ExperienceNum  = experienceNum;
                ability.Position       = position;
                userAbility.AbilityList.Add(ability);
                cacheSetAbility.Add(userAbility, GameEnvironment.CacheUserPeriod);
                // 添加到玩家集邮册
                UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.Ability, abilityId);
            }
            else
            {
                ability                = new Ability();
                ability.UserItemID     = Guid.NewGuid().ToString();
                userAbility.CreateDate = DateTime.Now;
                ability.AbilityID      = abilityId;
                ability.AbilityLv      = 1;
                ability.GeneralID      = generalID;
                ability.Position       = position;
                ability.ExperienceNum  = experienceNum;
                userAbility.AbilityList.Add(ability);
                // 添加到玩家集邮册
                UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.Ability, abilityId);
            }
        }
コード例 #2
0
        /// <summary>
        /// 添加玩家魂技
        /// </summary>
        /// <param name="abilityId"></param>
        /// <param name="userId"></param>
        public static void AddUserAbility(int abilityId, int userId, int generalID, int position)
        {
            var userAbility = _cacheSetAbility.FindKey(userId.ToString());
            var ability = userAbility != null && userAbility.AbilityList != null
                              ? userAbility.AbilityList.Find(s => s.AbilityID == abilityId)
                              : null;
            var abilityLv = new ShareCacheStruct<AbilityLvInfo>().FindKey(abilityId, 1);
            int experienceNum = abilityLv != null ? abilityLv.Experience : 0;
            if (userAbility == null)
            {
                userAbility = new UserAbility(userId);
                ability = new Ability();
                userAbility.CreateDate = DateTime.Now;
                ability.UserItemID = Guid.NewGuid().ToString();
                ability.AbilityID = abilityId;
                ability.AbilityLv = 1;
                ability.GeneralID = generalID;
                ability.ExperienceNum = experienceNum;
                ability.Position = position;
                userAbility.AbilityList.Add(ability);
                _cacheSetAbility.Add(userAbility);
                // 添加到玩家集邮册
                UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.Ability, abilityId);
            }
            else
            {
                ability = new Ability();
                ability.UserItemID = Guid.NewGuid().ToString();
                userAbility.CreateDate = DateTime.Now;
                ability.AbilityID = abilityId;
                ability.AbilityLv = 1;
                ability.GeneralID = generalID;
                ability.Position = position;
                ability.ExperienceNum = experienceNum;
                userAbility.AbilityList.Add(ability);
                // 添加到玩家集邮册
                UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.Ability, abilityId);
            }

            UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.General, generalID);
        }
コード例 #3
0
ファイル: AbilityCommand.cs プロジェクト: jinfei426/Scut
 /// <summary>
 /// 添加玩家魂技
 /// </summary>
 /// <param name="abilityId"></param>
 /// <param name="userId"></param>
 private void AddUserAbility(int abilityId, int userId, int generalID, int position)
 {
      GameDataCacheSet<UserAbility> _cacheSetAbility = new GameDataCacheSet<UserAbility>();
     var userAbility = _cacheSetAbility.FindKey(userId.ToString());
     var ability = userAbility != null && userAbility.AbilityList != null
                       ? userAbility.AbilityList.Find(s => s.AbilityID == abilityId)
                       : null;
     var abilityLv = new ConfigCacheSet<AbilityLvInfo>().FindKey(abilityId, 1);
     int experienceNum = abilityLv != null ? abilityLv.Experience : 0;
     if (userAbility == null)
     {
         userAbility = new UserAbility(userId);
         ability = new Ability();
         userAbility.CreateDate = DateTime.Now;
         ability.UserItemID = Guid.NewGuid().ToString();
         ability.AbilityID = abilityId;
         ability.AbilityLv = 1;
         ability.GeneralID = generalID;
         ability.ExperienceNum = experienceNum;
         ability.Position = position;
         userAbility.AbilityList.Add(ability);
         _cacheSetAbility.Add(userAbility);
     }
     else
     {
         ability = new Ability();
         ability.UserItemID = Guid.NewGuid().ToString();
         userAbility.CreateDate = DateTime.Now;
         ability.AbilityID = abilityId;
         ability.AbilityLv = 1;
         ability.GeneralID = generalID;
         ability.Position = position;
         ability.ExperienceNum = experienceNum;
         userAbility.AbilityList.Add(ability);
     }
 }