Exemplo n.º 1
0
 private void UpdateKuaFuMapClientCount(KarenBattleScene scene)
 {
     if (null != scene)
     {
         CopyMap copyMap = scene.CopyMap;
         if (null != copyMap)
         {
             KarenBattleSceneInfo sceneItem          = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>();
             List <int>           mapClientCountList = new List <int>(new int[sceneItem.MaxLegions]);
             List <GameClient>    objsList           = copyMap.GetClientsList();
             if (objsList != null && objsList.Count > 0)
             {
                 for (int i = 0; i < objsList.Count; i++)
                 {
                     GameClient c = objsList[i];
                     if (c != null)
                     {
                         int side = c.ClientData.BattleWhichSide;
                         if (side > 0 && side < mapClientCountList.Count)
                         {
                             List <int> list;
                             int        index;
                             (list = mapClientCountList)[index = side - 1] = list[index] + 1;
                         }
                     }
                 }
             }
             JunTuanClient.getInstance().UpdateKuaFuMapClientCount(scene.GameId, mapClientCountList);
         }
     }
 }
Exemplo n.º 2
0
 public void ClearCopyMapClients(CopyMap copyMap)
 {
     try
     {
         List <GameClient> objsList = copyMap.GetClientsList();
         if (objsList != null && objsList.Count > 0)
         {
             for (int i = 0; i < objsList.Count; i++)
             {
                 GameClient c = objsList[i];
                 if (c != null)
                 {
                     KuaFuManager.getInstance().GotoLastMap(c);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteExceptionLogEx(ex, "跨服组队竞技清场调度异常");
     }
 }
Exemplo n.º 3
0
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks >= KuaFuBossManager.NextHeartBeatTicks)
            {
                KuaFuBossManager.NextHeartBeatTicks = nowTicks + 1020L;
                foreach (KuaFuBossScene scene in this.SceneDict.Values)
                {
                    lock (this.RuntimeData.Mutex)
                    {
                        int nID        = scene.FuBenSeqId;
                        int nCopyID    = scene.CopyMapId;
                        int nMapCodeID = scene.m_nMapCode;
                        if (nID >= 0 && nCopyID >= 0 && nMapCodeID >= 0)
                        {
                            CopyMap  copyMap = scene.CopyMap;
                            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 + (long)(scene.SceneInfo.PrepareSecs * 1000);
                                    scene.m_eStatus              = GameSceneStatuses.STATUS_PREPARE;
                                    scene.StateTimeData.GameType = 6;
                                    scene.StateTimeData.State    = (int)scene.m_eStatus;
                                    scene.StateTimeData.EndTicks = scene.m_lBeginTime;
                                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, 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 + (long)(scene.SceneInfo.FightingSecs * 1000);
                                    scene.StateTimeData.GameType = 6;
                                    scene.StateTimeData.State    = (int)scene.m_eStatus;
                                    scene.StateTimeData.EndTicks = scene.m_lEndTime;
                                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMap);
                                }
                            }
                            else if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                                if (ticks >= scene.m_lEndTime)
                                {
                                    scene.m_eStatus              = GameSceneStatuses.STATUS_END;
                                    scene.m_lLeaveTime           = scene.m_lEndTime + (long)(scene.SceneInfo.ClearRolesSecs * 1000);
                                    scene.StateTimeData.GameType = 6;
                                    scene.StateTimeData.State    = 5;
                                    scene.StateTimeData.EndTicks = scene.m_lLeaveTime;
                                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMap);
                                    this.NotifySceneData(scene);
                                }
                                else
                                {
                                    scene.ElapsedSeconds = (int)Math.Min((nowTicks - scene.m_lBeginTime) / 1000L, (long)scene.SceneInfo.TotalSecs);
                                    this.CheckCreateDynamicMonster(scene, ticks);
                                    if (nowTicks > scene.NextNotifySceneStateDataTicks)
                                    {
                                        scene.NextNotifySceneStateDataTicks = nowTicks + 3000L;
                                        this.NotifySceneData(scene);
                                    }
                                }
                            }
                            else if (scene.m_eStatus == GameSceneStatuses.STATUS_END)
                            {
                                GameManager.CopyMapMgr.KillAllMonster(scene.CopyMap);
                                scene.m_eStatus = GameSceneStatuses.STATUS_AWARD;
                                YongZheZhanChangClient.getInstance().PushGameResultData(scene.GameStatisticalData);
                                YongZheZhanChangClient.getInstance().GameFuBenChangeState(scene.GameId, GameFuBenState.End, now);
                                YongZheZhanChangFuBenData fuBenData;
                                if (this.RuntimeData.FuBenItemData.TryGetValue(scene.GameId, out fuBenData))
                                {
                                    fuBenData.State = GameFuBenState.End;
                                    LogManager.WriteLog(LogTypes.Error, string.Format("跨服Boss跨服副本GameID={0},战斗结束", fuBenData.GameId), null, true);
                                }
                            }
                            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 i = 0; i < objsList.Count; i++)
                                            {
                                                GameClient c = objsList[i];
                                                if (c != null)
                                                {
                                                    KuaFuManager.getInstance().GotoLastMap(c);
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DataHelper.WriteExceptionLogEx(ex, "跨服Boss系统清场调度异常");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks < _nextHeartBeatTicks)
            {
                return;
            }

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

            long nowSecond = nowTicks / 1000;

            foreach (ElementWarScene scene in _sceneDict.Values)
            {
                lock (_mutex)
                {
                    int nID     = scene.FuBenSeqId;
                    int nCopyID = scene.CopyID;
                    int nMapID  = scene.MapID;

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

                    CopyMap copyMap = scene.CopyMapInfo;

                    if (scene.SceneStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        scene.PrepareTime = nowSecond;
                        scene.BeginTime   = nowSecond + _runtimeData.PrepareSecs;
                        scene.SceneStatus = GameSceneStatuses.STATUS_PREPARE;

                        scene.StateTimeData.GameType = (int)_gameType;
                        scene.StateTimeData.State    = (int)scene.SceneStatus;
                        scene.StateTimeData.EndTicks = nowTicks + _runtimeData.PrepareSecs * 1000;//scene.BeginTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMapInfo);
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (nowSecond >= (scene.BeginTime))
                        {
                            scene.SceneStatus = GameSceneStatuses.STATUS_BEGIN;
                            scene.EndTime     = nowSecond + _runtimeData.FightingSecs;

                            scene.StateTimeData.GameType = (int)_gameType;
                            scene.StateTimeData.State    = (int)scene.SceneStatus;
                            scene.StateTimeData.EndTicks = nowTicks + _runtimeData.FightingSecs * 1000;//scene.EndTime;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMapInfo);

                            //放开光幕
                            //copyMap.AddGuangMuEvent(1, 0);
                            //GameManager.ClientMgr.BroadSpecialMapAIEvent(copyMap.MapCode, copyMap.CopyMapID, 1, 0);
                        }
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (nowSecond >= scene.EndTime)
                        {
                            scene.SceneStatus = GameSceneStatuses.STATUS_END;
                            continue;
                        }

                        //检查怪物
                        bool bNeedCreateMonster = false;
                        int  upWave             = 0;
                        lock (scene)
                        {
                            ElementWarMonsterConfigInfo configInfo = _runtimeData.GetOrderConfig(scene.MonsterWave);
                            if (configInfo == null)
                            {
                                scene.MonsterWaveOld = 1;
                                scene.MonsterWave    = 0;
                                scene.SceneStatus    = GameSceneStatuses.STATUS_END;
                                continue;
                            }
                            //检查超时
                            if (scene.CreateMonsterTime > 0 && nowSecond - scene.CreateMonsterTime >= configInfo.Up1)
                            {
                                scene.MonsterWave = 0;
                                scene.SceneStatus = GameSceneStatuses.STATUS_END;
                                continue;
                            }

                            if (scene.CreateMonsterTime > 0 && scene.IsMonsterFlag == 0 && scene.ScoreData.MonsterCount <= 0)
                            {
                                if (scene.MonsterWave < scene.MonsterWaveTotal)
                                {
                                    bNeedCreateMonster = true;
                                    if (nowSecond - scene.CreateMonsterTime <= configInfo.Up4)
                                    {
                                        upWave = 4;
                                    }
                                    else if (nowSecond - scene.CreateMonsterTime <= configInfo.Up3)
                                    {
                                        upWave = 3;
                                    }
                                    else if (nowSecond - scene.CreateMonsterTime <= configInfo.Up2)
                                    {
                                        upWave = 2;
                                    }
                                    else if (nowSecond - scene.CreateMonsterTime < configInfo.Up1)
                                    {
                                        upWave = 1;
                                    }
                                }
                                else
                                {
                                    scene.MonsterWaveOld = scene.MonsterWave;
                                    scene.MonsterWave    = 0;
                                    scene.SceneStatus    = GameSceneStatuses.STATUS_END;
                                    continue;
                                }
                            }

                            if (scene.CreateMonsterTime <= 0)
                            {
                                bNeedCreateMonster = true;
                            }

                            if (bNeedCreateMonster)
                            {
                                CreateMonster(scene, upWave);
                            }
                        }
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_END)
                    {
                        GiveAwards(scene);

                        //结算奖励
                        scene.SceneStatus = GameSceneStatuses.STATUS_AWARD;
                        scene.EndTime     = nowSecond;
                        scene.LeaveTime   = scene.EndTime + _runtimeData.ClearRolesSecs;

                        //  ElementWarClient.getInstance().GameFuBenChangeState(scene.GameId, GameFuBenState.End, DateTime.Now);

                        scene.StateTimeData.GameType = (int)_gameType;
                        scene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_END;
                        scene.StateTimeData.EndTicks = nowTicks + _runtimeData.ClearRolesSecs * 1000;//scene.LeaveTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMapInfo);
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_AWARD)         // 战斗结束
                    {
                        if (nowSecond >= scene.LeaveTime)
                        {
                            copyMap.SetRemoveTicks(scene.LeaveTime);
                            scene.SceneStatus = 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;
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
0
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks >= ElementWarManager._nextHeartBeatTicks)
            {
                ElementWarManager._nextHeartBeatTicks = nowTicks + 1020L;
                long nowSecond = nowTicks / 1000L;
                foreach (ElementWarScene scene in this._sceneDict.Values)
                {
                    lock (ElementWarManager._mutex)
                    {
                        int nID     = scene.FuBenSeqId;
                        int nCopyID = scene.CopyID;
                        int nMapID  = scene.MapID;
                        if (nID >= 0 && nCopyID >= 0 && nMapID >= 0)
                        {
                            CopyMap copyMap = scene.CopyMapInfo;
                            if (scene.SceneStatus == GameSceneStatuses.STATUS_NULL)
                            {
                                scene.PrepareTime            = nowSecond;
                                scene.BeginTime              = nowSecond + (long)this._runtimeData.PrepareSecs;
                                scene.SceneStatus            = GameSceneStatuses.STATUS_PREPARE;
                                scene.StateTimeData.GameType = 4;
                                scene.StateTimeData.State    = (int)scene.SceneStatus;
                                scene.StateTimeData.EndTicks = nowTicks + (long)(this._runtimeData.PrepareSecs * 1000);
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMapInfo);
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_PREPARE)
                            {
                                if (nowSecond >= scene.BeginTime)
                                {
                                    scene.SceneStatus            = GameSceneStatuses.STATUS_BEGIN;
                                    scene.EndTime                = nowSecond + (long)this._runtimeData.FightingSecs;
                                    scene.StateTimeData.GameType = 4;
                                    scene.StateTimeData.State    = (int)scene.SceneStatus;
                                    scene.StateTimeData.EndTicks = nowTicks + (long)(this._runtimeData.FightingSecs * 1000);
                                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMapInfo);
                                }
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                                if (nowSecond >= scene.EndTime)
                                {
                                    scene.SceneStatus = GameSceneStatuses.STATUS_END;
                                }
                                else
                                {
                                    bool bNeedCreateMonster = false;
                                    int  upWave             = 0;
                                    lock (scene)
                                    {
                                        ElementWarMonsterConfigInfo configInfo = this._runtimeData.GetOrderConfig(scene.MonsterWave);
                                        if (configInfo == null)
                                        {
                                            scene.MonsterWaveOld = 1;
                                            scene.MonsterWave    = 0;
                                            scene.SceneStatus    = GameSceneStatuses.STATUS_END;
                                        }
                                        else if (scene.CreateMonsterTime > 0L && nowSecond - scene.CreateMonsterTime >= (long)configInfo.Up1)
                                        {
                                            scene.MonsterWave = 0;
                                            scene.SceneStatus = GameSceneStatuses.STATUS_END;
                                        }
                                        else
                                        {
                                            if (scene.CreateMonsterTime > 0L && scene.IsMonsterFlag == 0 && scene.ScoreData.MonsterCount <= 0L)
                                            {
                                                if (scene.MonsterWave >= scene.MonsterWaveTotal)
                                                {
                                                    scene.MonsterWaveOld = scene.MonsterWave;
                                                    scene.MonsterWave    = 0;
                                                    scene.SceneStatus    = GameSceneStatuses.STATUS_END;
                                                    continue;
                                                }
                                                bNeedCreateMonster = true;
                                                if (nowSecond - scene.CreateMonsterTime <= (long)configInfo.Up4)
                                                {
                                                    upWave = 4;
                                                }
                                                else if (nowSecond - scene.CreateMonsterTime <= (long)configInfo.Up3)
                                                {
                                                    upWave = 3;
                                                }
                                                else if (nowSecond - scene.CreateMonsterTime <= (long)configInfo.Up2)
                                                {
                                                    upWave = 2;
                                                }
                                                else if (nowSecond - scene.CreateMonsterTime < (long)configInfo.Up1)
                                                {
                                                    upWave = 1;
                                                }
                                            }
                                            if (scene.CreateMonsterTime <= 0L)
                                            {
                                                bNeedCreateMonster = true;
                                            }
                                            if (bNeedCreateMonster)
                                            {
                                                this.CreateMonster(scene, upWave);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_END)
                            {
                                this.GiveAwards(scene);
                                scene.SceneStatus            = GameSceneStatuses.STATUS_AWARD;
                                scene.EndTime                = nowSecond;
                                scene.LeaveTime              = scene.EndTime + (long)this._runtimeData.ClearRolesSecs;
                                scene.StateTimeData.GameType = 4;
                                scene.StateTimeData.State    = 3;
                                scene.StateTimeData.EndTicks = nowTicks + (long)(this._runtimeData.ClearRolesSecs * 1000);
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMapInfo);
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_AWARD)
                            {
                                if (nowSecond >= scene.LeaveTime)
                                {
                                    copyMap.SetRemoveTicks(scene.LeaveTime);
                                    scene.SceneStatus = GameSceneStatuses.STATUS_CLEAR;
                                    try
                                    {
                                        List <GameClient> objsList = copyMap.GetClientsList();
                                        if (objsList != null && objsList.Count > 0)
                                        {
                                            for (int i = 0; i < objsList.Count; i++)
                                            {
                                                GameClient c = objsList[i];
                                                if (c != null)
                                                {
                                                    KuaFuManager.getInstance().GotoLastMap(c);
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DataHelper.WriteExceptionLogEx(ex, "【元素试炼】清场调度异常");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks < _nextHeartBeatTicks)
            {
                return;
            }

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

            long nowSecond = nowTicks / 1000;

            foreach (CopyWolfSceneInfo scene in _runtimeData.SceneDict.Values)
            {
                lock (_mutex)
                {
                    int nID     = scene.FuBenSeqId;
                    int nCopyID = scene.CopyID;
                    int nMapID  = scene.MapID;

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

                    CopyMap copyMap = scene.CopyMapInfo;
                    if (scene.SceneStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        scene.PrepareTime = nowSecond;
                        scene.BeginTime   = nowSecond + _runtimeData.PrepareSecs;
                        scene.SceneStatus = GameSceneStatuses.STATUS_PREPARE;

                        scene.StateTimeData.GameType = (int)_gameType;
                        scene.StateTimeData.State    = (int)scene.SceneStatus;
                        scene.StateTimeData.EndTicks = nowTicks + _runtimeData.PrepareSecs * 1000;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMapInfo);
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (nowSecond >= (scene.BeginTime))
                        {
                            scene.SceneStatus = GameSceneStatuses.STATUS_BEGIN;
                            scene.EndTime     = nowSecond + _runtimeData.FightingSecs;

                            scene.StateTimeData.GameType = (int)_gameType;
                            scene.StateTimeData.State    = (int)scene.SceneStatus;
                            scene.StateTimeData.EndTicks = nowTicks + _runtimeData.FightingSecs * 1000;
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMapInfo);
                        }
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (nowSecond >= scene.EndTime)
                        {
                            scene.SceneStatus = GameSceneStatuses.STATUS_END;
                            continue;
                        }

                        //要塞
                        if (scene.IsFortFlag <= 0)
                        {
                            CreateFort(scene);
                        }

                        //检查怪物
                        bool bNeedCreateMonster = false;
                        lock (scene)
                        {
                            CopyWolfWaveInfo configInfo = _runtimeData.GetWaveConfig(scene.MonsterWave);
                            if (configInfo == null)
                            {
                                scene.MonsterWaveOld = 0;
                                scene.MonsterWave    = 0;
                                scene.SceneStatus    = GameSceneStatuses.STATUS_END;
                                continue;
                            }

                            //if (scene.MonsterWave >= scene.MonsterWaveTotal)
                            //{
                            //    scene.MonsterWaveOld = scene.MonsterWave;
                            //    scene.MonsterWave = 0;
                            //    scene.SceneStatus = GameSceneStatuses.STATUS_END;
                            //    continue;
                            //}

                            //刷新下一波
                            if (scene.CreateMonsterTime > 0 && nowSecond - scene.CreateMonsterTime >= configInfo.NextTime && configInfo.NextTime > 0)
                            {
                                bNeedCreateMonster = true;
                            }

                            //怪物清除
                            if (scene.CreateMonsterTime > 0 && scene.IsMonsterFlag == 0 && scene.KilledMonsterHashSet.Count == scene.MonsterCountCreate)
                            {
                                bNeedCreateMonster = true;
                            }

                            if (scene.CreateMonsterTime <= 0)
                            {
                                bNeedCreateMonster = true;
                                scene.MonsterWave  = 0;
                            }

                            if (bNeedCreateMonster)
                            {
                                CreateMonster(scene);
                            }
                        }
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_END)
                    {
                        int leftSecond = 0;
                        if (scene.MonsterWave >= scene.MonsterWaveTotal)
                        {
                            leftSecond = (int)Math.Max(0, nowSecond - scene.EndTime);
                        }
                        GiveAwards(scene, leftSecond);

                        //结算奖励
                        scene.SceneStatus = GameSceneStatuses.STATUS_AWARD;
                        scene.EndTime     = nowSecond;
                        scene.LeaveTime   = scene.EndTime + _runtimeData.ClearRolesSecs;

                        scene.StateTimeData.GameType = (int)_gameType;
                        scene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_END;
                        scene.StateTimeData.EndTicks = nowTicks + _runtimeData.ClearRolesSecs * 1000;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMapInfo);
                    }
                    else if (scene.SceneStatus == GameSceneStatuses.STATUS_AWARD)         // 战斗结束
                    {
                        if (nowSecond >= scene.LeaveTime)
                        {
                            copyMap.SetRemoveTicks(scene.LeaveTime);
                            scene.SceneStatus = 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;
        }
Exemplo n.º 10
0
        /// <summary>
        /// 检查死亡的怪物是否为帮会副本boss并进行通关处理
        /// </summary>
        public void ProcessMonsterDead(GameClient client, Monster monster)
        {
            // 怪物所在场景不是帮会地图
            if (IsGuildCopyMap(monster.CurrentMapCode) == false)
            {
                return;
            }

            SystemXmlItem systemFuBenItem = null;

            if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(monster.CurrentMapCode, out systemFuBenItem))
            {
                return;
            }

            if (null == systemFuBenItem)
            {
                return;
            }

            int nBossID = systemFuBenItem.GetIntValue("BossID");

#if ___CC___FUCK___YOU___BB___
            // 不是boss
            if (nBossID != monster.XMonsterInfo.MonsterId)
            {
                return;
            }
#else
            // 不是boss
            if (nBossID != monster.MonsterInfo.ExtensionID)
            {
                return;
            }
#endif
            // 没有对应副本?
            CopyMap copyMap = GameManager.CopyMapMgr.FindCopyMap(monster.CurrentCopyMapID);
            if (null == copyMap)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == copyMap), CurrentCopyMapID={0}", monster.CurrentCopyMapID));
                return;
            }

            GuildCopyMap mapData = GameManager.GuildCopyMapMgr.FindGuildCopyMapBySeqID(copyMap.FuBenSeqID);
            if (null == mapData)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == mapData), copyMap.FuBenSeqID={0}", copyMap.FuBenSeqID));
                return;
            }
            int guildid = mapData.GuildID;

            // 玩家没有帮会?
            GuildCopyMapDB data = GameManager.GuildCopyMapDBMgr.FindGuildCopyMapDB(guildid /*client.ClientData.Faction*//*不再用击杀者的帮会id*/, client.ServerId);
            if (null == data)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == data), guildid={0}", client.ClientData.Faction));
                return;
            }

            List <GameClient> objsList = copyMap.GetClientsList();
            // 副本里没人?
            if (null == objsList || objsList.Count <= 0)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == objsList || objsList.Count <= 0), CurrentCopyMapID={0}", monster.CurrentCopyMapID));
                return;
            }

            // 更新副本记录的状态
            if (copyMap.FubenMapID >= data.FuBenID)
            {
                data.FuBenID = copyMap.FubenMapID;
                data.State   = (int)GuildCopyMapState.Passed;
                if (copyMap.FubenMapID == GameManager.GuildCopyMapMgr.FirstGuildCopyMapOrder)
                {
                    data.Killers = monster.WhoKillMeName;
                }
                else
                {
                    data.Killers += ",";
                    data.Killers += monster.WhoKillMeName;
                }
            }
#if ___CC___FUCK___YOU___BB___
            //触发战盟事件
            GlobalEventSource.getInstance().fireEvent(ZhanMengShijianEvent.createKillBossEvent(Global.FormatRoleName4(client), client.ClientData.Faction,
                                                                                               monster.XMonsterInfo.MonsterId, client.ServerId));
#else
            //触发战盟事件
            GlobalEventSource.getInstance().fireEvent(ZhanMengShijianEvent.createKillBossEvent(Global.FormatRoleName4(client), client.ClientData.Faction,
                                                                                               monster.MonsterInfo.ExtensionID, client.ServerId));
#endif
            // 检查是否更新成功
            bool result = GameManager.GuildCopyMapDBMgr.UpdateGuildCopyMapDB(data, client.ServerId);
            if (false == result)
            {
                string logStr = @"GuildCopyMapManager::ProcessMonsterDead (false == result), 
                        data.GuildID={0}, data.FuBenID={1}, data.State={2}, data.OpenDay={3}, data.Killers={4}";
                LogManager.WriteLog(LogTypes.Error, string.Format(logStr, data.GuildID, data.FuBenID, data.State, data.OpenDay, data.Killers));
                return;
            }
        }
Exemplo n.º 11
0
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks >= KarenBattleManager_MapWest.NextHeartBeatTicks)
            {
                KarenBattleManager_MapWest.NextHeartBeatTicks = nowTicks + 510L;
                foreach (KarenBattleScene scene in this.SceneDict.Values)
                {
                    lock (this.RuntimeData.Mutex)
                    {
                        int nID        = scene.FuBenSeqId;
                        int nCopyID    = scene.CopyMapId;
                        int nMapCodeID = scene.m_nMapCode;
                        if (nID >= 0 && nCopyID >= 0 && nMapCodeID >= 0)
                        {
                            CopyMap  copyMap = scene.CopyMap;
                            DateTime now     = TimeUtil.NowDateTime();
                            long     ticks   = TimeUtil.NOW();
                            if (scene.m_eStatus == GameSceneStatuses.STATUS_PREPARE || scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                            }
                            if (scene.m_eStatus == GameSceneStatuses.STATUS_NULL)
                            {
                                if (ticks >= scene.StartTimeTicks)
                                {
                                    scene.m_lPrepareTime         = scene.StartTimeTicks;
                                    scene.m_lBeginTime           = scene.m_lPrepareTime + (long)(scene.SceneInfo.PrepareSecs * 1000);
                                    scene.m_eStatus              = GameSceneStatuses.STATUS_PREPARE;
                                    scene.StateTimeData.GameType = 19;
                                    scene.StateTimeData.State    = (int)scene.m_eStatus;
                                    scene.StateTimeData.EndTicks = scene.m_lBeginTime;
                                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, 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 + (long)(scene.SceneInfo.FightingSecs * 1000);
                                    scene.StateTimeData.GameType = 19;
                                    scene.StateTimeData.State    = (int)scene.m_eStatus;
                                    scene.StateTimeData.EndTicks = scene.m_lEndTime;
                                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMap);
                                    for (int guangMuId = 1; guangMuId <= 4; guangMuId++)
                                    {
                                        GameManager.CopyMapMgr.AddGuangMuEvent(copyMap, guangMuId, 0);
                                    }
                                }
                            }
                            else if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                                if (ticks >= scene.m_lEndTime)
                                {
                                    long successTicks = long.MaxValue;
                                    int  successScore = 0;
                                    int  successSide  = 0;
                                    for (int sideloop = 0; sideloop < scene.ScoreData.Count; sideloop++)
                                    {
                                        KarenBattleScoreData scoreData = scene.ScoreData[sideloop];
                                        if (scoreData.Score > successScore)
                                        {
                                            successSide  = sideloop + 1;
                                            successTicks = scoreData.ticks;
                                            successScore = scoreData.Score;
                                        }
                                        else if (scoreData.Score == successScore && scoreData.ticks < successTicks)
                                        {
                                            successSide  = sideloop + 1;
                                            successTicks = scoreData.ticks;
                                        }
                                    }
                                    this.ProcessEnd(scene, successSide, ticks);
                                }
                                else
                                {
                                    this.CheckSceneScoreTime(scene, ticks);
                                }
                            }
                            else if (scene.m_eStatus == GameSceneStatuses.STATUS_END)
                            {
                                GameManager.CopyMapMgr.KillAllMonster(scene.CopyMap);
                                scene.m_eStatus = GameSceneStatuses.STATUS_AWARD;
                                JunTuanClient.getInstance().GameFuBenRoleChangeState(-1, -1, scene.GameId, -1, 6);
                                KarenBattleManager.getInstance().GiveAwards(scene);
                                KarenFuBenData fuBenData;
                                if (this.RuntimeData.FuBenItemData.TryGetValue(scene.GameId, out fuBenData))
                                {
                                    fuBenData.State = GameFuBenState.End;
                                    LogManager.WriteLog(LogTypes.Error, string.Format("阿卡伦西战场跨服GameID={0},战斗结束", fuBenData.GameId), null, true);
                                }
                            }
                            else if (scene.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                            {
                                if (ticks >= scene.m_lLeaveTime)
                                {
                                    scene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;
                                    try
                                    {
                                        List <GameClient> objsList = copyMap.GetClientsList();
                                        if (objsList != null && objsList.Count > 0)
                                        {
                                            for (int i = 0; i < objsList.Count; i++)
                                            {
                                                GameClient c = objsList[i];
                                                if (c != null)
                                                {
                                                    KuaFuManager.getInstance().GotoLastMap(c);
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DataHelper.WriteExceptionLogEx(ex, "阿卡伦西战场系统清场调度异常");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void TimerProc()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks >= WanMoXiaGuManager._nextHeartBeatTicks)
            {
                WanMoXiaGuManager._nextHeartBeatTicks = nowTicks + 1020L;
                long nowSecond = nowTicks / 1000L;
                List <WanMoXiaGuScene> removeList = new List <WanMoXiaGuScene>();
                lock (this.RuntimeData.Mutex)
                {
                    foreach (WanMoXiaGuScene scene in this.SceneDict.Values)
                    {
                        int nID     = scene.FuBenSeqId;
                        int nCopyID = scene.CopyMapID;
                        int nMapID  = scene.MapID;
                        if (nID >= 0 && nCopyID >= 0 && nMapID >= 0)
                        {
                            CopyMap copyMap = scene.CopyMapInfo;
                            if (scene.SceneStatus == GameSceneStatuses.STATUS_NULL)
                            {
                                scene.PrepareTime            = nowSecond;
                                scene.BeginTime              = nowSecond + (long)this.RuntimeData.PrepareSecs;
                                scene.SceneStatus            = GameSceneStatuses.STATUS_PREPARE;
                                scene.StateTimeData.GameType = 8;
                                scene.StateTimeData.State    = (int)scene.SceneStatus;
                                scene.StateTimeData.EndTicks = nowTicks + (long)(this.RuntimeData.PrepareSecs * 1000);
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMapInfo);
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_PREPARE)
                            {
                                if (nowSecond >= scene.BeginTime)
                                {
                                    scene.SceneStatus            = GameSceneStatuses.STATUS_BEGIN;
                                    scene.EndTime                = nowSecond + (long)this.RuntimeData.FightingSecs;
                                    scene.StateTimeData.GameType = 8;
                                    scene.StateTimeData.State    = (int)scene.SceneStatus;
                                    scene.StateTimeData.EndTicks = nowTicks + (long)(this.RuntimeData.FightingSecs * 1000);
                                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMapInfo);
                                }
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                                if (nowSecond >= scene.EndTime)
                                {
                                    scene.SceneStatus = GameSceneStatuses.STATUS_END;
                                }
                                else if (null == scene.Boss)
                                {
                                    scene.Boss = (GameManager.MonsterMgr.FindMonsterByExtensionID(copyMap.CopyMapID, this.RuntimeData.BossMonsterID).FirstOrDefault <object>() as Monster);
                                    if (null != scene.Boss)
                                    {
                                        scene.ScoreData.MonsterID       = scene.Boss.RoleID;
                                        scene.ScoreData.BossLifePercent = 1.0;
                                    }
                                }
                                else if (scene.Boss != null && scene.Boss.Alive)
                                {
                                    if (!scene.MonsterCreated && scene.BossLifePercent < this.RuntimeData.WanMoXiaGuCall)
                                    {
                                        int rnd = Global.GetRandomNumber(this.RuntimeData.BeginNum, this.RuntimeData.EndNum);
                                        foreach (WanMoXiaGuMonsterConfigInfo item in this.RuntimeData.MonsterOrderConfigList.Values)
                                        {
                                            if (rnd >= item.BeginNum && rnd <= item.EndNum)
                                            {
                                                scene.ScoreData.Intro       = item.Intro;
                                                scene.ScoreData.Decorations = item.Decorations;
                                                scene.ZuoQiInfo             = item;
                                                this.CreateMonster(scene, scene.ZuoQiInfo);
                                                scene.MonsterCreated  = true;
                                                scene.NextRelifeTicks = nowTicks + (long)(scene.ZuoQiInfo.RecoverTime * 1000);
                                            }
                                        }
                                    }
                                    if (scene.ZuoQiInfo != null)
                                    {
                                        if (scene.MonsterCount != scene.ScoreData.MonsterCount)
                                        {
                                            scene.MonsterCount = scene.ScoreData.MonsterCount;
                                            foreach (string pstr in scene.ZuoQiInfo.Props.Split(new char[]
                                            {
                                                '|'
                                            }))
                                            {
                                                string[] strs = pstr.Split(new char[]
                                                {
                                                    ','
                                                });
                                                ExtPropIndexes propIdx;
                                                double         propValue;
                                                if (strs.Length == 2 && Enum.TryParse <ExtPropIndexes>(strs[0], out propIdx) && double.TryParse(strs[1], out propValue))
                                                {
                                                    scene.Boss.TempPropsBuffer.AddTempExtProp((int)propIdx, propValue * (double)scene.MonsterCount, long.MaxValue);
                                                }
                                            }
                                        }
                                        if (nowTicks >= scene.NextRelifeTicks)
                                        {
                                            scene.NextRelifeTicks = nowTicks + (long)(scene.ZuoQiInfo.RecoverTime * 1000);
                                            if (scene.MonsterCount > 0)
                                            {
                                                Monster monster = scene.Boss;
                                                monster.AddLife((long)(scene.ZuoQiInfo.RecoverNum * scene.MonsterCount));
                                                List <object> listObjs = Global.GetAll9Clients(monster);
                                                GameManager.ClientMgr.NotifyOthersRelife(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, monster, monster.MonsterZoneNode.MapCode, monster.CopyMapID, monster.RoleID, (int)monster.SafeCoordinate.X, (int)monster.SafeCoordinate.Y, (int)monster.SafeDirection, monster.VLife, monster.VMana, 120, listObjs, 0);
                                            }
                                            scene.BossLifePercent = (scene.ScoreData.BossLifePercent = scene.Boss.VLife / scene.Boss.MonsterInfo.VLifeMax);
                                            GameManager.ClientMgr.BroadSpecialCopyMapMessage <WanMoXiaGuScoreData>(1266, scene.ScoreData, scene.CopyMapInfo);
                                        }
                                    }
                                }
                                else
                                {
                                    scene.Success     = 1;
                                    scene.SceneStatus = GameSceneStatuses.STATUS_END;
                                }
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_END)
                            {
                                scene.SceneStatus = GameSceneStatuses.STATUS_AWARD;
                                scene.EndTime     = nowSecond;
                                scene.LeaveTime   = scene.EndTime + (long)this.RuntimeData.ClearRolesSecs;
                                if (scene.Success > 0)
                                {
                                    this.GiveAwards(scene);
                                }
                                scene.StateTimeData.GameType = 8;
                                scene.StateTimeData.State    = 3;
                                scene.StateTimeData.EndTicks = nowTicks + (long)(this.RuntimeData.ClearRolesSecs * 1000);
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, scene.StateTimeData, scene.CopyMapInfo);
                            }
                            else if (scene.SceneStatus == GameSceneStatuses.STATUS_AWARD)
                            {
                                if (nowSecond >= scene.LeaveTime)
                                {
                                    removeList.Add(scene);
                                    copyMap.SetRemoveTicks(scene.LeaveTime);
                                    scene.SceneStatus = GameSceneStatuses.STATUS_CLEAR;
                                    try
                                    {
                                        List <GameClient> objsList = copyMap.GetClientsList();
                                        if (objsList != null && objsList.Count > 0)
                                        {
                                            for (int i = 0; i < objsList.Count; i++)
                                            {
                                                GameClient c = objsList[i];
                                                if (c != null)
                                                {
                                                    KuaFuManager.getInstance().GotoLastMap(c);
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DataHelper.WriteExceptionLogEx(ex, "【万魔峡谷】清场调度异常");
                                    }
                                }
                            }
                        }
                    }
                }
                if (removeList.Count > 0)
                {
                    lock (this.RuntimeData.Mutex)
                    {
                        foreach (WanMoXiaGuScene scene in removeList)
                        {
                            WanMoXiaGuScene item2;
                            this.SceneDict.TryRemove(scene.FuBenSeqId, out item2);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 检查死亡的怪物是否为帮会副本boss并进行通关处理
        /// </summary>
        public void ProcessMonsterDead(GameClient client, Monster monster)
        {
            // 怪物所在场景不是帮会地图
            if (IsGuildCopyMap(monster.CurrentMapCode) == false)
            {
                return;
            }

            SystemXmlItem systemFuBenItem = null;

            if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(monster.CurrentMapCode, out systemFuBenItem))
            {
                return;
            }

            if (null == systemFuBenItem)
            {
                return;
            }

            int nBossID = systemFuBenItem.GetIntValue("BossID");

            // 不是boss
            if (nBossID != monster.MonsterInfo.ExtensionID)
            {
                return;
            }

            // 玩家没有帮会?
            GuildCopyMapDB data = GameManager.GuildCopyMapDBMgr.FindGuildCopyMapDB(client.ClientData.Faction);

            if (null == data)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == data), guildid={0}", client.ClientData.Faction));
                return;
            }

            // 没有对应副本?
            CopyMap copyMap = GameManager.CopyMapMgr.FindCopyMap(monster.CurrentCopyMapID);

            if (null == copyMap)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == copyMap), CurrentCopyMapID={0}", monster.CurrentCopyMapID));
                return;
            }

            // 没有奖励配置?
            FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(copyMap.FubenMapID, copyMap.MapCode);

            if (null == fuBenMapItem)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == fuBenMapItem), CopyMapID={0}, MapCode={1}", copyMap.FubenMapID, copyMap.MapCode));
                return;
            }

            List <GameClient> objsList = copyMap.GetClientsList();

            // 副本里没人?
            if (null == objsList || objsList.Count <= 0)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == objsList || objsList.Count <= 0), CurrentCopyMapID={0}", monster.CurrentCopyMapID));
                return;
            }

            // 更新副本记录的状态
            if (copyMap.FubenMapID >= data.FuBenID)
            {
                data.FuBenID = copyMap.FubenMapID;
                data.State   = (int)GuildCopyMapState.Passed;
                if (copyMap.FubenMapID == GameManager.GuildCopyMapMgr.FirstGuildCopyMapOrder)
                {
                    data.Killers = monster.WhoKillMeName;
                }
                else
                {
                    data.Killers += ",";
                    data.Killers += monster.WhoKillMeName;
                }
            }

            // 检查是否更新成功
            bool result = GameManager.GuildCopyMapDBMgr.UpdateGuildCopyMapDB(data);

            if (false == result)
            {
                string logStr = @"GuildCopyMapManager::ProcessMonsterDead (false == result), 
                        data.GuildID={0}, data.FuBenID={1}, data.State={2}, data.OpenDay={3}, data.Killers={4}";
                LogManager.WriteLog(LogTypes.Error, string.Format(logStr, data.GuildID, data.FuBenID, data.State, data.OpenDay, data.Killers));
                return;
            }

            for (int i = 0; i < objsList.Count; i++)
            {
                //不在同一个地图上不参与分配
                GameClient gc = objsList[i];
                if (null == gc)
                {
                    continue;
                }

                // 准备发奖
                // 先检查上次领奖是不是本周~~
                int      nGuildCopyMapAwardDay = Global.GetRoleParamsInt32FromDB(gc, RoleParamName.GuildCopyMapAwardDay);
                DateTime AwardTime             = Global.GetRealDate(nGuildCopyMapAwardDay);
                if (Global.BeginOfWeek(AwardTime) != Global.BeginOfWeek(DateTime.Now))
                {
                    // 不是这周领奖则重置玩家领奖记录
                    Global.SaveRoleParamsInt32ValueToDB(gc, RoleParamName.GuildCopyMapAwardFlag, 0, true);
                }

                int  nGuildCopyMapAwardFlag = Global.GetRoleParamsInt32FromDB(gc, RoleParamName.GuildCopyMapAwardFlag);
                bool flag = GetGuildCopyMapAwardDayFlag(nGuildCopyMapAwardFlag, GetGuildCopyMapIndex(monster.CopyMapID), 1);
                // 领取过了
                if (flag == true)
                {
                    continue;
                }

                nGuildCopyMapAwardFlag = SetGuildCopyMapAwardDayFlag(nGuildCopyMapAwardFlag, GetGuildCopyMapIndex(monster.CopyMapID), 1);
                Global.SaveRoleParamsInt32ValueToDB(gc, RoleParamName.GuildCopyMapAwardFlag, nGuildCopyMapAwardFlag, true);
                Global.SaveRoleParamsInt32ValueToDB(gc, RoleParamName.GuildCopyMapAwardDay, Global.GetOffsetDay(DateTime.Now), true);
                // 发奖

                Global.SaveRoleParamsInt32ValueToDB(gc, RoleParamName.GuildZhanGong, Global.GetRoleParamsInt32FromDB(gc, RoleParamName.GuildZhanGong) + fuBenMapItem.nZhanGongaward, true);
                GameManager.ClientMgr.NotifySelfParamsValueChange(gc, RoleCommonUseIntParamsIndexs.ZhanGong, fuBenMapItem.nZhanGongaward);
            }
        }
Exemplo n.º 14
0
 public void ProcessMonsterDead(GameClient client, Monster monster)
 {
     if (this.IsGuildCopyMap(monster.CurrentMapCode))
     {
         SystemXmlItem systemFuBenItem = null;
         if (GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(monster.CurrentMapCode, out systemFuBenItem))
         {
             if (null != systemFuBenItem)
             {
                 int nBossID = systemFuBenItem.GetIntValue("BossID", -1);
                 if (nBossID == monster.MonsterInfo.ExtensionID)
                 {
                     CopyMap copyMap = GameManager.CopyMapMgr.FindCopyMap(monster.CurrentCopyMapID);
                     if (null == copyMap)
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == copyMap), CurrentCopyMapID={0}", monster.CurrentCopyMapID), null, true);
                     }
                     else
                     {
                         GuildCopyMap mapData = GameManager.GuildCopyMapMgr.FindGuildCopyMapBySeqID(copyMap.FuBenSeqID);
                         if (null == mapData)
                         {
                             LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == mapData), copyMap.FuBenSeqID={0}", copyMap.FuBenSeqID), null, true);
                         }
                         else
                         {
                             int            guildid = mapData.GuildID;
                             GuildCopyMapDB data    = GameManager.GuildCopyMapDBMgr.FindGuildCopyMapDB(guildid, client.ServerId);
                             if (null == data)
                             {
                                 LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == data), guildid={0}", client.ClientData.Faction), null, true);
                             }
                             else
                             {
                                 List <GameClient> objsList = copyMap.GetClientsList();
                                 if (objsList == null || objsList.Count <= 0)
                                 {
                                     LogManager.WriteLog(LogTypes.Error, string.Format("GuildCopyMapManager::ProcessMonsterDead (null == objsList || objsList.Count <= 0), CurrentCopyMapID={0}", monster.CurrentCopyMapID), null, true);
                                 }
                                 else
                                 {
                                     if (copyMap.FubenMapID >= data.FuBenID)
                                     {
                                         data.FuBenID = copyMap.FubenMapID;
                                         data.State   = 2;
                                         if (copyMap.FubenMapID == GameManager.GuildCopyMapMgr.FirstGuildCopyMapOrder)
                                         {
                                             data.Killers = monster.WhoKillMeName;
                                         }
                                         else
                                         {
                                             GuildCopyMapDB guildCopyMapDB = data;
                                             guildCopyMapDB.Killers += ",";
                                             GuildCopyMapDB guildCopyMapDB2 = data;
                                             guildCopyMapDB2.Killers += monster.WhoKillMeName;
                                         }
                                     }
                                     GlobalEventSource.getInstance().fireEvent(ZhanMengShijianEvent.createKillBossEvent(Global.FormatRoleName4(client), client.ClientData.Faction, monster.MonsterInfo.ExtensionID, client.ServerId));
                                     if (!GameManager.GuildCopyMapDBMgr.UpdateGuildCopyMapDB(data, client.ServerId))
                                     {
                                         string logStr = "GuildCopyMapManager::ProcessMonsterDead (false == result), \r\n                        data.GuildID={0}, data.FuBenID={1}, data.State={2}, data.OpenDay={3}, data.Killers={4}";
                                         LogManager.WriteLog(LogTypes.Error, string.Format(logStr, new object[]
                                         {
                                             data.GuildID,
                                             data.FuBenID,
                                             data.State,
                                             data.OpenDay,
                                             data.Killers
                                         }), null, true);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }