Example #1
0
        public static short _currMaxLv = ObjectExtend.ToShort(ConfigEnvSet.GetInt("User.CurrMaxLv")); //玩家最大等级

        #endregion Fields

        #region Methods

        /// <summary>
        /// 增加灵件
        /// </summary>
        public static bool AddSparePart(GameUser user, UserSparePart sparePart)
        {
            int currNum = user.SparePartList.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count;
            if (currNum < user.UserExtend.SparePartGridNum)
            {
                user.AppendSparePart(sparePart);
                UserLogHelper.AppendSparePartLog(user.UserID, sparePart, 1);
                return true;
            }
            return false;
        }
Example #2
0
        private static UserSparePart BuildSparePart(int sparePartId)
        {
            var a         = new Array[3];
            var sparePart = new UserSparePart()
            {
                SparePartId     = sparePartId,
                UserSparepartID = Guid.NewGuid().ToString(),
                Position        = 0,
                UserItemID      = string.Empty
            };

            sparePart.SetPropertys();
            return(sparePart);
        }
Example #3
0
 public static void SetSparePartProperty(UserSparePart sparePart, SparePartProperty[] propertys)
 {
     for (int i = 0; i < sparePart.Propertys.Count; i++)
     {
         if (i < propertys.Length)
         {
             sparePart.Propertys[i] = propertys[i];
         }
         else
         {
             sparePart.Propertys[i] = new SparePartProperty()
             {
                 IsEnable = false
             };
         }
     }
 }
Example #4
0
 public void RemoveSparePart(UserSparePart sparePart)
 {
     var cacheSet = new GameDataCacheSet<UserSparePackage>();
     UserSparePackage package = cacheSet.FindKey(UserID);
     if (package == null)
     {
         return;
     }
     package.SparePackage.Remove(sparePart);
     //package.DelayChange();
 }
Example #5
0
        public bool EnableSpareProperty(string sparepartId, out UserSparePart sparePart)
        {
            sparePart = null;
            var cacheSet = new GameDataCacheSet<UserSparePackage>();
            UserSparePackage package = cacheSet.FindKey(UserID);
            if (package == null) return false;

            sparePart = package.SparePackage.Find(m => m.UserSparepartID.Equals(sparepartId));
            if (sparePart == null) return false;
            //[������]
            foreach (var property in sparePart.Propertys)
            {
                if (!property.IsEnable)
                {
                    var sparePartInfo = new ConfigCacheSet<SparePartInfo>().FindKey(sparePart.SparePartId) ?? new SparePartInfo();
                    var tempProperty = UserSparePart.RandomProperty(sparePartInfo, true, sparePart.Propertys);

                    property.UpdateNotify(obj =>
                    {
                        property.DefNum = tempProperty.DefNum;
                        property.NumRange = tempProperty.NumRange;
                        property.Rate = tempProperty.Rate;
                        property.ValueIndex = tempProperty.ValueIndex;
                        property.AbilityType = tempProperty.AbilityType;
                        property.Num = tempProperty.Num;
                        property.IsEnable = tempProperty.IsEnable;
                        //sparePart.OnChange();
                        return true;
                    });
                    break;
                }
            }

            return true;
        }
Example #6
0
        public void AppendSparePart(UserSparePart sparePart)
        {
            var cacheSet = new GameDataCacheSet<UserSparePackage>();
            UserSparePackage package = null;
            if (cacheSet.FindKey(UserID) == null)
            {
                package = new UserSparePackage() { UserID = UserID };
                cacheSet.Add(package, GameEnvironment.CacheUserPeriod);
            }
            package = cacheSet.FindKey(UserID);
            package.SparePackage.Add(sparePart);

            //package.Update();
        }
