/// <summary> /// 考古战役 /// </summary> /// <param name="user"></param> /// <param name="plotNpcID"></param> /// <returns></returns> public static ISingleCombat TriggerArchaeologyPlot(GameUser user, int plotNpcID) { ICombatController controller = new TjxCombatController(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.KaoGuPlot); plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID)); plotCombater.SetDefend(new MonsterQueue(plotNpcID)); return(plotCombater); }
/// <summary> /// 圣吉塔战役 /// </summary> /// <param name="user"></param> /// <param name="plotNpcID"></param> /// <returns></returns> public static ISingleCombat TriggerSJTPlot(GameUser user, int plotNpcID, double difficultNum) { ICombatController controller = new TjxCombatController(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.ShengJiTa); plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID)); plotCombater.SetDefend(new MonsterQueue(plotNpcID, difficultNum)); return(plotCombater); }
/// <summary> /// 国家战 /// </summary> /// <param name="cuser1">发起人</param> /// <param name="cuser2"></param> /// <returns></returns> public static ISingleCombat TriggerTournament(CountryUser cuser1, CountryUser cuser2) { TrumpAbilityAttack.CombatTrumpLift(cuser1.UserId); //法宝每战斗M次就扣除N点寿命 ICombatController controller = new TjxCombatController(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.Country); plotCombater.SetAttack(new UserEmbattleQueue(cuser1.UserId, GetMagicId(cuser1.UserId), cuser1.InspirePercent, CombatType.Country)); plotCombater.SetDefend(new UserEmbattleQueue(cuser2.UserId, GetMagicId(cuser2.UserId), cuser2.InspirePercent, CombatType.Country)); return(plotCombater); }
/// <summary> /// 副本战役 /// </summary> /// <param name="user"></param> /// <param name="plotNpcID"></param> /// <returns></returns> public static ISingleCombat TriggerPlot(GameUser user, int plotNpcID) { //TrumpAbilityAttack.CombatTrumpLift(user.UserID); //法宝每战斗M次就扣除N点寿命 ICombatController controller = new TjxCombatController(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.Plot); plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID)); plotCombater.SetDefend(new MonsterQueue(plotNpcID)); return(plotCombater); }
/// <summary> /// 玩家竞技 /// </summary> /// <param name="user1">发起人</param> /// <param name="user2"></param> /// <returns></returns> public static ISingleCombat TriggerTournament(GameUser user1, GameUser user2) { //TrumpAbilityAttack.CombatTrumpLift(user1.UserID); //法宝每战斗M次就扣除N点寿命 ICombatController controller = new TjxCombatController(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.User); user1 = UserCacheGlobal.LoadOffline(user1.UserID); user2 = UserCacheGlobal.LoadOffline(user2.UserID); if (user1 != null && user2 != null) { plotCombater.SetAttack(new UserEmbattleQueue(user1.UserID, user1.UseMagicID, 0, CombatType.User)); plotCombater.SetDefend(new UserEmbattleQueue(user2.UserID, user2.UseMagicID, 0, CombatType.User)); } return(plotCombater); }
/// <summary> /// 触发战斗 /// </summary> /// <param name="user"></param> /// <param name="bossCombatProcess"></param> /// <returns></returns> public bool Combat(GameUser user, BossCombatProcess bossCombatProcess) { CombatGeneral bossGeneral = Boss; bossGeneral.LossLifeNum = 0; bool isWin = false; BossUser bossUser = GetCombatUser(user.UserID); ICombatController controller = CombatControllerFactory.Create(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.BossPlot); double inspirePercent = bossUser.InspirePercent + bossUser.ReliveInspirePercent; plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID, inspirePercent, CombatType.BossPlot)); plotCombater.SetDefend(new MonsterQueue(bossGeneral)); isWin = plotCombater.Doing(); bossCombatProcess.ProcessContainer = (CombatProcessContainer)plotCombater.GetProcessResult(); bossUser.CombatNum += 1; bossUser.DamageNum = MathUtils.Addition(bossUser.DamageNum, bossGeneral.LossLifeNum, int.MaxValue); bossCombatProcess.LiveNum = bossGeneral.LifeNum; bossCombatProcess.DamageNum = bossGeneral.LossLifeNum; bossCombatProcess.IsWin = isWin; bossCombatProcess.UserId = user.UserID; DoDamagePrize(user, bossGeneral.LossLifeNum, bossCombatProcess); if (isWin && bossGeneral.IsOver) { //GameActive active = GameActive; UserGuild guild = UserGuild; short bossprizeLv = 0; int killbossrate = 0; if (guild.BossPrize != null) { bossprizeLv = (short)guild.BossPrize.KillBossLv; killbossrate = guild.BossPrize.KillBossRate; //击杀奖 BossActivePrize bossPrize = UserGuild.BossPrize; string prizeItemMsg = string.Empty; DoTopThreePrize(0, user, bossPrize.KillReward, bossPrize.Items, out prizeItemMsg); } short lv = MathUtils.Subtraction(bossGeneral.Lv, bossprizeLv, (short)1); int killCoin = lv * killbossrate; user.GameCoin = MathUtils.Addition(user.GameCoin, killCoin, int.MaxValue); // new CacheChat().SystemSend(ChatType.World, string.Format("{0}玩家获得公会Boss战击杀奖,奖励{1}金币", user.NickName, killCoin)); new TjxChatService(user).SystemGuildSend(ChatType.Guild, string.Format(LanguageManager.GetLang().St6105_CombatKillReward, user.NickName, killCoin)); bossCombatProcess.KillGameCoin = killCoin; DoKillPrize(); int tempMinute = gameActive.Minutes - ConfigEnvSet.GetInt("BossCombat.KillTime"); int subSeconds = (int)new TimeSpan(0, tempMinute, 0).TotalSeconds; if (subSeconds - guild.ColdTime < 0) { //Boss自动升级 guild.GuildBossInfo.UpdateNotify(obj => { guild.GuildBossInfo.BossLv = MathUtils.Addition(guild.GuildBossInfo.BossLv, (short)1, short.MaxValue); return(true); }); //guild.Update(); } guild.CombatStatus = CombatStatus.Killed; CombatHelper.UpdateGuildBossKill(guild.GuildID); //公会boss已被杀 } else { bossUser.IsRelive = true; bossUser.ReliveBeginDate = DateTime.Now; } //日志 var log = new UserCombatLog { CombatLogID = Guid.NewGuid().ToString(), UserID = user.UserID, CityID = user.CityID, PlotID = gameActive == null ? 0 : gameActive.BossPlotID, NpcID = bossGeneral.GeneralID, CombatType = CombatType.BossPlot, HostileUser = string.Empty, IsWin = isWin, CombatProcess = JsonUtils.Serialize(bossCombatProcess), CreateDate = DateTime.Now }; var sender = DataSyncManager.GetDataSender(); sender.Send(log); //user.Update(); return(isWin); }
private void DoCombat(MorePlotTeam team) { //初始阵形 var plotNpcTeam = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == team.MorePlot.PlotID); List <MonsterQueue> monsterQueueList = new List <MonsterQueue>(plotNpcTeam.Count); var userEmbattleList = new List <UserEmbattleQueue>(team.UserList.Count); foreach (var npcInfo in plotNpcTeam) { monsterQueueList.Add(new MonsterQueue(npcInfo.PlotNpcID)); } foreach (var user in team.UserList) { var gameUser = new PersonalCacheStruct <GameUser>().FindKey(user.UserId); userEmbattleList.Add(new UserEmbattleQueue(user.UserId, gameUser.UseMagicID, 0, CombatType.MultiPlot)); } bool isLoop = true; int maxCount = 0; while (isLoop) { if (maxCount > 500) { break; } int overNum = 0; for (int i = 0; i < userEmbattleList.Count; i++) { maxCount++; int position; var userEmbattle = userEmbattleList[i]; if (userEmbattle.IsOver) { overNum++; continue; } var monster = GetMonster(monsterQueueList, i, out position); if (monster == null || monster.IsOver) { team.CombatResult = true; isLoop = false; break; } ICombatController controller = new TjxCombatController(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.MultiPlot); plotCombater.SetAttack(userEmbattle); plotCombater.SetDefend(monster); bool IsWin = plotCombater.Doing(); var processLost = new TeamCombatProcess { TeamID = team.TeamID, PlotID = team.MorePlot.PlotID, Position = position, ProcessContainer = (CombatProcessContainer)plotCombater.GetProcessResult(), UserId = team.UserList[i].UserId, PlotNpcID = plotNpcTeam[position].PlotNpcID, IsWin = IsWin }; //new BaseLog().SaveDebuLog(string.Format("多人副本>>{4}组队{0}打{1}位置{2}结果{3}", processLost.UserId, processLost.PlotNpcID, position + 1, IsWin, team.TeamID)); AppendLog(team.TeamID, processLost); } if (overNum == userEmbattleList.Count) { team.CombatResult = false; isLoop = false; } } //奖励 if (team.CombatResult) { //new BaseLog().SaveDebuLog(string.Format("多人副本>>组队{0}结果{1}", team.TeamID, team.CombatResult)); SetCombatResult(team.TeamID, team.CombatResult); var chatService = new TjxChatService(); foreach (var user in team.UserList) { GameUser gameUser = new PersonalCacheStruct <GameUser>().FindKey(user.UserId); gameUser.ExpNum = MathUtils.Addition(gameUser.ExpNum, team.MorePlot.ExpNum, int.MaxValue); //gameUser.Update(); UserItemHelper.AddUserItem(user.UserId, team.MorePlot.ItemId, team.MorePlot.ItemNum); new BaseLog("参加多人副本获得奖励:" + team.MorePlot.ItemName); SetWinNum(user.UserId, team.MorePlot.PlotID); CombatHelper.DailyMorePlotRestrainNum(gameUser.UserID, team.MorePlot.PlotID); // 多人副本获胜加一次 chatService.SystemSendWhisper(gameUser, string.Format(LanguageManager.GetLang().St4211_MorePlotReward, team.MorePlot.ExpNum, team.MorePlot.ItemName, team.MorePlot.ItemNum)); } } }
/// <summary> /// 触发战斗 /// </summary> /// <param name="user"></param> /// <param name="bossCombatProcess"></param> /// <returns></returns> public bool Combat(GameUser user, BossCombatProcess bossCombatProcess) { CombatGeneral bossGeneral = Boss; bossGeneral.LossLifeNum = 0; BossUser bossUser = GetCombatUser(user.UserID); ICombatController controller = CombatControllerFactory.Create(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.BossPlot); double inspirePercent = bossUser.InspirePercent + bossUser.ReliveInspirePercent; plotCombater.SetAttack(new UserEmbattleQueue(user.UserID, user.UseMagicID, inspirePercent, CombatType.BossPlot)); plotCombater.SetDefend(new MonsterQueue(Boss)); bool isWin = plotCombater.Doing(); bossCombatProcess.ProcessContainer = (CombatProcessContainer)plotCombater.GetProcessResult(); bossUser.CombatNum += 1; bossUser.DamageNum = MathUtils.Addition(bossUser.DamageNum, bossGeneral.LossLifeNum, int.MaxValue); bossCombatProcess.LiveNum = bossGeneral.LifeNum; bossCombatProcess.DamageNum = bossGeneral.LossLifeNum; bossCombatProcess.IsWin = isWin; bossCombatProcess.UserId = user.UserID; DoDamagePrize(user, bossGeneral.LossLifeNum, bossCombatProcess); if (isWin && bossGeneral.IsOver) { GameActive active = GameActive; short lv = MathUtils.Subtraction(bossGeneral.Lv, (short)active.BossPrize.KillBossLv, (short)1); int killCoin = lv * active.BossPrize.KillBossRate; user.GameCoin = MathUtils.Addition(user.GameCoin, killCoin, int.MaxValue); new TjxChatService().SystemSend(ChatType.World, string.Format(LanguageManager.GetLang().St5405_CombatKillReward, user.NickName, killCoin)); TraceLog.ReleaseWriteDebug(string.Format(LanguageManager.GetLang().St5405_CombatKillReward, user.NickName, killCoin)); bossCombatProcess.KillGameCoin = killCoin; ServerEnvSet.Set(ServerEnvKey.KillBossUserID, user.UserID); DoKillPrize(user); int tempMinute = active.Minutes - ConfigEnvSet.GetInt("BossCombat.KillTime"); if (new TimeSpan(0, tempMinute, 0).TotalSeconds - active.ColdTime < 0) { //Boss自动升级 active.BossLv = MathUtils.Addition(active.BossLv, (short)1); //active.Update(); } active.CombatStatus = CombatStatus.Killed; CombatHelper.BossKillDate(); //增加boss被杀时间 } else { bossUser.IsRelive = true; bossUser.ReliveBeginDate = DateTime.Now; } //日志 var log = new UserCombatLog { CombatLogID = Guid.NewGuid().ToString(), UserID = user.UserID, CityID = user.CityID, PlotID = GameActive == null ? 0 : GameActive.BossPlotID, NpcID = bossGeneral.GeneralID, CombatType = CombatType.BossPlot, HostileUser = string.Empty, IsWin = isWin, CombatProcess = JsonUtils.Serialize(bossCombatProcess), CreateDate = DateTime.Now }; var sender = DataSyncManager.GetDataSender(); sender.Send(log); //user.Update(); return(isWin); }