protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "GeneralID": return GeneralID;
             case "HeadID": return HeadID;
             case "PicturesID": return PicturesID;
             case "GeneralName": return GeneralName;
             case "GeneralLv": return GeneralLv;
             case "LifeNum": return LifeNum;
             case "CareerID": return CareerID;
             case "PowerNum": return PowerNum;
             case "SoulNum": return SoulNum;
             case "IntellectNum": return IntellectNum;
             case "HitProbability": return HitProbability;
             case "AbilityID": return AbilityID;
             case "IsRecruit": return IsRecruit;
             case "ShowFilter": return ShowFilter;
             case "RecruitFilter": return RecruitFilter;
             case "GiftType": return GiftType;
             case "Description": return Description;
             case "ReplaceSkills": return ReplaceSkills;
             case "GeneralType": return GeneralType;
             case "SoulID": return SoulID;
             case "DemandNum": return DemandNum;
             case "Mature": return Mature;
             case "GeneralQuality": return GeneralQuality;
             case "ItemID": return ItemID;
             case "BattleHeadID": return BattleHeadID;
             case "IsConscribe": return IsConscribe;
             default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "GeneralID":
                 _GeneralID = value.ToInt();
                 break;
             case "HeadID":
                 _HeadID = value.ToNotNullString();
                 break;
             case "PicturesID":
                 _PicturesID = value.ToNotNullString();
                 break;
             case "GeneralName":
                 _GeneralName = value.ToNotNullString();
                 break;
             case "GeneralLv":
                 _GeneralLv = value.ToShort();
                 break;
             case "LifeNum":
                 _LifeNum = value.ToInt();
                 break;
             case "CareerID":
                 _CareerID = value.ToShort();
                 break;
             case "PowerNum":
                 _PowerNum = value.ToShort();
                 break;
             case "SoulNum":
                 _SoulNum = value.ToShort();
                 break;
             case "IntellectNum":
                 _IntellectNum = value.ToShort();
                 break;
             case "HitProbability":
                 _HitProbability = value.ToDecimal();
                 break;
             case "AbilityID":
                 _AbilityID = value.ToInt();
                 break;
             case "IsRecruit":
                 _IsRecruit = value.ToBool();
                 break;
             case "ShowFilter":
                 _ShowFilter = ConvertCustomField<CacheList<ShowFilterInfo>>(value, index);
                 break;
             case "RecruitFilter":
                 _RecruitFilter = ConvertCustomField<CacheList<RecruitFilter>>(value, index);
                 break;
             case "Description":
                 _Description = value.ToNotNullString();
                 break;
             case "GiftType":
                 _GiftType = value.ToEnum<GiftType>();
                 break;
             case "ReplaceSkills":
                 _ReplaceSkills = ConvertCustomField<SkillInfo>(value, index);
                 break;
             case "GeneralType":
                 _GeneralType = value.ToEnum<GeneralType>();
                 break;
             case "SoulID":
                 _SoulID = value.ToInt();
                 break;
             case "DemandNum":
                 _DemandNum = value.ToInt();
                 break;
             case "Mature":
                 _Mature = ConvertCustomField<CacheList<GeneralProperty>>(value, index);
                 break;
             case "GeneralQuality":
                 _GeneralQuality = value.ToEnum<GeneralQuality>();
                 break;
             case "ItemID":
                 _ItemID = value.ToInt();
                 break;
             case "BattleHeadID":
                 _BattleHeadID = value.ToNotNullString();
                 break;
             case "IsConscribe":
                 _IsConscribe = value.ToBool();
                 break;
             default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Beispiel #2
