Exemple #1
0
        private void CreateGeneral(CareerInfo careerInfo)
        {
            GeneralInfo general = new ShareCacheStruct<GeneralInfo>().FindKey(generalID);
            List<UserGeneral> userGeneralArray = new PersonalCacheStruct<UserGeneral>().FindAll(UserId.ToString());
            if (userGeneralArray.Count > 0 || general == null)
            {
                return;
            }

            UserGeneral userGeneral = new UserGeneral();
            userGeneral.UserID = UserId.ToString();
            userGeneral.GeneralID = general.GeneralID;
            userGeneral.GeneralName = general.GeneralName;
            userGeneral.HeadID = general.HeadID;
            userGeneral.PicturesID = general.PicturesID;
            userGeneral.GeneralLv = (short)careerInfo.Lv;
            userGeneral.GeneralType = GeneralType.YongHu;
            userGeneral.CareerID = _careerID;
            userGeneral.PowerNum = general.PowerNum;
            userGeneral.SoulNum = general.SoulNum;
            userGeneral.IntellectNum = general.IntellectNum;
            userGeneral.TrainingPower = 0;
            userGeneral.TrainingSoul = 0;
            userGeneral.TrainingIntellect = 0;
            userGeneral.AbilityID = general.AbilityID;
            userGeneral.Momentum = 0;
            userGeneral.Description = string.Empty;
            userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum");
            userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong;
            userGeneral.CurrExperience = 0;
            userGeneral.Experience1 = 0;
            userGeneral.Experience2 = 0;
            //userGeneral.LifeNum = MathUtils.Addition(general.LifeNum, careerInfo.LifeIncreaseNum * (MathUtils.Subtraction(careerInfo.Lv, (short)1, (short)0)), int.MaxValue);
            userGeneral.RefreshMaxLife();
            userGeneral.HeritageType = HeritageType.Normal;
            userGeneral.AbilityNum = 3;
            var cacheSet = new PersonalCacheStruct<UserGeneral>();
            cacheSet.Add(userGeneral);
            cacheSet.Update();
            UserAbilityHelper.AddUserAbility(general.AbilityID, UserId, generalID, 1);
          
        }
Exemple #2
0
 private static decimal GetCareerAddition(CareerInfo careerInfo, AbilityType abilityType)
 {
     CareerAdditionInfo addition = new ConfigCacheSet<CareerAdditionInfo>().FindKey(careerInfo.CareerID, abilityType);
     return addition != null ? addition.AdditionNum : 0;
 }
Exemple #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;
        }