public override bool TakeAction() { var plotTeam = new PlotTeamCombat(ContextUser); MorePlotTeam moreTeam = plotTeam.GetTeam(teamID); if (moreTeam != null && moreTeam.UserList.Count <= 1) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St4210_PeopleNotEnough; return(false); } PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(plotID); if (plotInfo == null) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St4210_PlotNotEnough; return(false); } if (!plotTeam.DoStart(teamID)) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } return(true); }
/// <summary> /// 创建组队 /// </summary> /// <param name="user"></param> /// <param name="plotId"></param> /// <returns></returns> private int Create(GameUser user, int plotId) { if (_teamList == null) { return(-1); } int teamId = NextTeamId; MorePlot morePlot = GetItem(plotId); var team = new MorePlotTeam { MorePlot = morePlot, TeamID = teamId, TeamUser = new TeamUser { UserId = user.UserID, NickName = user.NickName, //UserLv = user.UserLv, //UseMagicID = user.UseMagicID }, CombatResult = false, Status = 1, }; _teamList.Add(teamId, team); AddTeam(teamId); return(teamId); }
public override bool TakeAction() { var plotTeam = new PlotTeamCombat(ContextUser); moreTeam = plotTeam.GetTeam(teamID); return(true); }
/// <summary> /// 活动获取等待组队列表 /// </summary> /// <returns></returns> public List <MorePlotTeam> ToMoreTeamList() { List <MorePlotTeam> list = new List <MorePlotTeam>(); if (_teamList != null) { var cuserList = _teamList.ToList(); foreach (KeyValuePair <int, MorePlotTeam> keyPair in cuserList) { MorePlotTeam cuser = keyPair.Value; if (cuser.IsAllow && IsMoreCombat(cuser.MorePlot.PlotID)) { list.Add(cuser); } } } return(list); }
/// <summary> /// 获取等待组队列表 /// </summary> /// <returns></returns> public List <MorePlotTeam> ToTeamList() { List <MorePlotTeam> list = new List <MorePlotTeam>(); if (_teamList != null) { KeyValuePair <int, MorePlotTeam>[] cuserList; _teamList.CopyTo(out cuserList, 0); foreach (KeyValuePair <int, MorePlotTeam> keyPair in cuserList) { MorePlotTeam cuser = keyPair.Value; if (cuser.IsAllow && IsCombat(cuser.MorePlot.PlotID)) { list.Add(cuser); } } } return(list); }
/// <summary> /// 快速加入 活动 /// 优先顺序:副本低到高,队中人数高到低 改为随机 /// </summary> /// <param name="teamId"></param> public bool AddMoreTeam(out int teamId) { teamId = -1; List <MorePlotTeam> tempList = new List <MorePlotTeam>(); List <MorePlotTeam> list = ToMoreTeamList(); //ToTeamList(); foreach (MorePlotTeam item in list) { MorePlotTeam cuser = item; if (cuser.IsAllow && IsMoreCombat(cuser.MorePlot.PlotID)) { tempList.Add(cuser); } } if (tempList.Count > 0) { MorePlotTeam team = tempList[RandomUtils.GetRandom(0, list.Count)]; teamId = team.TeamID; AddTeam(teamId); return(true); } return(false); }
public override bool TakeAction() { var plotTeam = new PlotTeamCombat(ContextUser); teamCombatResult = plotTeam.GetCombatProcess(teamID); teamPlot = plotTeam.GetTeam(teamID); plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(plotID); if (teamCombatResult.IsWin) { //日常任务-多人副本 TaskHelper.TriggerDailyTask(Uid, 4007); if (ContextUser.UserExtend != null && ContextUser.UserExtend.DailyInfo != null) { if (ContextUser.UserExtend.DailyInfo.RefreshDate.Date == DateTime.Now.Date) { ContextUser.UserExtend.DailyInfo.MoreNum = MathUtils.Addition(ContextUser.UserExtend.DailyInfo.MoreNum, 1); } else { ContextUser.UserExtend.DailyInfo.RefreshDate = DateTime.Now; ContextUser.UserExtend.DailyInfo.MoreNum = 1; } } else if (ContextUser.UserExtend != null) { DailyRefresh dailyRefresh = new DailyRefresh(); dailyRefresh.RefreshDate = DateTime.Now; dailyRefresh.MoreNum = 1; ContextUser.UserExtend.DailyInfo = dailyRefresh; } //ContextUser.Update(); } return(true); }
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)); } } }