0
        public override bool TakeAction()
        {
            int    currMaxLv  = GameConfigSet.CurrMaxLv;
            string lifeUserID = string.Empty;

            UserCrystalInfo[] userCrystalsArrray = new UserCrystalInfo[0];
            if (!string.IsNullOrEmpty(toUserID))
            {
                var packageCrystal = UserCrystalPackage.Get(toUserID);
                userGeneral        = new PersonalCacheStruct <UserGeneral>().FindKey(toUserID, generalID);
                userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray();
                var package = UserItemPackage.Get(toUserID);
                userItemArray = package.ItemPackage.FindAll(
                    u => !u.IsRemove && u.GeneralID.Equals(generalID) &&
                    u.ItemStatus == ItemStatus.YongBing);
                lifeUserID = toUserID;
            }
            else
            {
                var packageCrystal = UserCrystalPackage.Get(ContextUser.UserID);
                userGeneral        = new PersonalCacheStruct <UserGeneral>().FindKey(ContextUser.UserID, generalID);
                userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray();

                var package = UserItemPackage.Get(ContextUser.UserID);
                userItemArray = package.ItemPackage.FindAll(u => !u.IsRemove && u.GeneralID.Equals(generalID) && u.ItemStatus == ItemStatus.YongBing);
                lifeUserID    = ContextUser.UserID;
            }
            UserCacheGlobal.LoadOffline(lifeUserID);
            GeneralInfo generalInfo = new ShareCacheStruct <GeneralInfo>().FindKey(generalID);

            generalQuality = generalInfo == null ? (short)0 : generalInfo.GeneralQuality;
            if (generalInfo != null && userGeneral != null)
            {
                description = generalInfo.Description;
                if (userGeneral.GeneralLv >= currMaxLv)
                {
                    genLv = (short)currMaxLv;
                    userGeneral.CurrExperience = 0;
                }
                else
                {
                    genLv = userGeneral.GeneralLv;
                }
                generalName     = userGeneral.GeneralName;
                headID          = userGeneral.HeadID;
                picturesID      = userGeneral.PicturesID;
                _battleHeadId   = generalInfo.BattleHeadID;
                _hitProbability = generalInfo.HitProbability;
                careerInfo      = new ShareCacheStruct <CareerInfo>().FindKey(userGeneral.CareerID);
                GeneralEscalateInfo generalEscalate = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(genLv);
                if (generalEscalate != null)
                {
                    currExperience = userGeneral.CurrExperience;
                    maxExperience  = generalEscalate.UpExperience;
                }
                powerNum     = MathUtils.Addition(userGeneral.PowerNum, userGeneral.TrainingPower, short.MaxValue);
                soulNum      = MathUtils.Addition(userGeneral.SoulNum, userGeneral.TrainingSoul, short.MaxValue);
                intellectNum = MathUtils.Addition(userGeneral.IntellectNum, userGeneral.TrainingIntellect, short.MaxValue);
                if (!string.IsNullOrEmpty(ContextUser.MercenariesID) && generalID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    //公会技能加成
                    powerNum     = MathUtils.RoundCustom(powerNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.PowerNum)).ToShort();
                    soulNum      = MathUtils.RoundCustom(soulNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.SoulNum)).ToShort();
                    intellectNum = MathUtils.RoundCustom(intellectNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.IntellectNum)).ToShort();
                }
                if (generalID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    //法宝基础属性加成
                    powerNum     = MathUtils.Addition(powerNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.PowerNum));
                    soulNum      = MathUtils.Addition(soulNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.SoulNum));
                    intellectNum = MathUtils.Addition(intellectNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.IntelligenceNum));

                    //法宝--技能属性转换获得的值
                    //法宝--技能属性转换获得的值
                    decimal trumpPower     = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.PowerNum);
                    decimal trumpsoul      = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.SoulNum);
                    decimal trumpintellect = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.IntelligenceNum);
                    powerNum     = MathUtils.Addition(trumpPower.ToShort(), powerNum);
                    soulNum      = MathUtils.Addition(trumpsoul.ToShort(), soulNum);
                    intellectNum = MathUtils.Addition(trumpintellect.ToShort(), intellectNum);
                }
                lifeNum       = userGeneral.LifeNum;
                lifeMaxNum    = UserHelper.GetMaxLife(lifeUserID, generalID);
                genLv         = userGeneral.GeneralLv;
                generalStatus = (short)userGeneral.GeneralStatus;

                talentAbility = userGeneral.AbilityID;
                _potential    = userGeneral.Potential;
                _battleHeadID = generalInfo.BattleHeadID;
                //玩家佣兵职业名称
                userCareerName = careerInfo.CareerName;
            }
            else if (generalInfo != null)
            {
                genLv         = 1;
                generalName   = generalInfo.GeneralName;
                headID        = generalInfo.HeadID;
                picturesID    = generalInfo.PicturesID;
                _battleHeadId = generalInfo.BattleHeadID;
                careerInfo    = new ShareCacheStruct <CareerInfo>().FindKey(generalInfo.CareerID);
                GeneralEscalateInfo generalEscalate = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(genLv);
                if (generalEscalate != null)
                {
                    currExperience = 0;
                    maxExperience  = generalEscalate.UpExperience;
                }
                powerNum      = generalInfo.PowerNum;
                soulNum       = generalInfo.SoulNum;
                intellectNum  = generalInfo.IntellectNum;
                lifeNum       = generalInfo.LifeNum;
                lifeMaxNum    = generalInfo.LifeNum;
                genLv         = generalInfo.GeneralLv;
                generalStatus = (short)GeneralStatus.KeZhaoMu;

                talentAbility = generalInfo.AbilityID;
            }
            AbilityInfo ability = new ShareCacheStruct <AbilityInfo>().FindKey(talentAbility);

            talentName = ability == null ? string.Empty : ability.AbilityName;

            gPropertyList = CombatHelper.GetAbility(lifeUserID, generalID, userGeneral);

            int sumCrystal = 0;

            foreach (UserCrystalInfo crystal in userCrystalsArrray)
            {
                sumCrystal = MathUtils.Addition(sumCrystal, crystal.CurrExprience, int.MaxValue);
            }
            vitalityNum  = (sumCrystal / 10);
            functionList = ViewHelper.GetFunctionList(lifeUserID);

            //佣兵魂技
            UserAbility userAbility = new PersonalCacheStruct <UserAbility>().FindKey(ContextUser.UserID);

            if (userAbility != null)
            {
                abilityList = userAbility.AbilityList.FindAll(s => s.GeneralID == generalID);
            }
            soulGrid = UserPackHelper.GetPackTypePositionNum(BackpackType.HunJi, ContextUser.UserID);

            // 缘分系统
            KarmaInfo karmaInfo = new ShareCacheStruct <KarmaInfo>().FindKey(generalID);

            if (karmaInfo != null && karmaInfo.KarmaList != null)
            {
                // 满足缘分条件显示激活状态

                // 判断佣兵
                UserMagic    userMagic            = new PersonalCacheStruct <UserMagic>().Find(ContextUser.UserID, s => s.IsEnabled);
                var          cacheSetUserEmbattle = new PersonalCacheStruct <UserEmbattle>();
                List <Karma> yongBingList         = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.YongBing);
                yongBingList.ForEach(yongBingInfo =>
                {
                    //yongBingInfo.IsActive = 1;
                    // 若阵型中存在该记录,该缘分为激活状态
                    if (yongBingInfo.ValueID.Contains(","))
                    {
                        string[] valueID = yongBingInfo.ValueID.Split(',');
                        int i            = 0;
                        foreach (var id in valueID)
                        {
                            if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(id)) != null)
                            {
                                i++;
                            }
                        }
                        yongBingInfo.IsActive = i == valueID.Length ? 1 : 0;
                    }
                    else
                    {
                        if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(yongBingInfo.ValueID)) != null)
                        {
                            yongBingInfo.IsActive = 1;
                        }
                        else
                        {
                            yongBingInfo.IsActive = 0;
                        }
                    }
                });
                // 判断装备
                UserItemPackage itemPackage = new PersonalCacheStruct <UserItemPackage>().FindKey(UserId.ToString());
                if (itemPackage != null)
                {
                    List <Karma> itemList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ZhuangBei);
                    itemList.ForEach(itemInfo =>
                    {
                        if (itemPackage.ItemPackage.Find(s => s.ItemID == MathUtils.ToInt(itemInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            itemInfo.IsActive = 1;
                        }
                        else
                        {
                            itemInfo.IsActive = 0;
                        }
                    });
                }

                // 判断命运水晶
                UserCrystalPackage crystalPackage = new PersonalCacheStruct <UserCrystalPackage>().FindKey(UserId.ToString());
                if (itemPackage != null)
                {
                    List <Karma> crystalList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ShuiJing);
                    crystalList.ForEach(crystalInfo =>
                    {
                        if (crystalPackage.CrystalPackage.Find(s => s.CrystalID == MathUtils.ToInt(crystalInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            crystalInfo.IsActive = 1;
                        }
                        else
                        {
                            crystalInfo.IsActive = 0;
                        }
                    });
                }

                // 判断技能
                UserAbility userAbilityInfo = new PersonalCacheStruct <UserAbility>().FindKey(UserId.ToString());
                if (userAbilityInfo != null)
                {
                    List <Karma> abilityList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.JiNen);
                    abilityList.ForEach(abilityInfo =>
                    {
                        if (userAbilityInfo.AbilityList.Find(s => s.AbilityID == MathUtils.ToInt(abilityInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            abilityInfo.IsActive = 1;
                        }
                        else
                        {
                            abilityInfo.IsActive = 0;
                        }
                    });
                }
                karmaList = karmaInfo.KarmaList;
                if (userGeneral != null)
                {
                    lifeNum    = userGeneral.TLifeNum;
                    lifeMaxNum = userGeneral.TLifeMaxNun;
                }
            }
            return(true);
        }
Beispiel #3
0
        public override bool TakeAction()
        {
            int currMaxLv = GameConfigSet.CurrMaxLv;
            string lifeUserID = string.Empty;

            UserCrystalInfo[] userCrystalsArrray = new UserCrystalInfo[0];
            if (!string.IsNullOrEmpty(toUserID))
            {
                var packageCrystal = UserCrystalPackage.Get(toUserID);
                userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(toUserID, generalID);
                userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray();
                var package = UserItemPackage.Get(toUserID);
                userItemArray = package.ItemPackage.FindAll(
                    u => !u.IsRemove && u.GeneralID.Equals(generalID) &&
                        u.ItemStatus == ItemStatus.YongBing);
                lifeUserID = toUserID;
            }
            else
            {
                var packageCrystal = UserCrystalPackage.Get(ContextUser.UserID);
                userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, generalID);
                userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray();

                var package = UserItemPackage.Get(ContextUser.UserID);
                userItemArray = package.ItemPackage.FindAll(u => !u.IsRemove && u.GeneralID.Equals(generalID) && u.ItemStatus == ItemStatus.YongBing);
                lifeUserID = ContextUser.UserID;
            }
            UserCacheGlobal.LoadOffline(lifeUserID);
            GeneralInfo generalInfo = new ConfigCacheSet<GeneralInfo>().FindKey(generalID);
            generalQuality = generalInfo == null ? (short)0 : generalInfo.GeneralQuality;
            if (generalInfo != null && userGeneral != null)
            {
                description = generalInfo.Description;
                if (userGeneral.GeneralLv >= currMaxLv)
                {
                    genLv = (short)currMaxLv;
                    userGeneral.CurrExperience = 0;
                }
                else
                {
                    genLv = userGeneral.GeneralLv;
                }
                generalName = userGeneral.GeneralName;
                headID = userGeneral.HeadID;
                picturesID = userGeneral.PicturesID;
                _battleHeadId = generalInfo.BattleHeadID;
                _hitProbability = generalInfo.HitProbability;
                careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(userGeneral.CareerID);
                GeneralEscalateInfo generalEscalate = new ConfigCacheSet<GeneralEscalateInfo>().FindKey(genLv);
                if (generalEscalate != null)
                {
                    currExperience = userGeneral.CurrExperience;
                    maxExperience = generalEscalate.UpExperience;
                }
                powerNum = MathUtils.Addition(userGeneral.PowerNum, userGeneral.TrainingPower, short.MaxValue);
                soulNum = MathUtils.Addition(userGeneral.SoulNum, userGeneral.TrainingSoul, short.MaxValue);
                intellectNum = MathUtils.Addition(userGeneral.IntellectNum, userGeneral.TrainingIntellect, short.MaxValue);
                if (!string.IsNullOrEmpty(ContextUser.MercenariesID) && generalID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    //公会技能加成
                    powerNum = MathUtils.RoundCustom(powerNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.PowerNum)).ToShort();
                    soulNum = MathUtils.RoundCustom(soulNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.SoulNum)).ToShort();
                    intellectNum = MathUtils.RoundCustom(intellectNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.IntellectNum)).ToShort();
                }
                if (generalID == LanguageManager.GetLang().GameUserGeneralID)
                {
                    //法宝基础属性加成
                    powerNum = MathUtils.Addition(powerNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.PowerNum));
                    soulNum = MathUtils.Addition(soulNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.SoulNum));
                    intellectNum = MathUtils.Addition(intellectNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.IntelligenceNum));

                    //法宝--技能属性转换获得的值
                    //法宝--技能属性转换获得的值
                    decimal trumpPower = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.PowerNum);
                    decimal trumpsoul = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.SoulNum);
                    decimal trumpintellect = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.IntelligenceNum);
                    powerNum = MathUtils.Addition(trumpPower.ToShort(), powerNum);
                    soulNum = MathUtils.Addition(trumpsoul.ToShort(), soulNum);
                    intellectNum = MathUtils.Addition(trumpintellect.ToShort(), intellectNum);
                }
                lifeNum = userGeneral.LifeNum;
                lifeMaxNum = UserHelper.GetMaxLife(lifeUserID, generalID);
                genLv = userGeneral.GeneralLv;
                generalStatus = (short)userGeneral.GeneralStatus;

                talentAbility = userGeneral.AbilityID;
                _potential = userGeneral.Potential;
                _battleHeadID = generalInfo.BattleHeadID;
                //玩家佣兵职业名称
                userCareerName = careerInfo.CareerName;
            }
            else if (generalInfo != null)
            {
                genLv = 1;
                generalName = generalInfo.GeneralName;
                headID = generalInfo.HeadID;
                picturesID = generalInfo.PicturesID;
                _battleHeadId = generalInfo.BattleHeadID;
                careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(generalInfo.CareerID);
                GeneralEscalateInfo generalEscalate = new ConfigCacheSet<GeneralEscalateInfo>().FindKey(genLv);
                if (generalEscalate != null)
                {
                    currExperience = 0;
                    maxExperience = generalEscalate.UpExperience;
                }
                powerNum = generalInfo.PowerNum;
                soulNum = generalInfo.SoulNum;
                intellectNum = generalInfo.IntellectNum;
                lifeNum = generalInfo.LifeNum;
                lifeMaxNum = generalInfo.LifeNum;
                genLv = generalInfo.GeneralLv;
                generalStatus = (short)GeneralStatus.KeZhaoMu;

                talentAbility = generalInfo.AbilityID;
            }
            AbilityInfo ability = new ConfigCacheSet<AbilityInfo>().FindKey(talentAbility);
            talentName = ability == null ? string.Empty : ability.AbilityName;

            gPropertyList = CombatHelper.GetAbility(lifeUserID, generalID, userGeneral);

            int sumCrystal = 0;
            foreach (UserCrystalInfo crystal in userCrystalsArrray)
            {
                sumCrystal = MathUtils.Addition(sumCrystal, crystal.CurrExprience, int.MaxValue);
            }
            vitalityNum = (sumCrystal / 10);
            functionList = ViewHelper.GetFunctionList(lifeUserID);

            //佣兵魂技
            UserAbility userAbility = new GameDataCacheSet<UserAbility>().FindKey(ContextUser.UserID);
            if (userAbility != null)
            {
                abilityList = userAbility.AbilityList.FindAll(s => s.GeneralID == generalID);
            }
            soulGrid = UserPackHelper.GetPackTypePositionNum(BackpackType.HunJi, ContextUser.UserID);

            // 缘分系统
            KarmaInfo karmaInfo = new ShareCacheStruct<KarmaInfo>().FindKey(generalID);

            if (karmaInfo != null && karmaInfo.KarmaList != null)
            {
                // 满足缘分条件显示激活状态

                // 判断佣兵
                UserMagic userMagic = new GameDataCacheSet<UserMagic>().Find(ContextUser.UserID, s => s.IsEnabled);
                var cacheSetUserEmbattle = new GameDataCacheSet<UserEmbattle>();
                List<Karma> yongBingList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.YongBing);
                yongBingList.ForEach(yongBingInfo =>
                                         {
                                             //yongBingInfo.IsActive = 1;
                                             // 若阵型中存在该记录,该缘分为激活状态
                                             if (yongBingInfo.ValueID.Contains(","))
                                             {
                                                 string[] valueID = yongBingInfo.ValueID.Split(',');
                                                 int i = 0;
                                                 foreach (var id in valueID)
                                                 {
                                                     if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(id)) != null)
                                                     {
                                                         i++;
                                                     }
                                                 }
                                                 yongBingInfo.IsActive = i == valueID.Length ? 1 : 0;

                                             }
                                             else
                                             {
                                                 if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(yongBingInfo.ValueID)) != null)
                                                 {
                                                     yongBingInfo.IsActive = 1;
                                                 }
                                                 else
                                                 {
                                                     yongBingInfo.IsActive = 0;
                                                 }

                                             }
                                         });
                // 判断装备
                UserItemPackage itemPackage = new GameDataCacheSet<UserItemPackage>().FindKey(UserId.ToString());
                if (itemPackage != null)
                {
                    List<Karma> itemList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ZhuangBei);
                    itemList.ForEach(itemInfo =>
                    {
                        if (itemPackage.ItemPackage.Find(s => s.ItemID == MathUtils.ToInt(itemInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            itemInfo.IsActive = 1;
                        }
                        else
                        {
                            itemInfo.IsActive = 0;
                        }
                    });
                }

                // 判断命运水晶
                UserCrystalPackage crystalPackage = new GameDataCacheSet<UserCrystalPackage>().FindKey(UserId.ToString());
                if (itemPackage != null)
                {
                    List<Karma> crystalList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ShuiJing);
                    crystalList.ForEach(crystalInfo =>
                    {
                        if (crystalPackage.CrystalPackage.Find(s => s.CrystalID == MathUtils.ToInt(crystalInfo.ValueID) && s.GeneralID == generalID) != null)
                        {
                            crystalInfo.IsActive = 1;
                        }
                        else
                        {
                            crystalInfo.IsActive = 0;
                        }
                    });
                }

                // 判断技能
                UserAbility userAbilityInfo = new GameDataCacheSet<UserAbility>().FindKey(UserId.ToString());
                if (userAbilityInfo != null)
                {
                    List<Karma> abilityList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.JiNen);
                    abilityList.ForEach(abilityInfo =>
                                            {
                                                if (userAbilityInfo.AbilityList.Find(s => s.AbilityID == MathUtils.ToInt(abilityInfo.ValueID) && s.GeneralID == generalID) != null)
                                                {
                                                    abilityInfo.IsActive = 1;
                                                }
                                                else
                                                {
                                                    abilityInfo.IsActive = 0;
                                                }
                                            });
                }
                karmaList = karmaInfo.KarmaList;
                if (userGeneral != null)
                {
                    lifeNum = userGeneral.TLifeNum;
                    lifeMaxNum = userGeneral.TLifeMaxNun;
                }
            }
            return true;
        }
