Esempio n. 1
0
        /// 获得灵魂
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="itemId"></param>
        /// <param name="num"></param>
        public static void AddGeneralSoul(string userId, int itemId, int num)
        {
            var cacheSetGeneral     = new GameDataCacheSet <UserGeneral>();
            var cacheSetGeneralInfo = new ConfigCacheSet <GeneralInfo>();
            var generalInfo         = cacheSetGeneralInfo.Find(s => s.SoulID == itemId);
            var userGeneral         = cacheSetGeneral.FindKey(userId, itemId);

            if (userGeneral != null && generalInfo != null)
            {
                userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, num).ToShort();
            }
            else
            {
                if (generalInfo != null)
                {
                    userGeneral                   = new UserGeneral();
                    userGeneral.UserID            = userId;
                    userGeneral.GeneralID         = itemId;
                    userGeneral.AtmanNum          = num;
                    userGeneral.GeneralName       = generalInfo.GeneralName;
                    userGeneral.HeadID            = generalInfo.HeadID;
                    userGeneral.PicturesID        = generalInfo.PicturesID;
                    userGeneral.GeneralLv         = generalInfo.GeneralLv;
                    userGeneral.LifeNum           = generalInfo.LifeNum;
                    userGeneral.GeneralType       = generalInfo.GeneralType;
                    userGeneral.CareerID          = generalInfo.CareerID;
                    userGeneral.PowerNum          = generalInfo.PowerNum;
                    userGeneral.SoulNum           = generalInfo.SoulNum;
                    userGeneral.IntellectNum      = generalInfo.IntellectNum;
                    userGeneral.TrainingPower     = 0;
                    userGeneral.TrainingSoul      = 0;
                    userGeneral.TrainingIntellect = 0;
                    userGeneral.HitProbability    = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                    userGeneral.AbilityID         = generalInfo.AbilityID;
                    userGeneral.Momentum          = 0;
                    userGeneral.Description       = generalInfo.Description;
                    userGeneral.AddGeneralStatus(2);
                    userGeneral.CurrExperience = 0;
                    userGeneral.Experience1    = 0;
                    userGeneral.Experience2    = 0;
                    userGeneral.AbilityNum     = 3;
                    cacheSetGeneral.Add(userGeneral, GameEnvironment.CacheUserPeriod);
                }
            }
        }
Esempio 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);
        }