예제 #1
0
 public void AddCopyScene(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
 {
     if (copyMap.MapCode == this.MapCode)
     {
         int fuBenSeqId = copyMap.FuBenSeqID;
         int mapCode    = copyMap.MapCode;
         lock (this.copyDict)
         {
             MoRiJudgeCopy copy = null;
             if (!this.copyDict.TryGetValue(fuBenSeqId, out copy))
             {
                 copy           = new MoRiJudgeCopy();
                 copy.MyCopyMap = copyMap;
                 copy.GameId    = Global.GetClientKuaFuServerLoginData(client).GameId;
                 copy.StateTimeData.GameType = 3;
                 copy.StartTime            = TimeUtil.NowDateTime();
                 copy.EndTime              = copy.StartTime.AddMinutes((double)this.CopyMaxAliveMinutes);
                 copy.LimitKillCount       = 0;
                 copy.RoleCount            = 1;
                 copy.Passed               = false;
                 this.copyDict[fuBenSeqId] = copy;
             }
             else
             {
                 copy.RoleCount++;
             }
         }
         FuBenManager.AddFuBenSeqID(client.ClientData.RoleID, copyMap.FuBenSeqID, 0, copyMap.FubenMapID);
         copyMap.IsKuaFuCopy = true;
         copyMap.SetRemoveTicks(TimeUtil.NOW() + (long)((this.CopyMaxAliveMinutes + 3) * 60000));
         GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 1, 0, 0, 3);
     }
 }
예제 #2
0
        /// <summary>
        /// 添加副本
        /// </summary>
        /// <param name="client"></param>
        /// <param name="copyMap"></param>
        /// <param name="sceneType"></param>
        public void AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            if (sceneType != SceneUIClasses.CoupleArena)
            {
                return;
            }

            int fuBenSeqId = copyMap.FuBenSeqID;
            int mapCode    = copyMap.MapCode;

            lock (Mutex)
            {
                CoupleArenaCopyScene scene = null;
                if (!this.FuBenSeq2CopyScenes.TryGetValue(fuBenSeqId, out scene))
                {
                    scene          = new CoupleArenaCopyScene();
                    scene.GameId   = (int)Global.GetClientKuaFuServerLoginData(client).GameId;
                    scene.FuBenSeq = fuBenSeqId;
                    scene.MapCode  = mapCode;
                    scene.CopyMap  = copyMap;

                    FuBenSeq2CopyScenes[fuBenSeqId] = scene;
                }

                scene.EnterRoleSide[client.ClientData.RoleID] = client.ClientData.BattleWhichSide;
                copyMap.IsKuaFuCopy = true;
                copyMap.SetRemoveTicks(TimeUtil.NOW() + (WarCfg.WaitSec + WarCfg.FightSec + WarCfg.ClearSec + 120) * TimeUtil.SECOND);
                GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 1, 0, 0, (int)GameTypes.CoupleArena);
            }
        }
예제 #3
0
        // 添加一个末日审判副本
        public void AddCopyScene(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            if (copyMap.MapCode == this.MapCode)
            {
                int fuBenSeqId = copyMap.FuBenSeqID;
                int mapCode    = copyMap.MapCode;

                lock (copyDict)
                {
                    MoRiJudgeCopy copy = null;
                    if (!copyDict.TryGetValue(fuBenSeqId, out copy))
                    {
                        copy           = new MoRiJudgeCopy();
                        copy.MyCopyMap = copyMap;
                        copy.GameId    = Global.GetClientKuaFuServerLoginData(client).GameId;
                        copy.StateTimeData.GameType = (int)GameTypes.MoRiJudge;

                        // 副本的统计信息
                        copy.StartTime      = TimeUtil.NowDateTime();
                        copy.EndTime        = copy.StartTime.AddMinutes(this.CopyMaxAliveMinutes);
                        copy.LimitKillCount = 0;
                        copy.RoleCount      = 1;
                        copy.Passed         = false;

                        copyDict[fuBenSeqId] = copy;
                    }
                    else
                    {
                        copy.RoleCount++;
                    }
                }

                FuBenManager.AddFuBenSeqID(client.ClientData.RoleID, copyMap.FuBenSeqID, 0, copyMap.FubenMapID);

                copyMap.IsKuaFuCopy = true;
                // 增加清除时间
                copyMap.SetRemoveTicks(TimeUtil.NOW() + (this.CopyMaxAliveMinutes + 3) * TimeUtil.MINITE);

                //更新状态
                //  MoRiJudgeClient.getInstance().GameFuBenRoleChangeState(client.ClientData.RoleID, (int)KuaFuRoleStates.StartGame);
                // 开始游戏统计
                GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 1, 0, 0, (int)GameTypes.MoRiJudge);
            }
        }
