Ejemplo n.º 1
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks < NextHeartBeatTicks)
            {
                return;
            }

            NextHeartBeatTicks = nowTicks + 1020; //1020毫秒执行一次

            foreach (var huanYingSiYuanScene in HuanYingSiYuanSceneDict.Values)
            {
                lock (Mutex)
                {
                    int nID = -1;
                    nID = huanYingSiYuanScene.FuBenSeqId;

                    int nCopyID = -1;
                    nCopyID = huanYingSiYuanScene.CopyMapId;

                    int nMapCodeID = -1;
                    nMapCodeID = huanYingSiYuanScene.m_nMapCode;

                    if (nID < 0 || nCopyID < 0 || nMapCodeID < 0)
                    {
                        continue;
                    }

                    CopyMap copyMap = huanYingSiYuanScene.CopyMap;

                    // 当前tick
                    DateTime now   = TimeUtil.NowDateTime();
                    long     ticks = TimeUtil.NOW();

                    if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        huanYingSiYuanScene.m_lPrepareTime = ticks;
                        huanYingSiYuanScene.m_lBeginTime   = ticks + RuntimeData.PrepareSecs * TimeUtil.SECOND;
                        huanYingSiYuanScene.m_eStatus      = GameSceneStatuses.STATUS_PREPARE;

                        huanYingSiYuanScene.StateTimeData.GameType = (int)GameTypes.HuanYingSiYuan;
                        huanYingSiYuanScene.StateTimeData.State    = (int)huanYingSiYuanScene.m_eStatus;
                        huanYingSiYuanScene.StateTimeData.EndTicks = huanYingSiYuanScene.m_lBeginTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, huanYingSiYuanScene.StateTimeData, huanYingSiYuanScene.CopyMap);
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (ticks >= (huanYingSiYuanScene.m_lBeginTime))
                        {
                            huanYingSiYuanScene.m_eStatus  = GameSceneStatuses.STATUS_BEGIN;
                            huanYingSiYuanScene.m_lEndTime = ticks + RuntimeData.FightingSecs * TimeUtil.SECOND;

                            huanYingSiYuanScene.StateTimeData.GameType = (int)GameTypes.HuanYingSiYuan;
                            huanYingSiYuanScene.StateTimeData.State    = (int)huanYingSiYuanScene.m_eStatus;
                            huanYingSiYuanScene.StateTimeData.EndTicks = huanYingSiYuanScene.m_lEndTime;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, huanYingSiYuanScene.StateTimeData, huanYingSiYuanScene.CopyMap);

                            //刷圣杯
                            foreach (var shengBeiData in RuntimeData.ShengBeiDataDict.Values)
                            {
                                HuanYingSiYuanShengBeiContextData contextData = new HuanYingSiYuanShengBeiContextData()
                                {
                                    UniqueId      = GetInternalId(),
                                    FuBenSeqId    = huanYingSiYuanScene.FuBenSeqId,
                                    ShengBeiId    = shengBeiData.ID,
                                    BufferGoodsId = shengBeiData.GoodsID,
                                    MonsterId     = shengBeiData.MonsterID,
                                    PosX          = shengBeiData.PosX,
                                    PosY          = shengBeiData.PosY,
                                    CopyMapID     = huanYingSiYuanScene.CopyMapId,
                                    Score         = shengBeiData.Score,
                                    Time          = shengBeiData.Time,
                                    BufferProps   = shengBeiData.BufferProps,
                                };

                                CreateMonster(huanYingSiYuanScene, contextData);
                            }

                            //放开光幕
                            copyMap.AddGuangMuEvent(1, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 1, 0);
                        }
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (ticks >= huanYingSiYuanScene.m_lEndTime)
                        {
                            int successSide = 0;
                            if (huanYingSiYuanScene.ScoreInfoData.Score1 > huanYingSiYuanScene.ScoreInfoData.Score2)
                            {
                                successSide = 1;
                            }
                            else if (huanYingSiYuanScene.ScoreInfoData.Score2 > huanYingSiYuanScene.ScoreInfoData.Score1)
                            {
                                successSide = 2;
                            }

                            CompleteHuanYingSiYuanScene(huanYingSiYuanScene, successSide);
                        }
                        else
                        {
                            CheckShengBeiBufferTime(huanYingSiYuanScene, nowTicks);
                        }
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_END)
                    {
                        //结算奖励
                        huanYingSiYuanScene.m_eStatus    = GameSceneStatuses.STATUS_AWARD;
                        huanYingSiYuanScene.m_lEndTime   = nowTicks;
                        huanYingSiYuanScene.m_lLeaveTime = huanYingSiYuanScene.m_lEndTime + RuntimeData.ClearRolesSecs * TimeUtil.SECOND;

                        HuanYingSiYuanClient.getInstance().GameFuBenChangeState(huanYingSiYuanScene.GameId, GameFuBenState.End, now);

                        huanYingSiYuanScene.StateTimeData.GameType = (int)GameTypes.HuanYingSiYuan;
                        huanYingSiYuanScene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_END;
                        huanYingSiYuanScene.StateTimeData.EndTicks = huanYingSiYuanScene.m_lLeaveTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, huanYingSiYuanScene.StateTimeData, huanYingSiYuanScene.CopyMap);

                        GiveAwards(huanYingSiYuanScene);
                    }
                    else if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_AWARD)         // 战斗结束
                    {
                        if (ticks >= huanYingSiYuanScene.m_lLeaveTime)
                        {
                            copyMap.SetRemoveTicks(huanYingSiYuanScene.m_lLeaveTime);
                            huanYingSiYuanScene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;

                            try
                            {
                                List <GameClient> objsList = copyMap.GetClientsList();
                                if (objsList != null && objsList.Count > 0)
                                {
                                    for (int n = 0; n < objsList.Count; ++n)
                                    {
                                        GameClient c = objsList[n];
                                        if (c != null)
                                        {
                                            KuaFuManager.getInstance().GotoLastMap(c);
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                DataHelper.WriteExceptionLogEx(ex, "幻影寺院清场调度异常");
                            }
                        }
                    }
                }
            }

            return;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks < NextHeartBeatTicks)
            {
                return;
            }

            NextHeartBeatTicks = nowTicks + 1020; //1020毫秒执行一次

            foreach (var scene in SceneDict.Values)
            {
                lock (RuntimeData.Mutex)
                {
                    int nID = -1;
                    nID = scene.FuBenSeqId;

                    int nCopyID = -1;
                    nCopyID = scene.CopyMapId;

                    int nMapCodeID = -1;
                    nMapCodeID = scene.m_nMapCode;

                    if (nID < 0 || nCopyID < 0 || nMapCodeID < 0)
                    {
                        continue;
                    }

                    CopyMap copyMap = scene.CopyMap;

                    // 当前tick
                    DateTime now   = TimeUtil.NowDateTime();
                    long     ticks = TimeUtil.NOW();

                    if (scene.m_eStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        if (ticks >= scene.StartTimeTicks)
                        {
                            scene.m_lPrepareTime = scene.StartTimeTicks;
                            scene.m_lBeginTime   = scene.m_lPrepareTime + scene.SceneInfo.PrepareSecs * TimeUtil.SECOND;
                            scene.m_eStatus      = GameSceneStatuses.STATUS_PREPARE;

                            scene.StateTimeData.GameType = (int)GameTypes.YongZheZhanChang;
                            scene.StateTimeData.State    = (int)scene.m_eStatus;
                            scene.StateTimeData.EndTicks = scene.m_lBeginTime;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap);
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (ticks >= scene.m_lBeginTime)
                        {
                            scene.m_eStatus  = GameSceneStatuses.STATUS_BEGIN;
                            scene.m_lEndTime = scene.m_lBeginTime + scene.SceneInfo.FightingSecs * TimeUtil.SECOND;

                            scene.StateTimeData.GameType = (int)GameTypes.YongZheZhanChang;
                            scene.StateTimeData.State    = (int)scene.m_eStatus;
                            scene.StateTimeData.EndTicks = scene.m_lEndTime;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap);

                            InitCreateDynamicMonster(scene);

                            copyMap.AddGuangMuEvent(1, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 1, 0);
                            copyMap.AddGuangMuEvent(2, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 2, 0);
                            copyMap.AddGuangMuEvent(3, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 3, 0);
                            copyMap.AddGuangMuEvent(4, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 4, 0);
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (ticks >= scene.m_lEndTime)
                        {
                            int successSide = 0;
                            if (scene.ScoreData.Score1 > scene.ScoreData.Score2)
                            {
                                successSide = 1;
                            }
                            else if (scene.ScoreData.Score2 > scene.ScoreData.Score1)
                            {
                                successSide = 2;
                            }

                            CompleteScene(scene, successSide);
                            scene.m_eStatus    = GameSceneStatuses.STATUS_END;
                            scene.m_lLeaveTime = scene.m_lEndTime + scene.SceneInfo.ClearRolesSecs * TimeUtil.SECOND;

                            scene.StateTimeData.GameType = (int)GameTypes.YongZheZhanChang;
                            scene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_CLEAR;
                            scene.StateTimeData.EndTicks = scene.m_lLeaveTime;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap);
                        }
                        else
                        {
                            CheckCreateDynamicMonster(scene, ticks);
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_END)         // 战斗结束
                    {
                        GameManager.CopyMapMgr.KillAllMonster(scene.CopyMap);

                        //结算奖励
                        scene.m_eStatus = GameSceneStatuses.STATUS_AWARD;
                        YongZheZhanChangClient.getInstance().GameFuBenChangeState(scene.GameId, GameFuBenState.End, now);
                        GiveAwards(scene);

                        YongZheZhanChangFuBenData fuBenData;
                        if (RuntimeData.FuBenItemData.TryGetValue(scene.GameId, out fuBenData))
                        {
                            fuBenData.State = GameFuBenState.End;
                            LogManager.WriteLog(LogTypes.Error, string.Format("勇者战场跨服副本GameID={0},战斗结束", fuBenData.GameId));
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                    {
                        if (ticks >= scene.m_lLeaveTime)
                        {
                            copyMap.SetRemoveTicks(scene.m_lLeaveTime);
                            scene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;

                            try
                            {
                                List <GameClient> objsList = copyMap.GetClientsList();
                                if (objsList != null && objsList.Count > 0)
                                {
                                    for (int n = 0; n < objsList.Count; ++n)
                                    {
                                        GameClient c = objsList[n];
                                        if (c != null)
                                        {
                                            KuaFuManager.getInstance().GotoLastMap(c);
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                DataHelper.WriteExceptionLogEx(ex, "勇者战场系统清场调度异常");
                            }
                        }
                    }
                }
            }

            return;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks < NextHeartBeatTicks)
            {
                return;
            }

            NextHeartBeatTicks = nowTicks + 1020; //1020毫秒执行一次

            foreach (var tianTiScene in TianTiSceneDict.Values)
            {
                lock (RuntimeData.Mutex)
                {
                    int nID = -1;
                    nID = tianTiScene.FuBenSeqId;

                    int nCopyID = -1;
                    nCopyID = tianTiScene.CopyMapId;

                    int nMapCodeID = -1;
                    nMapCodeID = tianTiScene.m_nMapCode;

                    if (nID < 0 || nCopyID < 0 || nMapCodeID < 0)
                    {
                        continue;
                    }

                    CopyMap copyMap = tianTiScene.CopyMap;

                    // 当前tick
                    DateTime now   = TimeUtil.NowDateTime();
                    long     ticks = TimeUtil.NOW();

                    if (tianTiScene.m_eStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        tianTiScene.m_lPrepareTime = ticks;
                        tianTiScene.m_lBeginTime   = ticks + RuntimeData.WaitingEnterSecs * TimeUtil.SECOND;
                        tianTiScene.m_eStatus      = GameSceneStatuses.STATUS_PREPARE;

                        tianTiScene.StateTimeData.GameType = (int)GameTypes.TianTi;
                        tianTiScene.StateTimeData.State    = (int)tianTiScene.m_eStatus;
                        tianTiScene.StateTimeData.EndTicks = tianTiScene.m_lBeginTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, tianTiScene.StateTimeData, tianTiScene.CopyMap);
                    }
                    else if (tianTiScene.m_eStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        //检查双方是否都进入了
                        if (copyMap.GetGameClientCount() >= 2)
                        {
                            tianTiScene.m_eStatus  = GameSceneStatuses.STATUS_BEGIN;
                            tianTiScene.m_lEndTime = ticks + RuntimeData.FightingSecs * TimeUtil.SECOND;

                            tianTiScene.StateTimeData.GameType = (int)GameTypes.TianTi;
                            tianTiScene.StateTimeData.State    = (int)tianTiScene.m_eStatus;
                            tianTiScene.StateTimeData.EndTicks = tianTiScene.m_lEndTime;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, tianTiScene.StateTimeData, tianTiScene.CopyMap);

                            //放开光幕
                            copyMap.AddGuangMuEvent(1, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 1, 0);
                            copyMap.AddGuangMuEvent(2, 0);
                            GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 2, 0);
                        }
                        else if (ticks >= (tianTiScene.m_lBeginTime))
                        {
                            CompleteTianTiScene(tianTiScene, -1);
                        }
                    }
                    else if (tianTiScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (ticks >= tianTiScene.m_lEndTime)
                        {
                            CompleteTianTiScene(tianTiScene, 0);
                        }
                    }
                    else if (tianTiScene.m_eStatus == GameSceneStatuses.STATUS_END)         // 战斗结束
                    {
                        ProcessEnd(tianTiScene, now, nowTicks);
                    }
                    else if (tianTiScene.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                    {
                        if (ticks >= tianTiScene.m_lLeaveTime)
                        {
                            copyMap.SetRemoveTicks(tianTiScene.m_lLeaveTime);
                            tianTiScene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;

                            try
                            {
                                List <GameClient> objsList = copyMap.GetClientsList();
                                if (objsList != null && objsList.Count > 0)
                                {
                                    for (int n = 0; n < objsList.Count; ++n)
                                    {
                                        GameClient c = objsList[n];
                                        if (c != null)
                                        {
                                            KuaFuManager.getInstance().GotoLastMap(c);
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                DataHelper.WriteExceptionLogEx(ex, "跨服天梯系统清场调度异常");
                            }
                        }
                    }
                }
            }

            return;
        }