/// <summary> /// 副本奖励,如果通关下发通关奖励 /// </summary> /// <param name="userID"></param> /// <param name="plotNpcInfo"></param> /// <param name="userPlotCombat"></param> internal static void DoPlotPrize(string userID, PlotNPCInfo plotNpcInfo, UserPlotCombat userPlotCombat, int npcGeneralNum, out int honourNum) { honourNum = 0; int experience = 0; PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(plotNpcInfo.PlotID); var package = UserPlotPackage.Get(userID); if (plotInfo == null || plotNpcInfo == null || userPlotCombat == null || package == null) { return; } GameUser user = new PersonalCacheStruct<GameUser>().FindKey(userID); if (user != null) { experience += plotNpcInfo.Experience; userPlotCombat.Experience = plotNpcInfo.Experience; if (!string.IsNullOrEmpty(user.MercenariesID)) { //公会技能加成 userPlotCombat.Experience = MathUtils.RoundCustom(experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt(); experience = userPlotCombat.Experience; } var cacheSetGeneral = new PersonalCacheStruct<UserGeneral>(); var userMagic = new PersonalCacheStruct<UserMagic>().Find(user.UserID, s => s.IsEnabled); int userMagicID = userMagic == null ? 0 : userMagic.MagicID; var userEmbattleList = new PersonalCacheStruct<UserEmbattle>().FindAll(userID, s => s.MagicID == userMagicID && s.GeneralID > 0); int generalNum = 0; userEmbattleList.ForEach(userEmbattle => { var userGeneral = cacheSetGeneral.FindKey(userID, userEmbattle.GeneralID); generalNum = userGeneral != null && userGeneral.LifeNum > 0 ? MathUtils.Addition(generalNum, 1) : generalNum; }); user.GeneralAllCount = MathUtils.Addition(user.GeneralAllCount, userPlotCombat.GeneralNum); user.GeneralKillCount = MathUtils.Addition(user.GeneralKillCount, (userPlotCombat.GeneralNum - generalNum)); //怪物掉落物品) if (plotNpcInfo.IsBoss) { if (plotInfo.PlotType == PlotType.Normal && user.PlotProgress < plotInfo.PlotID) { user.PlotProgress = plotInfo.PlotID; } //日常任务-通关副本 TaskHelper.TriggerDailyTask(userID, 4005); DateTime currDate = DateTime.Now; //通关奖励 var userPlot = UserPlotHelper.GetUserPlotInfo(userID, plotNpcInfo.PlotID); if (userPlot == null) { userPlot = new UserPlotInfo(); userPlot.PlotID = plotNpcInfo.PlotID; userPlot.CreateDate = currDate; package.SaveItem(userPlot); } NoviceHelper.PlotFestivalList(user, plotInfo.PlotID); //活动集合 List<UserPlotCombat> preUserPlotList = new PersonalCacheStruct<UserPlotCombat>().FindAll(userID, m => !m.PlotNpcID.Equals(userPlotCombat.PlotNpcID) && m.PlotID == plotNpcInfo.PlotID); preUserPlotList.Add(userPlotCombat); List<UserPlotCombat> plotCombatList = preUserPlotList; short starScore; PlotSuccessType plotSuccessType = PlotSuccessType.No; userPlot.ScoreNum = GetPlotScoreNum(plotCombatList, out starScore); userPlot.PlotStatus = PlotStatus.Completed; userPlot.AttackScore = 0; userPlot.DefenseScore = 0; userPlot.ItemID = 0; userPlot.EnchantID = 0; userPlot.PlotSuccessType = plotSuccessType; //获得星星等级 if (userPlotCombat.IsWin) { double pren = 0; GetStar(user, generalNum, out starScore, out plotSuccessType, out pren); userPlot.StarScore = starScore; userPlot.PlotSuccessType = plotSuccessType; //获得荣誉值 honourNum = plotInfo.HonourNum; userPlot.PlotNum = MathUtils.Addition(userPlot.PlotNum, 1); if (GetPlotChallengeNum(userID, plotNpcInfo.PlotID) == 1) { if (starScore >= 3) { if (plotInfo.PlotType==PlotType.Elite) // 如果是精英副本 { if (userPlot.FirstWin==false) // 如果是首次获得3星 { userPlot.FirstWin = true; userPlot.ExpNum = (int)(plotInfo.ExpNum * 2); userPlot.PennyNum = (int)(plotInfo.GameCoin * 2); } else { userPlot.ExpNum = plotInfo.ExpNum; userPlot.PennyNum = plotInfo.GameCoin; } } else { userPlot.ExpNum = (int)(plotInfo.ExpNum * 2); userPlot.PennyNum = (int)(plotInfo.GameCoin * 2); } } else { userPlot.ExpNum = plotInfo.ExpNum; userPlot.PennyNum = plotInfo.GameCoin; } honourNum = honourNum * starScore; } else { userPlot.ExpNum = plotInfo.ExpNum; userPlot.PennyNum = plotInfo.GameCoin; } userPlot.HonourNum = honourNum; GeneralEscalateHelper.AddUserLv(user, honourNum); } else { PlotFailureType plotFailureType; GetFailure(npcGeneralNum, out plotFailureType); userPlot.PlotFailureType = plotFailureType; } // userPlot.ExpNum = plotInfo.ExpNum; userPlot.GoldNum = plotInfo.GetRandomGold(); if (!string.IsNullOrEmpty(user.MercenariesID)) { //公会技能加成 userPlot.Experience = MathUtils.RoundCustom(userPlot.Experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt(); userPlot.ExpNum = MathUtils.RoundCustom(userPlot.ExpNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.ExpNum)).ToInt(); userPlot.PennyNum = MathUtils.RoundCustom(userPlot.PennyNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.CoinNum)).ToInt(); } CacheList<PrizeItemInfo> itemList = new CacheList<PrizeItemInfo>(); string itemName = string.Empty; if (plotInfo.PlotType != PlotType.Kalpa) { var copyList = GetPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, userPlot); copyList.Foreach(item => { if (item.Type == 0) { item.RemoveParentEvent(); itemList.Add(item); } return true; }); if (itemList.Count > 0) { userPlot.ItemID = itemList[0].ItemID; var item = new ShareCacheStruct<ItemBaseInfo>().FindKey(userPlot.ItemID); itemName = item != null ? item.ItemName : string.Empty; } } if (!string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0) { var copyList = GetKalpaPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, userPlot); copyList.Foreach(item => { if (item.Type == 2) { itemList.Add(item); if (plotInfo.PlotType != PlotType.Kalpa) { userPlot.EnchantID = item.ItemID; EnchantAddUser(user, item.ItemID); } } return true; }); } if (plotInfo.PlotType == PlotType.Elite) { //精英副本奖励发聊天<label color='0,255,0' >{0}</label><label>{0}</label> string content = string.Format(LanguageManager.GetLang().St_PlotRewardNotice, user.NickName, plotNpcInfo.NpcName, itemName); new TjxChatService().SystemSend(ChatType.World, content); } //祝福加金币 if (UserHelper.GainBlessing(user, 0) > 0) { UserHelper.GainBlessing(user, 1); userPlot.BlessPennyNum = (int)Math.Floor(userPlot.PennyNum * new GuildMember().BlessingCionPercent); userPlot.PennyNum = MathUtils.Addition(userPlot.PennyNum, userPlot.BlessPennyNum); user.GameCoin = MathUtils.Addition(user.GameCoin, userPlot.PennyNum, int.MaxValue); } if (userPlot.CompleteDate <= MathUtils.SqlMinDate) { userPlot.CompleteDate = currDate; } userPlot.RefleshDate = currDate; //experience = userPlot.Experience; //userPlotCombat.Experience = experience; experience += userPlot.Experience + userPlot.BlessExperience; user.GameCoin = MathUtils.Addition(user.GameCoin, userPlot.PennyNum, int.MaxValue); user.ExpNum = MathUtils.Addition(user.ExpNum, userPlot.ExpNum, int.MaxValue); user.ItemGold = MathUtils.Addition(user.ItemGold, userPlot.GoldNum, int.MaxValue); //user.Update(); //奖励日志 UserPlotPrizeLog prizeLog = new UserPlotPrizeLog { PrizeLogID = Guid.NewGuid().ToString(), ScoreNum = userPlot.ScoreNum, StarScore = userPlot.StarScore, PrizeItem = itemList, Experience = userPlot.Experience, ExpNum = userPlot.ExpNum, GameCoin = userPlot.PennyNum, PlotID = userPlot.PlotID, UserID = userID, CreateDate = DateTime.Now }; var sender = DataSyncManager.GetDataSender(); sender.Send(prizeLog); //重置评价 foreach (UserPlotCombat plotCombat in plotCombatList) { //只有一个NPC时更新不了 //if (plotCombatList.Count > 1 && plotCombat.Equals(userPlotCombat)) continue; plotCombat.GeneralNum = 0; plotCombat.GeneralOverNum = 0; plotCombat.OverNum = 0; //plotCombat.Update(); } //通关副本 副本ID清空 if (user.UserExtend != null) { user.UserExtend.UpdateNotify(obj => { user.UserExtend.PlotStatusID = 0; user.UserExtend.PlotNpcID = 0; user.UserExtend.MercenarySeq = 0; return true; }); } package.SaveItem(userPlot); user.GeneralAllCount = 0; user.GeneralKillCount = 0; if (plotInfo.PlotType == PlotType.Normal) { int multiple = FestivalHelper.DuplicateDropDouble(user.UserID); if (multiple > 1) { FestivalHelper.DuplicateDropDoubleRestrain(user.UserID); } } } //佣兵经验 AddExprerience(user, experience); } }
/// <summary> /// 副本扫荡奖励 /// </summary> /// <param name="userID"></param> /// <param name="plotID"></param> /// <param name="turnsNum"></param> /// <param name="battleNum"></param> /// <param name="npcCount"></param> internal static void DoPlotSweepPrize(string userID, int plotID, int turnsNum, int battleNum, int npcCount) { GameUser user = new PersonalCacheStruct<GameUser>().FindKey(userID); if (user == null) { return; } int experience = 0; var npcList = new ShareCacheStruct<PlotNPCInfo>().FindAll(m => m.PlotID == plotID && m.NpcSeqNo == battleNum); if (npcList.Count == 0) return; PlotNPCInfo npcInfo = npcList[0]; experience += npcInfo.Experience; var cacheSet = new PersonalCacheStruct<UserSweepPool>(); UserSweepPool sweepPool = cacheSet.FindKey(userID, turnsNum, battleNum); if (sweepPool == null) { sweepPool = new UserSweepPool { UserID = userID, CreateDate = DateTime.Now }; } sweepPool.PlotID = plotID; sweepPool.TurnsNum = turnsNum; sweepPool.BattleNum = battleNum; sweepPool.Experience = npcInfo.Experience; sweepPool.ExpNum = npcInfo.ExpNum; sweepPool.GameCoin = npcInfo.GameCoin; sweepPool.Gold = npcInfo.GetRandomGold(); sweepPool.PrizeItems = GetPlotMonsterItems(userID, npcInfo.PlotNpcID); sweepPool.IsSend = false; if (cacheSet.FindKey(userID, turnsNum, battleNum) == null) { cacheSet.Add(sweepPool); } //else //{ // sweepPool.Update(); //} user.ExpNum = MathUtils.Addition(user.ExpNum, sweepPool.ExpNum, int.MaxValue); user.GameCoin = MathUtils.Addition(user.GameCoin, sweepPool.GameCoin + sweepPool.BlessPennyNum, int.MaxValue); user.ItemGold = MathUtils.Addition(user.ItemGold, sweepPool.Gold, int.MaxValue); if (battleNum == npcCount) { PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(plotID); experience += plotInfo.Experience; //通关奖励 int tempNum = 10; //var cacheSet = new PersonalCacheStruct<UserSweepPool>(); if (cacheSet.FindKey(userID, turnsNum, tempNum) == null) { sweepPool = new UserSweepPool { UserID = userID, CreateDate = DateTime.Now }; } sweepPool.PlotID = plotID; sweepPool.TurnsNum = turnsNum; sweepPool.BattleNum = tempNum; sweepPool.Experience = plotInfo.Experience; sweepPool.ExpNum = plotInfo.ExpNum; sweepPool.GameCoin = plotInfo.GameCoin; sweepPool.Gold = plotInfo.GetRandomGold(); sweepPool.PrizeItems = GetPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, null); sweepPool.IsSend = false; //祝福加金币 if (UserHelper.GainBlessing(user, 0) > 0) { UserHelper.GainBlessing(user, 1); sweepPool.BlessPennyNum = (int)Math.Floor(plotInfo.GameCoin * new GuildMember().BlessingCionPercent); } if (!string.IsNullOrEmpty(user.MercenariesID)) { //公会技能加成 sweepPool.Experience = MathUtils.RoundCustom(sweepPool.Experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt(); sweepPool.ExpNum = MathUtils.RoundCustom(sweepPool.ExpNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.ExpNum)).ToInt(); sweepPool.GameCoin = MathUtils.RoundCustom(sweepPool.GameCoin * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.CoinNum)).ToInt(); } if (cacheSet.FindKey(userID, turnsNum, tempNum) == null) { cacheSet.Add(sweepPool); } user.ExpNum = MathUtils.Addition(user.ExpNum, sweepPool.ExpNum, int.MaxValue); user.GameCoin = MathUtils.Addition(user.GameCoin, sweepPool.GameCoin, int.MaxValue); user.ItemGold = MathUtils.Addition(user.ItemGold, sweepPool.Gold, int.MaxValue); //日常任务-通关副本 TaskHelper.TriggerDailyTask(userID, 4005); } //user.Update(); //佣兵经验 //UserHelper.UserGeneralExp(user.UserID, experience); TaskHelper.KillPlotMonster(userID, plotID, npcList[0].PlotNpcID); TrumpAbilityAttack.CombatTrumpLift(userID); }