예제 #4
0
        public void TimerProc()
        {
            long nowMs = TimeUtil.NOW();

            if (nowMs >= this.NextHeartBeatMs)
            {
                this.NextHeartBeatMs = nowMs + 1020L;
                List <MoRiJudgeCopy> copyList = null;
                lock (this.copyDict)
                {
                    copyList = this.copyDict.Values.ToList <MoRiJudgeCopy>();
                }
                if (copyList != null && copyList.Count > 0)
                {
                    foreach (MoRiJudgeCopy judgeCopy in copyList)
                    {
                        lock (judgeCopy)
                        {
                            if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_NULL)
                            {
                                judgeCopy.m_eStatus              = GameSceneStatuses.STATUS_PREPARE;
                                judgeCopy.CurrStateBeginMs       = nowMs;
                                judgeCopy.DeadlineMs             = nowMs + (long)(this.CopyMaxAliveMinutes * 60 * 1000);
                                judgeCopy.StateTimeData.State    = 2;
                                judgeCopy.StateTimeData.EndTicks = judgeCopy.DeadlineMs;
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_PREPARE)
                            {
                                if (nowMs >= judgeCopy.CurrStateBeginMs + 1500L)
                                {
                                    judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_BEGIN;
                                    judgeCopy.CurrStateBeginMs = nowMs;
                                }
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                                if (nowMs >= judgeCopy.DeadlineMs || (nowMs >= judgeCopy.CurrStateBeginMs + 90000L && judgeCopy.RoleCount <= 0))
                                {
                                    judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                                    judgeCopy.CurrStateBeginMs = nowMs;
                                    break;
                                }
                                int nextMonsterIdx = -1;
                                if (judgeCopy.CurrMonsterIdx == -1)
                                {
                                    nextMonsterIdx = 0;
                                }
                                else if (judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs > 0L && nowMs >= judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs + 1300L)
                                {
                                    nextMonsterIdx = judgeCopy.CurrMonsterIdx + 1;
                                }
                                if (nextMonsterIdx != -1)
                                {
                                    if (nextMonsterIdx >= this.BossConfigList.Count)
                                    {
                                        judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                                        judgeCopy.CurrStateBeginMs = nowMs;
                                    }
                                    else
                                    {
                                        this.FlushMonster(judgeCopy, nextMonsterIdx);
                                    }
                                }
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_END)
                            {
                                GameManager.CopyMapMgr.KillAllMonster(judgeCopy.MyCopyMap);
                                judgeCopy.EndTime = TimeUtil.NowDateTime();
                                int roleCount = 0;
                                List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                                if (clientList != null && clientList.Count > 0)
                                {
                                    int combatSum = 0;
                                    foreach (GameClient client in clientList)
                                    {
                                        roleCount++;
                                        combatSum += client.ClientData.CombatForce;
                                        if (judgeCopy.Passed)
                                        {
                                            GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, 3);
                                        }
                                        else
                                        {
                                            GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, 3);
                                        }
                                    }
                                    if (roleCount > 0)
                                    {
                                        int combatAvg = combatSum / roleCount;
                                    }
                                    if (judgeCopy.Passed)
                                    {
                                        GameManager.CopyMapMgr.CopyMapPassAwardForAll(clientList[0], judgeCopy.MyCopyMap, false);
                                    }
                                }
                                judgeCopy.m_eStatus              = GameSceneStatuses.STATUS_AWARD;
                                judgeCopy.CurrStateBeginMs       = nowMs;
                                judgeCopy.StateTimeData.State    = 3;
                                judgeCopy.StateTimeData.EndTicks = nowMs + 30000L;
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                            {
                                if (nowMs >= judgeCopy.CurrStateBeginMs + 30000L)
                                {
                                    lock (this.copyDict)
                                    {
                                        this.copyDict.Remove(judgeCopy.MyCopyMap.FuBenSeqID);
                                    }
                                    try
                                    {
                                        List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                                        if (clientList != null)
                                        {
                                            foreach (GameClient client in clientList)
                                            {
                                                KuaFuManager.getInstance().GotoLastMap(client);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DataHelper.WriteExceptionLogEx(ex, "末日审判清场调度异常");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
 private bool ProcessMoRiJudgeJoin(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);
         if (sceneType != SceneUIClasses.Normal)
         {
             client.sendCmd(nID, -21, false);
             return(true);
         }
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd(nID, -2001, false);
             return(true);
         }
         if (client.ClientData.SignUpGameType != 0)
         {
             client.sendCmd(nID, -2002, false);
             return(true);
         }
         if (KuaFuManager.getInstance().IsInCannotJoinKuaFuCopyTime(client))
         {
             client.sendCmd(nID, -2004, false);
             return(true);
         }
         SystemXmlItem systemFuBenItem = null;
         if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(70000, out systemFuBenItem))
         {
             client.sendCmd(nID, -3, false);
             return(true);
         }
         int minLevel       = systemFuBenItem.GetIntValue("MinLevel", -1);
         int maxLevel       = systemFuBenItem.GetIntValue("MaxLevel", -1);
         int nMinZhuanSheng = systemFuBenItem.GetIntValue("MinZhuanSheng", -1);
         int nMaxZhuanSheng = systemFuBenItem.GetIntValue("MaxZhuanSheng", -1);
         if (client.ClientData.ChangeLifeCount < nMinZhuanSheng || (client.ClientData.ChangeLifeCount == nMinZhuanSheng && client.ClientData.Level < minLevel))
         {
             client.sendCmd(nID, "-19".ToString(), false);
             return(true);
         }
         if (client.ClientData.ChangeLifeCount > nMaxZhuanSheng || (client.ClientData.ChangeLifeCount == nMaxZhuanSheng && client.ClientData.Level > maxLevel))
         {
             client.sendCmd(nID, "-19".ToString(), false);
             return(true);
         }
         FuBenData fuBenData = Global.GetFuBenData(client, 70000);
         if (fuBenData != null && fuBenData.FinishNum >= systemFuBenItem.GetIntValue("FinishNumber", -1))
         {
             client.sendCmd(nID, "-16".ToString(), false);
             return(true);
         }
         int result = 0;
         if (result == 1)
         {
             client.ClientData.SignUpGameType = 3;
             GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 1, 0, 0, 0, 3);
         }
         client.sendCmd(nID, result.ToString(), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
예제 #6
0
        // 定时处理副本逻辑
        public void TimerProc()
        {
            long nowMs = TimeUtil.NOW();

            if (nowMs < NextHeartBeatMs)
            {
                return;
            }

            NextHeartBeatMs = nowMs + 1020; //1020毫秒执行一次

            List <MoRiJudgeCopy> copyList = null;

            lock (copyDict)
            {
                copyList = copyDict.Values.ToList();
            }
            if (copyList == null || copyList.Count <= 0)
            {
                return;
            }

            foreach (var judgeCopy in copyList)
            {
                lock (judgeCopy)
                {
                    if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_NULL)
                    {
                        judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_PREPARE;
                        judgeCopy.CurrStateBeginMs = nowMs;
                        judgeCopy.DeadlineMs       = nowMs + this.CopyMaxAliveMinutes * 60 * 1000;

                        // 末日审判副本进入之后就是等待结束
                        judgeCopy.StateTimeData.State    = (int)GameSceneStatuses.STATUS_BEGIN;
                        judgeCopy.StateTimeData.EndTicks = judgeCopy.DeadlineMs;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_PREPARE)
                    {
                        if (nowMs >= judgeCopy.CurrStateBeginMs + 1500)
                        {
                            judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_BEGIN;
                            judgeCopy.CurrStateBeginMs = nowMs;
                        }
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                    {
                        // 如果超时了
                        if (nowMs >= judgeCopy.DeadlineMs ||
                            (nowMs >= judgeCopy.CurrStateBeginMs + 90 * 1000 && judgeCopy.RoleCount <= 0)
                            )
                        {
                            judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                            judgeCopy.CurrStateBeginMs = nowMs;
                            return;
                        }

                        int nextMonsterIdx = -1;
                        if (judgeCopy.CurrMonsterIdx == -1)
                        {
                            nextMonsterIdx = 0;
                        }
                        else// if (judgeCopy.CurrMonsterIndex < )
                        {
                            if (judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs > 0 &&
                                nowMs >= judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs + MoRiJudgeConsts.MonsterFlushIntervalMs)
                            {
                                nextMonsterIdx = judgeCopy.CurrMonsterIdx + 1;
                            }
                        }

                        if (nextMonsterIdx != -1)
                        {
                            if (nextMonsterIdx >= BossConfigList.Count)
                            {
                                judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                                judgeCopy.CurrStateBeginMs = nowMs;
                            }
                            else
                            {
                                FlushMonster(judgeCopy, nextMonsterIdx);
                            }
                        }
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_END)
                    {
                        // 把所有怪杀死,主要是副本到时间的情况
                        GameManager.CopyMapMgr.KillAllMonster(judgeCopy.MyCopyMap);

                        //  MoRiJudgeClient.getInstance().GameFuBenChangeState(judgeCopy.GameId, GameFuBenState.End, DateTime.Now);
                        // 记录副本通关信息
                        judgeCopy.EndTime = TimeUtil.NowDateTime();
                        int combatAvg = 0;
                        int roleCount = 0;

                        List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                        if (clientList != null && clientList.Count > 0)
                        {
                            int combatSum = 0;

                            foreach (var client in clientList)
                            {
                                ++roleCount;
                                combatSum += client.ClientData.CombatForce;

                                if (judgeCopy.Passed)
                                {
                                    // 成功统计
                                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)GameTypes.MoRiJudge);
                                }
                                else
                                {
                                    // 失败统计
                                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, (int)GameTypes.MoRiJudge);
                                }
                            }
                            if (roleCount > 0)
                            {
                                combatAvg = combatSum / roleCount;
                            }

                            if (judgeCopy.Passed)
                            {
                                GameManager.CopyMapMgr.CopyMapPassAwardForAll(clientList[0], judgeCopy.MyCopyMap, false);
                            }
                        }

                        //  MoRiJudgeClient.getInstance().UpdateCopyPassEvent(judgeCopy.GameId, judgeCopy.Passed, judgeCopy.StartTime, judgeCopy.EndTime, judgeCopy.LimitKillCount, roleCount, combatAvg);

                        judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_AWARD;
                        judgeCopy.CurrStateBeginMs = nowMs;

                        judgeCopy.StateTimeData.State    = (int)GameSceneStatuses.STATUS_END;
                        judgeCopy.StateTimeData.EndTicks = nowMs + 30 * 1000;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                    {
                        // 暂时设置为30S的清理时间
                        // 副本到时间的话,客户端会主动关闭
                        if (nowMs >= judgeCopy.CurrStateBeginMs + 30 * 1000)
                        {
                            lock (copyDict)
                            {
                                copyDict.Remove(judgeCopy.MyCopyMap.FuBenSeqID);
                            }

                            try
                            {
                                List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                                if (clientList != null)
                                {
                                    foreach (var client in clientList)
                                    {
                                        KuaFuManager.getInstance().GotoLastMap(client);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                DataHelper.WriteExceptionLogEx(ex, "末日审判清场调度异常");
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        // 报名末日审判
        private bool ProcessMoRiJudgeJoin(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);
                if (sceneType != SceneUIClasses.Normal)
                {
                    client.sendCmd(nID, StdErrorCode.Error_Denied_In_Current_Map.ToString());
                    return(true);
                }

                if (!IsGongNengOpened(client, true))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Not_In_valid_Time.ToString());
                    return(true);
                }

                if (client.ClientData.SignUpGameType != (int)GameTypes.None)
                {
                    client.sendCmd(nID, StdErrorCode.Error_Denied_In_Activity_Time.ToString());
                    return(true);
                }

                if (KuaFuManager.getInstance().IsInCannotJoinKuaFuCopyTime(client))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Time_Punish.ToString());
                    return(true);
                }

                SystemXmlItem systemFuBenItem = null;
                if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(MoRiJudgeConsts.CopyId, out systemFuBenItem))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Config_Fault.ToString());
                    return(true);
                }

                int minLevel       = systemFuBenItem.GetIntValue("MinLevel");
                int maxLevel       = systemFuBenItem.GetIntValue("MaxLevel");
                int nMinZhuanSheng = systemFuBenItem.GetIntValue("MinZhuanSheng");
                int nMaxZhuanSheng = systemFuBenItem.GetIntValue("MaxZhuanSheng");

                // 先判断等级
                if (client.ClientData.ChangeLifeCount < nMinZhuanSheng ||
                    (client.ClientData.ChangeLifeCount == nMinZhuanSheng && client.ClientData.Level < minLevel))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Level_Limit.ToString());
                    return(true);
                }

                if (client.ClientData.ChangeLifeCount > nMaxZhuanSheng ||
                    (client.ClientData.ChangeLifeCount == nMaxZhuanSheng && client.ClientData.Level > maxLevel))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Level_Limit.ToString());
                    return(true);
                }

                // 判断剩余次数
                FuBenData fuBenData = Global.GetFuBenData(client, MoRiJudgeConsts.CopyId);
                if (fuBenData != null && fuBenData.FinishNum >= systemFuBenItem.GetIntValue("FinishNumber"))
                {
                    client.sendCmd(nID, StdErrorCode.Error_No_Residue_Degree.ToString());
                    return(true);
                }

                int result = 0;// MoRiJudgeClient.getInstance().MoRiJudgeSignUp(client.strUserID, client.ClientData.RoleID, client.ClientData.ZoneID, client.ClientData.CombatForce);
                if (result == (int)KuaFuRoleStates.SignUp)
                {
                    // 报名成功
                    client.ClientData.SignUpGameType = (int)GameTypes.MoRiJudge;

                    // 报名统计
                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 1, 0, 0, 0, (int)GameTypes.MoRiJudge);
                }

                //发送结果给客户端
                client.sendCmd(nID, result.ToString());
                return(true);
            }

            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }