Beispiel #1
0
 private static void AppendLog(int teamId, TeamCombatProcess logTeam)
 {
     if (_combatProcessList != null)
     {
         if (!_combatProcessList.ContainsKey(teamId))
         {
             _combatProcessList.Add(teamId, new TeamCombatResult());
         }
         lock (ThisLock)
         {
             TeamCombatResult tempList = _combatProcessList[teamId];
             tempList.ProcessList.Add(logTeam);
         }
         UserCombatLog log = new UserCombatLog
         {
             CombatLogID = Guid.NewGuid().ToString(),
             CombatType = CombatType.MultiPlot,
             UserID = logTeam.UserId,
             PlotID = logTeam.PlotID,
             NpcID = logTeam.PlotNpcID,
             HostileUser = logTeam.TeamID.ToString(),
             IsWin = logTeam.IsWin,
             CombatProcess = JsonUtils.Serialize(logTeam.ProcessContainer),
             CreateDate = DateTime.Now
         };
         var sender = DataSyncManager.GetDataSender();
         sender.Send(log);
     }
 }
Beispiel #2
0
        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));

                }
            }
        }