Exemplo n.º 1
0
 public override bool TakeAction()
 {
     GameUser user = null;
     string puUserID = string.Empty;
     if (!string.IsNullOrEmpty(toUserID))
     {
         puUserID = toUserID;
         user = UserCacheGlobal.LoadOffline(toUserID);
     }
     else
     {
         puUserID = ContextUser.UserID;
         user = new GameDataCacheSet<GameUser>().FindKey(ContextUser.UserID);
         UserFunction userFunction = new GameDataCacheSet<UserFunction>().FindKey(ContextUser.UserID,
                                                                                  FunctionEnum.Enchant);
         if (userFunction != null)
         {
             EnchantHelper.EnchantFunctionOpen(ContextUser);
         }
         else
         {
             ErrorCode = LanguageManager.GetLang().ErrorCode;
             ErrorInfo = LanguageManager.GetLang().St_NoFun;
             return false;
         }
     }
     generalArray = new GameDataCacheSet<UserGeneral>().FindAll(puUserID, m => m.GeneralStatus == GeneralStatus.DuiWuZhong && m.GeneralType != GeneralType.Soul).ToArray();
     if (user != null)
     {
         goldNum = user.GoldNum;
         if (user.UserExtend != null)
         {
             enchantPackNum = user.UserExtend.EnchantGridNum;
             moShiNum = user.UserExtend.MoJingNum;
         }
     }
     package = UserEnchant.Get(puUserID);
     if (package != null && string.IsNullOrEmpty(toUserID))
     {
         var enchantsArray = package.EnchantPackage.FindAll(m => string.IsNullOrEmpty(m.UserItemID));
         enchantPackageArray = enchantsArray.GetPaging(pageIndex, pageSize, out pageCount).ToArray();
     }
     mosaicList = new ConfigCacheSet<MosaicInfo>().FindAll().ToArray();
     return true;
 }
