Exemplo n.º 1
0
 /// <summary>
 /// 获取附魔符
 /// </summary>
 /// <param name="enchantID"></param>
 /// <returns></returns>
 public static UserEnchantInfo GetUserEnchantInfo(int enchantID)
 {
     UserEnchantInfo enchant = new UserEnchantInfo();
     EnchantInfo enchantInfo = new ShareCacheStruct<EnchantInfo>().FindKey(enchantID);
     if (enchantInfo != null)
     {
         enchant.UserEnchantID = Guid.NewGuid().ToString();
         enchant.EnchantID = enchantID;
         enchant.EnchantLv = 1;
         enchant.CurrExprience = 0;
         enchant.Position = 0;
         enchant.UserItemID = string.Empty;
         enchant.MaxMature = (short)RandomUtils.GetRandom(enchantInfo.BeseNum, enchantInfo.MaxNum);
     }
     return enchant;
 }
Exemplo n.º 2
0
 public override bool TakeAction()
 {
     string puUserID;
     if (string.IsNullOrEmpty(toUserID))
     {
         puUserID = ContextUser.UserID;
     }
     else
     {
         puUserID = toUserID;
         UserCacheGlobal.LoadOffline(puUserID);
     }
     var package = UserEnchant.Get(puUserID);
     if (package != null)
     {
         userEnchantInfo = package.EnchantPackage.Find(m => m.UserEnchantID == userEnchantID);
         if (userEnchantInfo != null)
         {
             finalMature = CombatHelper.EnchantFinalNum(userEnchantInfo);
             currExp = userEnchantInfo.CurrExprience;
             enchant = new ConfigCacheSet<EnchantInfo>().FindKey(userEnchantInfo.EnchantID);
             if (enchant != null)
             {
                 enchantLvInfo = new ConfigCacheSet<EnchantLvInfo>().FindKey(enchant.EnchantID, userEnchantInfo.EnchantLv);
                 short uplv = MathUtils.Addition(userEnchantInfo.EnchantLv, (short)1, (short)GameConfigSet.MaxEnchantLv);
                 EnchantLvInfo enchantLv = new ConfigCacheSet<EnchantLvInfo>().FindKey(userEnchantInfo.EnchantID, uplv);
                 upExp = enchantLv == null ? 0 : enchantLv.Experience;
             }
         }
     }
     return true;
 }