Beispiel #4
0
        public override bool TakeAction()
        {
            var cacheSet = new PersonalCacheStruct <UserGeneral>();

            if (recruitType == RecruitType.SoulRecruit)
            {
                general = new ShareCacheStruct <GeneralInfo>().FindKey(soulID);
                if (general == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, soulID);
                if (soulID == 0 || userGeneral != null)
                {
                    UserItemHelper.AddUserItem(ContextUser.UserID, general.ItemID, 1);
                }
                else
                {
                    userGeneral        = new UserGeneral();
                    userGeneral.UserID = ContextUser.UserID;
                    cacheSet.Add(userGeneral);
                    userGeneral.GeneralID         = general.GeneralID;
                    userGeneral.GeneralName       = general.GeneralName;
                    userGeneral.HeadID            = general.HeadID;
                    userGeneral.PicturesID        = general.PicturesID;
                    userGeneral.GeneralLv         = (short)general.GeneralLv;
                    userGeneral.LifeNum           = general.LifeNum;
                    userGeneral.GeneralType       = GeneralType.YongBing;
                    userGeneral.CareerID          = general.CareerID;
                    userGeneral.PowerNum          = general.PowerNum;
                    userGeneral.SoulNum           = general.SoulNum;
                    userGeneral.IntellectNum      = general.IntellectNum;
                    userGeneral.TrainingPower     = 0;
                    userGeneral.TrainingSoul      = 0;
                    userGeneral.TrainingIntellect = 0;
                    userGeneral.HitProbability    = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                    userGeneral.AbilityID         = general.AbilityID;
                    userGeneral.Momentum          = 0;
                    userGeneral.Description       = general.Description;
                    userGeneral.GeneralStatus     = GeneralStatus.DuiWuZhong;
                    userGeneral.CurrExperience    = 0;
                    userGeneral.Experience1       = 0;
                    userGeneral.Experience2       = 0;
                }
            }
            else
            {
                RecruitRule recruitRule = new ShareCacheStruct <RecruitRule>().FindKey(recruitType);
                if (recruitRule == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                int surplusNum = GeneralHelper.SurplusNum(ContextUser.UserID, recruitRule.FreeNum,
                                                          recruitRule.RecruitType.ToEnum <RecruitType>());
                if (surplusNum > 0 && !GeneralHelper.GeneralRecruitColdTime(ContextUser.UserID, recruitType))
                {
                    GeneralHelper.UpdateDailyRecruitNum(ContextUser.UserID, recruitType);
                    GeneralHelper.UpdateRecruitColdTime(ContextUser.UserID, recruitRule);
                }
                else
                {
                    if (ContextUser.GoldNum < recruitRule.GoldNum)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, recruitRule.GoldNum);
                }

                CacheList <RecruitInfo> recruitInfos = recruitRule.GeneralQuality;
                double[] probability = new double[recruitInfos.Count];
                for (int i = 0; i < recruitInfos.Count; i++)
                {
                    probability[i] = (double)recruitInfos[i].Probability;
                }
                int            index2      = RandomUtils.GetHitIndex(probability);
                GeneralQuality quality     = recruitInfos[index2].Quality;
                var            generalList = new ShareCacheStruct <GeneralInfo>().FindAll(s => s.GeneralQuality == quality);
                if (generalList.Count > 0)
                {
                    int indexradom = RandomUtils.GetRandom(0, generalList.Count);
                    if (indexradom < 0 || indexradom >= generalList.Count)
                    {
                        return(false);
                    }
                    general = generalList[indexradom];

                    UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, general.GeneralID);

                    if (userGeneral != null && userGeneral.GeneralStatus != GeneralStatus.YinCang)
                    {
                        currSoulID  = general.SoulID;
                        gainNum     = general.DemandNum;
                        userGeneral = cacheSet.FindKey(ContextUser.UserID, currSoulID);
                        if (userGeneral != null)
                        {
                            userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, gainNum);
                            generalType          = GeneralType.Soul;
                        }
                        else
                        {
                            userGeneral           = new UserGeneral();
                            userGeneral.UserID    = ContextUser.UserID;
                            userGeneral.GeneralID = currSoulID;
                            generalType           = GeneralType.Soul;
                            cacheSet.Add(userGeneral);
                            UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID, 1);
                        }
                    }
                    else if (userGeneral == null)
                    {
                        userGeneral           = new UserGeneral();
                        userGeneral.UserID    = ContextUser.UserID;
                        userGeneral.GeneralID = general.GeneralID;
                        generalType           = GeneralType.YongBing;
                        cacheSet.Add(userGeneral);
                        UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID, 1);
                    }
                    userGeneral.GeneralName       = general.GeneralName;
                    userGeneral.HeadID            = general.HeadID;
                    userGeneral.PicturesID        = general.PicturesID;
                    userGeneral.GeneralLv         = (short)general.GeneralLv;
                    userGeneral.LifeNum           = general.LifeNum;
                    userGeneral.GeneralType       = generalType;
                    userGeneral.CareerID          = general.CareerID;
                    userGeneral.PowerNum          = general.PowerNum;
                    userGeneral.SoulNum           = general.SoulNum;
                    userGeneral.IntellectNum      = general.IntellectNum;
                    userGeneral.TrainingPower     = 0;
                    userGeneral.TrainingSoul      = 0;
                    userGeneral.TrainingIntellect = 0;
                    userGeneral.HitProbability    = ConfigEnvSet.GetDecimal("Combat.HitiNum");
                    userGeneral.AbilityID         = general.AbilityID;
                    userGeneral.Momentum          = 0;
                    userGeneral.Description       = general.Description;
                    userGeneral.GeneralStatus     = GeneralStatus.DuiWuZhong;
                    userGeneral.CurrExperience    = 0;
                    userGeneral.Experience1       = 0;
                    userGeneral.Experience2       = 0;

                    //玩家抽取到蓝色和紫色佣兵时,给予系统频道提示
                    //if (recruitType != RecruitType.SoulRecruit)
                    //{
                    //    if (general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Blue || general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Purple)
                    //    {
                    //        string content = string.Empty;
                    //        content = string.Format(LanguageManager.GetLang().St_UserGetGeneralQuality, ContextUser.NickName,recruitType,
                    //                            general.GeneralQuality.ToEnum<GeneralQuality>(), general.GeneralName);
                    //        new TjxChatService().SystemSend(ChatType.System, content);
                    //    }
                    //}
                }
            }
            return(true);
        }