Exemplo n.º 2
0
        private int GetMaxLife()
        {
            int      genLv     = 0;
            int      currMaxLv = 0;
            GameUser userinfo  = new GameDataCacheSet <GameUser>().FindKey(UserID);

            if (userinfo != null)
            {
                currMaxLv = userinfo.UserLv;
            }
            if (currMaxLv > 0 && GeneralLv > currMaxLv)
            {
                genLv = userinfo.UserLv;
            }
            else
            {
                genLv = GeneralLv;
            }
            //��ʼ����+(�ȼ�-1)*ְҵ�ӳ� + װ������+����ˮ������+ħ����������+������+��ħ����
            int        lifeNum    = 0;
            CareerInfo careerInfo = new ConfigCacheSet <CareerInfo>().FindKey(CareerID);

            if (careerInfo == null)
            {
                return(lifeNum);
            }
            var tempLv = MathUtils.Subtraction(genLv, 1, 0);

            if (IsUserGeneral)
            {
                lifeNum = MathUtils.Addition(careerInfo.LifeNum, careerInfo.LifeIncreaseNum * tempLv, int.MaxValue);
            }
            else
            {
                GeneralInfo generalInfo = new ConfigCacheSet <GeneralInfo>().FindKey(GeneralID);
                if (generalInfo != null)
                {
                    lifeNum = MathUtils.Addition(generalInfo.LifeNum, careerInfo.LifeIncreaseNum * tempLv, int.MaxValue);
                }
            }
            //����ˮ������
            var packageCrystal = UserCrystalPackage.Get(UserID);

            if (packageCrystal != null && packageCrystal.CrystalPackage != null)
            {
                UserCrystalInfo[] crystalList = packageCrystal.CrystalPackage.FindAll(m => m.GeneralID.Equals(GeneralID)).ToArray();
                foreach (UserCrystalInfo item in crystalList)
                {
                    short upLv = 0;
                    if (item.CrystalLv < 10)
                    {
                        upLv = item.CrystalLv; //item.CrystalLv.Addition(1, short.MaxValue);
                    }
                    else
                    {
                        upLv = 10;
                    }
                    //AbilityType abilityType = new ConfigCacheSet<CrystalInfo>().FindKey(item.CrystalID).AbilityID;
                    var           cacheSetCrystal = new ConfigCacheSet <CrystalInfo>();
                    var           crystalInfo     = cacheSetCrystal.FindKey(item.CrystalID);
                    AbilityType   abilityType     = crystalInfo != null ? crystalInfo.AbilityID : AbilityType.AttackLife;
                    decimal       effectNum       = 0;
                    CrystalLvInfo lvInfo          = new ConfigCacheSet <CrystalLvInfo>().FindKey(item.CrystalID, upLv);
                    if (lvInfo != null)
                    {
                        effectNum = lvInfo.AbilityNum;
                    }
                    if (abilityType == AbilityType.ShengMing)
                    {
                        lifeNum = MathUtils.Addition(lifeNum, effectNum.ToInt(), int.MaxValue);
                    }
                }
            }
            //װ������
            var package = UserItemPackage.Get(UserID);

            if (package != null && package.ItemPackage != null)
            {
                var equList = package.ItemPackage.FindAll(m => !m.IsRemove && m.GeneralID.Equals(GeneralID) && m.ItemStatus.Equals(ItemStatus.YongBing));
                foreach (var item in equList)
                {
                    ItemEquAttrInfo equAttr = new ConfigCacheSet <ItemEquAttrInfo>().FindKey(item.ItemID, AbilityType.ShengMing);
                    if (equAttr != null)
                    {
                        lifeNum = MathUtils.Addition(lifeNum, equAttr.GetEffectNum(item.ItemLv), int.MaxValue);
                    }
                    //���������
                    var user = new GameDataCacheSet <GameUser>().FindKey(UserID);
                    if (user != null && user.SparePartList != null && user.SparePartList.Count > 0)
                    {
                        var sparepartList = user.SparePartList.FindAll(m => string.Equals(m.UserItemID, item.UserItemID));
                        foreach (var sparepart in sparepartList)
                        {
                            foreach (var property in sparepart.Propertys)
                            {
                                if (property.AbilityType == AbilityType.ShengMing)
                                {
                                    lifeNum = MathUtils.Addition(lifeNum, property.Num.ToInt());
                                }
                            }
                        }
                    }
                }
            }
            //ħ������������������
            var userMagicList = new GameDataCacheSet <UserMagic>().FindAll(UserID, u => u.MagicID != 1);

            foreach (UserMagic item in userMagicList)
            {
                //�����󷨵ȼ�Ϊ10��
                int mlv = 0;
                if (item.MagicType == MagicType.MoFaZhen && item.MagicLv > 10)
                {
                    mlv = 10;
                }
                else if (item.MagicType == MagicType.JiNeng && item.MagicLv > currMaxLv)
                {
                    mlv = currMaxLv;
                }
                else
                {
                    mlv = item.MagicLv;
                }
                MagicLvInfo magicLvItem = new ConfigCacheSet <MagicLvInfo>().FindKey(item.MagicID, mlv);

                if (magicLvItem != null && magicLvItem.AbilityType == AbilityType.ShengMing)
                {
                    int errNum = magicLvItem.EffectNum.ToInt();
                    lifeNum = MathUtils.Addition(lifeNum, errNum, int.MaxValue);
                }
            }
            // Ӷ���øжȵȼ��ӳ�����
            FeelLvInfo fellLvInfo = new ConfigCacheSet <FeelLvInfo>().FindKey(FeelLv);

            if (fellLvInfo != null && fellLvInfo.Property != null)
            {
                GeneralProperty property = fellLvInfo.Property.Find(m => m.AbilityType.Equals(AbilityType.ShengMing));
                if (property != null)
                {
                    int effectNum = property.AbilityValue.ToInt();
                    lifeNum = MathUtils.Addition(lifeNum, effectNum, int.MaxValue);
                }
            }

            //���������ӳ�
            UserTrump userTrump = new GameDataCacheSet <UserTrump>().FindKey(UserID, TrumpInfo.CurrTrumpID);

            if (userTrump != null && userTrump.LiftNum > 0 && GeneralID == LanguageManager.GetLang().GameUserGeneralID)
            {
                TrumpInfo trumpInfo = new ConfigCacheSet <TrumpInfo>().FindKey(TrumpInfo.CurrTrumpID, userTrump.TrumpLv);
                if (trumpInfo != null && trumpInfo.Property != null && trumpInfo.Property.Count > 0)
                {
                    int             maxMatureNum = ConfigEnvSet.GetInt("Trump.MaxMatrueNum");
                    decimal         mature       = (decimal)userTrump.MatureNum / maxMatureNum;
                    GeneralProperty property     = trumpInfo.Property.Find(m => m.AbilityType == AbilityType.ShengMing);
                    if (property != null)
                    {
                        lifeNum = MathUtils.Addition(lifeNum, (int)Math.Floor(mature * property.AbilityValue));
                    }
                }

                if (userTrump.PropertyInfo.Count > 0)
                {
                    GeneralProperty property = userTrump.PropertyInfo.Find(m => m.AbilityType == AbilityType.ShengMing);
                    if (property != null)
                    {
                        lifeNum = MathUtils.Addition(lifeNum, (int)property.AbilityValue);
                    }
                }
            }

            //��ħ����
            var itempackage    = UserItemPackage.Get(UserID);
            var enchantPackage = UserEnchant.Get(UserID);

            if (itempackage != null && itempackage.ItemPackage != null && enchantPackage != null && enchantPackage.EnchantPackage != null)
            {
                var useritem = itempackage.ItemPackage.Find(m => !m.IsRemove && m.GeneralID == GeneralID && m.Equparts == EquParts.WuQi);
                if (useritem != null)
                {
                    var enchantList = enchantPackage.EnchantPackage.FindAll(m => m.UserItemID == useritem.UserItemID && m.AbilityType == AbilityType.ShengMing);
                    foreach (var info in enchantList)
                    {
                        EnchantLvInfo enchantLvInfo = new ConfigCacheSet <EnchantLvInfo>().FindKey(info.EnchantID, info.EnchantLv);
                        if (enchantLvInfo != null)
                        {
                            int     maxEnchantMature = ConfigEnvSet.GetInt("Enchant.MaxEnchantMature");
                            decimal growthrate       = enchantLvInfo.Num * info.MaxMature / maxEnchantMature * info.EnchantLv;
                            lifeNum = MathUtils.Addition(lifeNum, (int)growthrate);
                        }
                    }
                }
            }
            //Ӷ����������
            if (Attribute.Count > 0)
            {
                var generalPro = Attribute.Find(s => s.AbilityType == AbilityType.ShengMing);
                if (generalPro != null)
                {
                    lifeNum = MathUtils.Addition(lifeNum, generalPro.AbilityValue.ToInt());
                }
            }

            return(lifeNum);
        }