Exemplo n.º 3
0
        public int CompareTo(UserEnchantInfo item)
        {
            int result = 0;
            if (this == null && item == null) return 0;
            if (this != null && item == null) return 1;
            if (this == null && item != null) return -1;

            result = ((int)item.EnchantLv).CompareTo((int)EnchantLv);
            if (result == 0)
            {
                result = item.CurrExprience.CompareTo(item.CurrExprience);
            }

            return result;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 玩家附魔符log
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="opType"></param>
        /// <param name="enchantID"></param>
        /// <param name="synthesisInfo"></param>
        /// <param name="enchantLv"></param>
        /// <param name="mature"></param>
        /// <param name="exp"></param>
        /// <param name="userEnchantID"></param>
        public static void AppenEnchantLog(string userID, short opType, UserEnchantInfo enchantInfo, CacheList<SynthesisInfo> synthesisInfo)
        {
            UserEnchantLog log = new UserEnchantLog();
            log.ID = Guid.NewGuid().ToString();
            log.UserID = userID;
            log.OpType = opType;
            log.UserEnchantID = enchantInfo.UserEnchantID;
            log.EnchantID = enchantInfo.EnchantID;
            log.EnchantLv = enchantInfo.EnchantLv;
            log.MaxMature = enchantInfo.MaxMature;
            log.Experience = enchantInfo.CurrExprience;
            log.SynthesisEnchant = synthesisInfo;
            log.CreateDate = DateTime.Now;

            var sender = DataSyncManager.GetDataSender();
            sender.Send(log);
        }
Exemplo n.º 5
0
 public override bool TakeAction()
 {
     var package = UserEnchant.Get(ContextUser.UserID);
     if (package != null)
     {
         userEnchant = package.EnchantPackage.Find(m => m.UserEnchantID == userEnchantID);
         if (userEnchant != null)
         {
             matureNum = (decimal)userEnchant.MaxMature / GameConfigSet.MaxEnchantMature;
             maxMature = CombatHelper.EnchantFinalNum(userEnchant);
             enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(userEnchant.EnchantID);
             EnchantLvInfo enchantLvInfo = new ConfigCacheSet<EnchantLvInfo>().FindKey(userEnchant.EnchantID,
                                                                                       userEnchant.EnchantLv);
             if (enchantLvInfo != null)
             {
                 abilityNum = TrumpHelper.GetTransformData(enchantLvInfo.Num);
             }
         }
     }
     enchantList = EnchantHelper.EnchantCultureList();
     return true;
 }
Exemplo n.º 6
0
        public override void BuildPacket()
        {
            PushIntoStack(enchantPackNum);
            PushIntoStack(moShiNum);
            PushIntoStack(goldNum);
            PushIntoStack(generalArray.Length);
            foreach (var general in generalArray)
            {
                UserEnchantInfo[] enchantGeneralArray = new UserEnchantInfo[0];
                UserItemInfo useritem = EnchantHelper.GetGeneralWeapon(general.UserID, general.GeneralID);
                ItemBaseInfo itemInfo = null;
                if (useritem != null)
                {
                    itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(useritem.ItemID);
                    openNum = EnchantHelper.EnchantOpenGridNum(useritem.ItemLv);
                    if (package != null)
                    {
                        enchantGeneralArray = package.EnchantPackage.FindAll(m => m.UserItemID == useritem.UserItemID).ToArray();
                    }
                }
                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(general.GeneralID);
                dsItem.PushIntoStack(general.GeneralName.ToNotNullString());
                dsItem.PushIntoStack((short)general.CareerID);
                dsItem.PushIntoStack(useritem == null ? string.Empty : useritem.UserItemID.ToNotNullString());
                dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemName.ToNotNullString());
                dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.HeadID.ToNotNullString());
                dsItem.PushIntoStack((short)openNum);
                dsItem.PushIntoStack(enchantGeneralArray.Length);
                foreach (var enchant in enchantGeneralArray)
                {
                    EnchantInfo enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(enchant.EnchantID);
                    DataStruct dsItem1 = new DataStruct();
                    dsItem1.PushIntoStack((short)enchant.Position);
                    dsItem1.PushIntoStack(enchant.UserEnchantID.ToNotNullString());
                    dsItem1.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.EnchantName.ToNotNullString());
                    dsItem1.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.HeadID.ToNotNullString());
                    dsItem1.PushIntoStack((short)enchant.EnchantLv);
                    dsItem1.PushIntoStack(enchantInfo == null ? (short)0 : (short)enchantInfo.ColorType);
                    dsItem.PushIntoStack(dsItem1);
                }

                PushIntoStack(dsItem);
            }
            this.PushIntoStack(pageCount);
            this.PushIntoStack(enchantPackageArray.Length);
            foreach (var enchant in enchantPackageArray)
            {
                EnchantInfo enchantInfo = new ConfigCacheSet<EnchantInfo>().FindKey(enchant.EnchantID);
                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(enchant.UserEnchantID.ToNotNullString());
                dsItem.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.EnchantName.ToNotNullString());
                dsItem.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.HeadID.ToNotNullString());
                dsItem.PushIntoStack((short)enchant.EnchantLv);
                dsItem.PushIntoStack(enchantInfo == null ? (short)0 : (short)enchantInfo.ColorType);
                PushIntoStack(dsItem);
            }
            this.PushIntoStack(mosaicList.Length);
            foreach (var mosaic in mosaicList)
            {
                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack((short)mosaic.Position);
                dsItem.PushIntoStack(mosaic.MosaicColor.ToNotNullString());
                dsItem.PushIntoStack((short)mosaic.DemandLv);

                this.PushIntoStack(dsItem);
            }
        }
Exemplo n.º 7
0
 public void SaveEnchant(UserEnchantInfo enchant)
 {
     if (enchant == null || string.IsNullOrEmpty(enchant.UserEnchantID)) return;
     var tempEnchant = EnchantPackage.Find(m => !string.IsNullOrEmpty(enchant.UserEnchantID) && string.Equals(m.UserEnchantID, enchant.UserEnchantID));
     if (tempEnchant == null)
     {
         EnchantPackage.Add(enchant);
     }
     else
     {
         tempEnchant.UpdateNotify(obj =>
         {
             tempEnchant.UserEnchantID = enchant.UserEnchantID;
             tempEnchant.EnchantID = enchant.EnchantID;
             tempEnchant.EnchantLv = enchant.EnchantLv;
             tempEnchant.CurrExprience = enchant.CurrExprience;
             tempEnchant.MaxMature = enchant.MaxMature;
             tempEnchant.Position = enchant.Position;
             tempEnchant.UserItemID = enchant.UserItemID;
             return true;
         });
     }
 }
Exemplo n.º 8
0
        public void RemoveEnchant(UserEnchantInfo userEnchantInfo)
        {
            if (userEnchantInfo != null)
            {
                EnchantPackage.Remove(userEnchantInfo);

                TraceLog.Write(string.Format("UserId:{0} remove enchant:'{1}' {2},lv:{3}",
                    UserID,
                    userEnchantInfo.UserItemID,
                    userEnchantInfo.EnchantID,
                    userEnchantInfo.EnchantLv));
            }
        }
Exemplo n.º 9
0
 public static decimal EnchantFinalNum(UserEnchantInfo userEnchant)
 {
     //最终属性=基础属性*成长率*附魔符等级
     decimal growthRate = EnchantAbilityNum(userEnchant.EnchantID, userEnchant.EnchantLv) * userEnchant.MaxMature / GameConfigSet.MaxEnchantMature * userEnchant.EnchantLv;
     if (growthRate >= 1)
     {
         growthRate = MathUtils.RoundCustom(growthRate, 0);
     }
     if (growthRate > 0 && growthRate < 1)
     {
         growthRate = MathUtils.RoundCustom(growthRate, 3);
     }
     return growthRate;
 }