Example #7
0
 /// <summary>
 /// 灵件操作日志
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="sparePartID"></param>
 /// <param name="userSparepartID"></param>
 /// <param name="userItemID"></param>
 /// <param name="position"></param>
 /// <param name="partStatus"></param>
 public static void AppendSparePartLog(string userId, UserSparePart sparePart, short partStatus)
 {
     UserSparePartLog partLog = new UserSparePartLog()
                                   {
                                       UserID = userId,
                                       SparePartID = sparePart.SparePartId,
                                       SparePart = sparePart,
                                       PartStatus = partStatus,
                                       CreateDate = DateTime.Now
                                   };
     var sender = DataSyncManager.GetDataSender();
     sender.Send(partLog);
 }
Example #8
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "LogID": return LogID;
             case "UserID": return UserID;
             case "SparePartID": return SparePartID;
             case "SparePart": return SparePart;
             case "PartStatus": return PartStatus;
             case "CreateDate": return CreateDate;
             default: throw new ArgumentException(string.Format("UserSparePartLog index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "LogID":
                 _LogID = value.ToInt();
                 break;
             case "UserID":
                 _UserID = value.ToNotNullString();
                 break;
             case "SparePartID":
                 _SparePartID = value.ToInt();
                 break;
             case "SparePart":
                 _SparePart = ConvertCustomField<UserSparePart>(value, index);
                 break;
             case "PartStatus":
                 _PartStatus = value.ToShort();
                 break;
             case "CreateDate":
                 _CreateDate = value.ToDateTime();
                 break;
             default: throw new ArgumentException(string.Format("UserSparePartLog index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Example #9
0
        private void ResetProperty()
        {
            //洗涤属性
            var sparePart = ContextUser.SparePartList.Find(m => m.UserSparepartID.Equals(_sparepartID));
            if (sparePart != null)
            {
                var sparePartInfo = new ShareCacheStruct<SparePartInfo>().FindKey(sparePart.SparePartId) ?? new SparePartInfo();
                sparePart.UpdateNotify(obj =>
                {
                    for (int i = 0; i < sparePart.Propertys.Count; i++)
                    {
                        if (!sparePart.Propertys[i].IsEnable) continue;
                        if (_partPropertys.Length > 0 && Array.Exists(_partPropertys, m => m.ToInt() - 1 == i)) continue;

                        sparePart.Propertys[i] = UserSparePart.RandomProperty(sparePartInfo, false, sparePart.Propertys);
                        var package = UserItemPackage.Get(Uid);
                        UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(sparePart.UserItemID));
                        if (userItem != null && userItem.ItemStatus.Equals(ItemStatus.YongBing))
                        {
                            var userGeneral = new PersonalCacheStruct<UserGeneral>().FindKey(Uid, userItem.GeneralID);
                            if (userGeneral != null) userGeneral.RefreshMaxLife();
                        }
                    }
                    return true;
                });
                _sparePart = ContextUser.SparePartList.Find(m => m.UserSparepartID.Equals(_sparepartID));
                //ContextUser.UpdateSparePart();
            }
        }
Example #10
0
 private static UserSparePart BuildSparePart(int sparePartId)
 {
     var a = new Array[3];
     var sparePart = new UserSparePart()
     {
         SparePartId = sparePartId,
         UserSparepartID = Guid.NewGuid().ToString(),
         Position = 0,
         UserItemID = string.Empty
     };
     sparePart.SetPropertys();
     return sparePart;
 }
Example #11
0
 public static void SetSparePartProperty(UserSparePart sparePart, SparePartProperty[] propertys)
 {
     for (int i = 0; i < sparePart.Propertys.Count; i++)
     {
         if (i < propertys.Length)
         {
             sparePart.Propertys[i] = propertys[i];
         }
         else
         {
             sparePart.Propertys[i] = new SparePartProperty() { IsEnable = false };
         }
     }
 }
Example #12
0
        public void AppendSparePart(UserSparePart sparePart)
        {
            var cacheSet = new PersonalCacheStruct<UserSparePackage>();
            UserSparePackage package = null;
            if (cacheSet.FindKey(UserID) == null)
            {
                package = new UserSparePackage() { UserID = UserID };
                cacheSet.Add(package);
            }
            package = cacheSet.FindKey(UserID);
            package.SparePackage.Add(sparePart);

            //package.Update();
        }