Beispiel #5
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "GeneralID": return(GeneralID);

                case "HeadID": return(HeadID);

                case "PicturesID": return(PicturesID);

                case "GeneralName": return(GeneralName);

                case "GeneralLv": return(GeneralLv);

                case "LifeNum": return(LifeNum);

                case "CareerID": return(CareerID);

                case "PowerNum": return(PowerNum);

                case "SoulNum": return(SoulNum);

                case "IntellectNum": return(IntellectNum);

                case "HitProbability": return(HitProbability);

                case "AbilityID": return(AbilityID);

                case "IsRecruit": return(IsRecruit);

                case "ShowFilter": return(ShowFilter);

                case "RecruitFilter": return(RecruitFilter);

                case "GiftType": return(GiftType);

                case "Description": return(Description);

                case "ReplaceSkills": return(ReplaceSkills);

                case "GeneralType": return(GeneralType);

                case "SoulID": return(SoulID);

                case "DemandNum": return(DemandNum);

                case "Mature": return(Mature);

                case "GeneralQuality": return(GeneralQuality);

                case "ItemID": return(ItemID);

                case "BattleHeadID": return(BattleHeadID);

                case "IsConscribe": return(IsConscribe);

                default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "GeneralID":
                    _GeneralID = value.ToInt();
                    break;

                case "HeadID":
                    _HeadID = value.ToNotNullString();
                    break;

                case "PicturesID":
                    _PicturesID = value.ToNotNullString();
                    break;

                case "GeneralName":
                    _GeneralName = value.ToNotNullString();
                    break;

                case "GeneralLv":
                    _GeneralLv = value.ToShort();
                    break;

                case "LifeNum":
                    _LifeNum = value.ToInt();
                    break;

                case "CareerID":
                    _CareerID = value.ToShort();
                    break;

                case "PowerNum":
                    _PowerNum = value.ToShort();
                    break;

                case "SoulNum":
                    _SoulNum = value.ToShort();
                    break;

                case "IntellectNum":
                    _IntellectNum = value.ToShort();
                    break;

                case "HitProbability":
                    _HitProbability = value.ToDecimal();
                    break;

                case "AbilityID":
                    _AbilityID = value.ToInt();
                    break;

                case "IsRecruit":
                    _IsRecruit = value.ToBool();
                    break;

                case "ShowFilter":
                    _ShowFilter = ConvertCustomField <CacheList <ShowFilterInfo> >(value, index);
                    break;

                case "RecruitFilter":
                    _RecruitFilter = ConvertCustomField <CacheList <RecruitFilter> >(value, index);
                    break;

                case "Description":
                    _Description = value.ToNotNullString();
                    break;

                case "GiftType":
                    _GiftType = value.ToEnum <GiftType>();
                    break;

                case "ReplaceSkills":
                    _ReplaceSkills = ConvertCustomField <SkillInfo>(value, index);
                    break;

                case "GeneralType":
                    _GeneralType = value.ToEnum <GeneralType>();
                    break;

                case "SoulID":
                    _SoulID = value.ToInt();
                    break;

                case "DemandNum":
                    _DemandNum = value.ToInt();
                    break;

                case "Mature":
                    _Mature = ConvertCustomField <CacheList <GeneralProperty> >(value, index);
                    break;

                case "GeneralQuality":
                    _GeneralQuality = value.ToEnum <GeneralQuality>();
                    break;

                case "ItemID":
                    _ItemID = value.ToInt();
                    break;

                case "BattleHeadID":
                    _BattleHeadID = value.ToNotNullString();
                    break;

                case "IsConscribe":
                    _IsConscribe = value.ToBool();
                    break;

                default: throw new ArgumentException(string.Format("GeneralInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
    public int GetCharacteristics(MonstersManager.Characteristic characteristics, int grade, int level, GeneralQuality quality)
    {
        float stat = MonstersManager.GetMonsterCharacteristics(characteristics, m_Params.Params.MobType, grade, level, m_Params.Params.m_NaturalGrade);

        stat *= m_Params.CharacteristicKoeff[(int)characteristics];
        if (IsAwakened(quality))
        {
            float k = BasicParams.GetGradesInfo().GeneralInfo.Awakening * 0.01f / 3;
            if (k > 0.001f)
            {
                stat *= (1 + k);
            }
        }
        return(HelpMethods.Round(stat));
    }
 static bool IsAwakened(GeneralQuality q)
 {
     return(q == GeneralQuality.Epic);
 }