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); }