Example #1
0
        /// <summary>
        /// 添加装备到玩家集邮表
        /// </summary>
        /// <param name="userID">玩家ID</param>
        /// <param name="itemID">物品ID</param>
        private static void AddUserAlbum(string userID, int itemID)
        {
            // 判断物品时否是装备
            var itemBaseinfo = new ShareCacheStruct <ItemBaseInfo>().Find(s => s.ItemID == itemID && s.ItemType == ItemType.ZhuangBei);

            if (itemBaseinfo != null)
            {
                UserAlbumHelper.AddUserAlbum(userID, AlbumType.Item, itemID);
            }
        }
        /// <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);
        }