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); } } }
public bool initialize(ICoreInterface coreInterface) { try { this.CoreInterface = coreInterface; if (!this.InitConfig()) { return(false); } RemotingConfiguration.Configure(Process.GetCurrentProcess().MainModule.FileName + ".config", false); if (!HuanYingSiYuanClient.getInstance().initialize(coreInterface)) { return(false); } if (!TianTiClient.getInstance().initialize(coreInterface)) { return(false); } if (!YongZheZhanChangClient.getInstance().initialize(coreInterface)) { return(false); } if (!KFCopyRpcClient.getInstance().initialize(coreInterface)) { return(false); } if (!SpreadClient.getInstance().initialize(coreInterface)) { return(false); } if (!AllyClient.getInstance().initialize(coreInterface)) { return(false); } if (!IPStatisticsClient.getInstance().initialize(coreInterface)) { return(false); } if (!JunTuanClient.getInstance().initialize(coreInterface)) { return(false); } if (!KuaFuWorldClient.getInstance().initialize(coreInterface)) { return(false); } GlobalEventSource.getInstance().registerListener(12, KuaFuManager.getInstance()); } catch (Exception ex) { return(false); } return(true); }
private void LeaveFuBen(GameClient client) { lock (this.RuntimeData.Mutex) { KarenBattleScene scene = null; if (this.SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene)) { scene.m_nPlarerCount--; } JunTuanClient.getInstance().GameFuBenRoleChangeState(client.ServerId, client.ClientData.RoleID, scene.GameId, client.ClientData.BattleWhichSide, 7); } }
public bool ProcessGVoiceGetRoleListCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { int type = Global.SafeConvertToInt32(cmdParams[1]); int bhid = client.ClientData.Faction; int junTuanId = client.ClientData.JunTuanId; int rid = client.ClientData.RoleID; GVoicePriorityData resultData = new GVoicePriorityData(); resultData.Type = type; string priority = ""; lock (this.RuntimeData.Mutex) { if (type == 1) { resultData.ID = bhid; if (bhid > 0) { if (!this.RuntimeData.ZhanMengGVoiceDict.TryGetValue(bhid, out priority)) { priority = Global.sendToDB <string, int>(1112, bhid, client.ServerId); this.RuntimeData.ZhanMengGVoiceDict[bhid] = priority; } client.ClientData.GVoicePrioritys = priority; } } else if (type == 2) { resultData.ID = client.ClientData.JunTuanId; if (client.ClientData.JunTuanId > 0) { if (!this.RuntimeData.JunTuanGVoiceDict.TryGetValue(junTuanId, out priority)) { priority = JunTuanClient.getInstance().GetJunTuanGVoicePrioritys(bhid); this.RuntimeData.JunTuanGVoiceDict[junTuanId] = priority; } client.ClientData.GVoicePrioritys = priority; } } } resultData.RoleIdList = priority; client.sendCmd <GVoicePriorityData>(nID, resultData, false); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }
public bool KuaFuLogin(KuaFuServerLoginData kuaFuServerLoginData) { KarenFuBenRoleData kroleData = JunTuanClient.getInstance().GetKarenFuBenRoleData((int)kuaFuServerLoginData.GameId, kuaFuServerLoginData.RoleId); bool result; if (kroleData == null || (long)kroleData.KuaFuMapCode != kuaFuServerLoginData.GameId || kroleData.KuaFuServerId != GameManager.ServerId) { LogManager.WriteLog(LogTypes.Error, string.Format("{0}不具有进入跨服地图{1}的资格", kuaFuServerLoginData.RoleId, kuaFuServerLoginData.GameId), null, true); result = false; } else { result = true; } return(result); }
public JunTuanRankData GetJunTuanRankDataByClient(GameClient client) { List <JunTuanRankData> RankDataList = JunTuanClient.getInstance().GetJunTuanRankingData(); JunTuanRankData result; if (null == RankDataList) { result = null; } else { KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>(); if (RankDataList.Count > sceneItem.MaxLegions) { RankDataList = new List <JunTuanRankData>(RankDataList.GetRange(0, sceneItem.MaxLegions)); } result = RankDataList.Find((JunTuanRankData x) => x.JunTuanId == client.ClientData.JunTuanId); } return(result); }
public JunTuanRankData GetJunTuanRankDataBySide(int Side) { List <JunTuanRankData> RankDataList = JunTuanClient.getInstance().GetJunTuanRankingData(); JunTuanRankData result; if (null == RankDataList) { result = null; } else { KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>(); if (Side <= 0 || Side > RankDataList.Count || Side > sceneItem.MaxLegions) { result = null; } else { result = RankDataList[Side - 1]; } } return(result); }
public bool OnInitGame(GameClient client) { KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client); KarenFuBenData fuBenData; lock (this.RuntimeData.Mutex) { if (!this.RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData)) { fuBenData = null; } else if (fuBenData.State >= GameFuBenState.End) { return(false); } } if (null == fuBenData) { if (KarenBattleManager.getInstance().GMTest) { lock (this.RuntimeData.Mutex) { if (!this.RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData)) { fuBenData = new KarenFuBenData(); fuBenData.GameId = (int)kuaFuServerLoginData.GameId; fuBenData.SequenceId = GameCoreInterface.getinstance().GetNewFuBenSeqId(); this.RuntimeData.FuBenItemData[fuBenData.GameId] = fuBenData; } } } else { KarenFuBenData newFuBenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData((int)kuaFuServerLoginData.GameId); if (newFuBenData == null || newFuBenData.State == GameFuBenState.End) { LogManager.WriteLog(LogTypes.Error, ("获取不到有效的副本数据," + newFuBenData == null) ? "fuBenData == null" : "fuBenData.State == GameFuBenState.End", null, true); return(false); } lock (this.RuntimeData.Mutex) { if (!this.RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData)) { fuBenData = newFuBenData; fuBenData.SequenceId = GameCoreInterface.getinstance().GetNewFuBenSeqId(); this.RuntimeData.FuBenItemData[fuBenData.GameId] = fuBenData; } } } } if (KarenBattleManager.getInstance().GMTest) { client.ClientData.BattleWhichSide = Global.GetRandomNumber(1, 5); } else { KarenFuBenRoleData kroleData = JunTuanClient.getInstance().GetKarenFuBenRoleData((int)kuaFuServerLoginData.GameId, client.ClientData.RoleID); if (null == kroleData) { return(false); } client.ClientData.BattleWhichSide = kroleData.Side; } int posX; int posY; int side = this.GetBirthPoint(client, out posX, out posY, true); bool result; if (side <= 0) { LogManager.WriteLog(LogTypes.Error, "无法获取有效的阵营和出生点,进入跨服失败,side=" + side, null, true); result = false; } else { lock (this.RuntimeData.Mutex) { kuaFuServerLoginData.FuBenSeqId = fuBenData.SequenceId; KarenBattleSceneInfo sceneInfo; if (null == (sceneInfo = KarenBattleManager.getInstance().TryGetKarenBattleSceneInfo((int)kuaFuServerLoginData.GameId))) { return(false); } client.ClientData.MapCode = sceneInfo.MapCode; } client.ClientData.PosX = posX; client.ClientData.PosY = posY; client.ClientData.FuBenSeqID = kuaFuServerLoginData.FuBenSeqId; KarenBattleManager.getInstance().OnInitGame(SceneUIClasses.KarenWest, client); result = true; } return(result); }
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, "阿卡伦西战场系统清场调度异常"); } } } } } } } }
public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType) { bool result; if (sceneType == SceneUIClasses.KarenWest) { GameMap gameMap = null; if (!GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap)) { result = false; } else { int fuBenSeqId = copyMap.FuBenSeqID; int mapCode = copyMap.MapCode; int roleId = client.ClientData.RoleID; int gameId = (int)Global.GetClientKuaFuServerLoginData(client).GameId; DateTime now = TimeUtil.NowDateTime(); lock (this.RuntimeData.Mutex) { KarenBattleScene scene = null; if (!this.SceneDict.TryGetValue(fuBenSeqId, out scene)) { KarenFuBenData fuBenData; if (!this.RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData)) { LogManager.WriteLog(LogTypes.Error, "阿卡伦战场没有为副本找到对应的跨服副本数据,GameID:" + gameId, null, true); } KarenBattleSceneInfo sceneInfo; if (null == (sceneInfo = KarenBattleManager.getInstance().TryGetKarenBattleSceneInfo(mapCode))) { LogManager.WriteLog(LogTypes.Error, "阿卡伦战场没有为副本找到对应的档位数据,ID:" + mapCode, null, true); } scene = new KarenBattleScene(); scene.CopyMap = copyMap; scene.CleanAllInfo(); scene.GameId = gameId; scene.m_nMapCode = mapCode; scene.CopyMapId = copyMap.CopyMapID; scene.FuBenSeqId = fuBenSeqId; scene.m_nPlarerCount = 1; scene.SceneInfo = sceneInfo; scene.MapGridWidth = gameMap.MapGridWidth; scene.MapGridHeight = gameMap.MapGridHeight; DateTime startTime = now.Date.Add(KarenBattleManager.getInstance().GetStartTime(sceneInfo.MapCode)); scene.StartTimeTicks = startTime.Ticks / 10000L; this.InitScene(scene, client); this.SceneDict[fuBenSeqId] = scene; } else { scene.m_nPlarerCount++; } KarenBattleClientContextData clientContextData; if (!scene.ClientContextDataDict.TryGetValue(roleId, out clientContextData)) { clientContextData = new KarenBattleClientContextData { RoleId = roleId, ServerId = client.ServerId, BattleWhichSide = client.ClientData.BattleWhichSide }; scene.ClientContextDataDict[roleId] = clientContextData; } client.SceneObject = scene; client.SceneGameId = (long)scene.GameId; client.SceneContextData2 = clientContextData; copyMap.IsKuaFuCopy = true; copyMap.SetRemoveTicks(TimeUtil.NOW() + (long)(scene.SceneInfo.TotalSecs * 1000)); } JunTuanClient.getInstance().GameFuBenRoleChangeState(client.ServerId, roleId, gameId, client.ClientData.BattleWhichSide, 5); result = true; } } else { result = false; } return(result); }
public void PushGameResultData(KarenBattleScene scene) { JunTuanRankData rankData = this.GetJunTuanRankDataBySide(scene.SuccessSide); if (null != rankData) { JunTuanBaseData baseData = JunTuanManager.getInstance().GetJunTuanBaseDataByJunTuanID(rankData.JunTuanId); if (null == baseData) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取军团基本信息 JunTuanId={0}", rankData.JunTuanId), null, true); } else if (baseData.BhList == null || baseData.BhList.Count == 0) { LogManager.WriteLog(LogTypes.Fatal, string.Format("军团基本信息BhList为空 JunTuanId={0}", rankData.JunTuanId), null, true); } else { int leaderBangHui = baseData.BhList[0]; int leaderServerID = 0; SceneUIClasses mapType = Global.GetMapSceneType(scene.m_nMapCode); int lingDiType = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType); LingDiData oldLingDiData = null; List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData(); if (null != LingDiList) { oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType); } RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null; lock (this.Mutex) { if (!this.FactionIDVsServerIDDict.TryGetValue(leaderBangHui, out leaderServerID)) { JunTuanData data = JunTuanClient.getInstance().GetJunTuanData(leaderBangHui, rankData.JunTuanId, true); if (null == data) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取JunTuanData BangHuiID={0} JunTuanId={1}", leaderBangHui, rankData.JunTuanId), null, true); return; } LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, data.LeaderRoleId, rankData.JunTuanId, rankData.JunTuanName, null); EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, data.LeaderZoneId, rankData.JunTuanId, data.LeaderRoleId); return; } } BangHuiDetailData bhData = Global.GetBangHuiDetailData(-1, leaderBangHui, leaderServerID); if (null == bhData) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮会详细信息 BangHuiID={0} ServerID={1}", leaderBangHui, leaderServerID), null, true); } else { RoleDataEx dbRd = Global.sendToDB <RoleDataEx, string>(275, string.Format("{0}:{1}", -1, bhData.BZRoleID), leaderServerID); if (dbRd == null || dbRd.RoleID <= 0) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮主详细信息 BangHuiID={0} BZRoleID={1} ServerID={2}", leaderBangHui, bhData.BZRoleID, leaderServerID), null, true); } else { JunTuanManager.getInstance().OnInitGame(dbRd); RoleData4Selector leaderShowInfo = Global.RoleDataEx2RoleData4Selector(dbRd); LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, dbRd.RoleID, rankData.JunTuanId, rankData.JunTuanName, leaderShowInfo); EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, dbRd.ZoneID, rankData.JunTuanId, dbRd.RoleID); } } } } }
public bool ProcessGVoiceSetRoleListCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { int result = 0; int type = Global.SafeConvertToInt32(cmdParams[1]); string prioritys = cmdParams[2]; int bhid = client.ClientData.Faction; int rid = client.ClientData.RoleID; string leader = rid.ToString(); HashSet <string> rids = new HashSet <string>(); if (!string.IsNullOrEmpty(prioritys)) { foreach (string str in prioritys.Split(new char[] { ',' })) { if (str != leader) { rids.Add(str); } } } prioritys = string.Join(",", rids); if (type == 1) { if (bhid <= 0 || client.ClientData.BHZhiWu != 1) { result = -1002; } else if (rids.Count >= this.RuntimeData.VoicePowerNum[0]) { result = -1035; } else { Global.sendToDB <string, string>(1111, string.Format("{0}:{1}:{2}", rid, bhid, prioritys), client.ServerId); GMCmdData gmCmdData = new GMCmdData { Fields = new string[] { "-gvoicepriority", 1.ToString(), bhid.ToString(), prioritys } }; HuanYingSiYuanClient.getInstance().BroadcastGMCmdData(gmCmdData, 1); this.UpdateGVoicePriority(gmCmdData, true); } } else if (type == 2) { if (client.ClientData.BHZhiWu != 1 || (client.ClientData.JunTuanId <= 0 && client.ClientData.JunTuanZhiWu == 1)) { result = -1024; } else if (rids.Count >= this.RuntimeData.VoicePowerNum[1]) { result = -1035; } else { result = JunTuanClient.getInstance().ChangeJunTuanGVoicePrioritys(bhid, prioritys); } } client.sendCmd <int>(nID, result, false); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }
public bool ProcessGetKarenBattleStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { int result = 0; int westcount = 0; int eastcount = 0; if (!this.IsGongNengOpened(client, true)) { client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { result, westcount, eastcount, "", "" }), false); return(true); } KarenGameStates timeState = KarenGameStates.None; this.CheckTimeCondition(ref timeState); if (this.CheckCanEnterKarenBattle(client)) { if (timeState == KarenGameStates.Wait) { result = 1; } else if (timeState == KarenGameStates.Start) { lock (this.Mutex) { foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict) { KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key); if (null != fubenData) { JunTuanRankData rankData = this.GetJunTuanRankDataByClient(client); if (null != rankData) { SceneUIClasses sceneType = Global.GetMapSceneType(item.Value.MapCode); if (sceneType == SceneUIClasses.KarenWest) { westcount = fubenData.GetRoleCountWithEnter(rankData.Rank); } else { eastcount = fubenData.GetRoleCountWithEnter(rankData.Rank); } } } } } result = 2; } } else if (timeState == KarenGameStates.Wait || timeState == KarenGameStates.Start) { JunTuanRankData RankData = this.GetJunTuanRankDataByClient(client); if (null != RankData) { result = 3; } else { result = 4; } } string eastjtname = ""; string westjtname = ""; List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData(); if (null != LingDiList) { foreach (LingDiData item2 in LingDiList) { SceneUIClasses mapType = this.ConvertCaiJiLingDiTypeToMapSceneType(item2.LingDiType); if (mapType == SceneUIClasses.KarenWest) { westjtname = item2.JunTuanName; } else if (mapType == SceneUIClasses.KarenEast) { eastjtname = item2.JunTuanName; } } } client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[] { result, westcount, eastcount, westjtname, eastjtname }), false); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }
public bool ProcessKarenBattleEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { int result = 0; if (!this.IsGongNengOpened(client, true)) { client.sendCmd <int>(nID, result, false); return(true); } int roleID = Global.SafeConvertToInt32(cmdParams[0]); int mapCode = Global.SafeConvertToInt32(cmdParams[1]); KarenBattleSceneInfo sceneItem = null; KarenGameStates state = KarenGameStates.None; int eastcount = 0; int westcount = 0; JunTuanRankData rankData = this.GetJunTuanRankDataByClient(client); if (rankData == null || !this.CheckCanEnterKarenBattle(client)) { result = -5; client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } if (!this.CheckMap(client)) { result = -21; client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } result = this.CheckTimeCondition(ref state); if (state != KarenGameStates.Start) { result = -2001; client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } lock (this.Mutex) { if (!this.SceneDataDict.TryGetValue(mapCode, out sceneItem)) { result = -5; client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict) { KarenFuBenData fbData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key); if (null != fbData) { SceneUIClasses sType = Global.GetMapSceneType(item.Value.MapCode); if (sType == SceneUIClasses.KarenWest) { westcount = fbData.GetRoleCountWithEnter(rankData.Rank); } else { eastcount = fbData.GetRoleCountWithEnter(rankData.Rank); } } } DateTime lastEnterTime = Global.GetRoleParamsDateTimeFromDB(client, "20019"); if (!this.GMTest && TimeUtil.NowDateTime().Ticks - lastEnterTime.Ticks < 10000000L * (long)sceneItem.EnterCD) { GameManager.ClientMgr.NotifyImportantMsg(client, string.Format(GLang.GetLang(2615, new object[0]), sceneItem.EnterCD), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0); result = -2007; client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } KuaFuServerInfo kfserverInfo = null; KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(mapCode); if (fubenData == null || !KuaFuManager.getInstance().TryGetValue(fubenData.ServerId, out kfserverInfo)) { result = -11000; client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } if (fubenData.GetRoleCountWithEnter(rankData.Rank) >= sceneItem.MaxEnterNum) { result = -22; client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } SceneUIClasses sceneType = Global.GetMapSceneType(sceneItem.MapCode); KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client); if (null != clientKuaFuServerLoginData) { clientKuaFuServerLoginData.RoleId = client.ClientData.RoleID; clientKuaFuServerLoginData.GameId = (long)fubenData.GameId; clientKuaFuServerLoginData.GameType = fubenData.GameType; clientKuaFuServerLoginData.EndTicks = fubenData.EndTime.Ticks; clientKuaFuServerLoginData.ServerId = client.ServerId; clientKuaFuServerLoginData.ServerIp = kfserverInfo.Ip; clientKuaFuServerLoginData.ServerPort = kfserverInfo.Port; clientKuaFuServerLoginData.FuBenSeqId = 0; } if (result >= 0) { result = JunTuanClient.getInstance().GameFuBenRoleChangeState(client.ServerId, client.ClientData.RoleID, (int)clientKuaFuServerLoginData.GameId, rankData.Rank, 4); if (result >= 0) { GlobalNew.RecordSwitchKuaFuServerLog(client); client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false); } else { Global.GetClientKuaFuServerLoginData(client).RoleId = 0; } } } client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[] { result, 0, westcount, eastcount }), false); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }
private void TimerProc(object sender, EventArgs e) { bool notifyPrepareGame = false; bool notifyEnterGame = false; bool notifyEndGame = false; DateTime now = TimeUtil.NowDateTime(); lock (this.Mutex) { KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>(); for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2) { if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - 120.0 && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1] + 120.0) { double secsPrepare = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds; double secsEnd = sceneItem.SecondsOfDay[i + 1] + 120.0 - now.TimeOfDay.TotalSeconds; if (!this.PrepareGame) { if (secsPrepare > 0.0 && secsPrepare < 120.0) { this.PrepareGame = true; notifyPrepareGame = true; break; } } else if (secsPrepare < 0.0) { notifyEnterGame = true; this.PrepareGame = false; break; } if (!this.EndGame) { if (secsEnd > 0.0 && secsEnd < 120.0) { this.EndGame = true; notifyEndGame = true; break; } } else if (secsEnd < 0.0) { this.EndGame = false; break; } } } } if (notifyPrepareGame) { LogManager.WriteLog(LogTypes.Error, "阿卡伦战场活动即将开始,准备通知军团角色进入!", null, true); lock (this.Mutex) { this.FactionIDVsServerIDDict.Clear(); } } if (notifyEnterGame) { int westcount = 0; int eastcount = 0; lock (this.Mutex) { LogManager.WriteLog(LogTypes.Error, "阿卡伦战场开启,可以通知已分配到场次的玩家进入游戏了", null, true); KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>(); foreach (GameClient client in GameManager.ClientMgr.GetAllClients(true)) { if (this.CheckCanEnterKarenBattle(client) && this.CheckMap(client) && this.IsGongNengOpened(client, false)) { if (null != client) { client.sendCmd(1210, string.Format("{0}:{1}:{2}:{3}", new object[] { 1, 1, westcount, eastcount }), false); } } } } } if (notifyEndGame) { lock (this.Mutex) { foreach (KarenBattleSceneInfo item in this.SceneDataDict.Values) { KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.MapCode); if (fubenData != null && fubenData.ServerId == GameManager.ServerId) { SceneUIClasses mapType = Global.GetMapSceneType(item.MapCode); if (mapType != SceneUIClasses.KarenEast || KarenBattleManager_MapEast.getInstance().SceneDict.Count == 0) { if (mapType != SceneUIClasses.KarenWest || KarenBattleManager_MapWest.getInstance().SceneDict.Count == 0) { int lingDiType = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType); LingDiData oldLingDiData = null; List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData(); if (null != LingDiList) { oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType); } RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null; LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, 0, 0, "", null); EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, 0, 0, 0); } } } } } } this.UpdateKuaFuMapClientCount(KarenBattleManager_MapWest.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>()); this.UpdateKuaFuMapClientCount(KarenBattleManager_MapEast.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>()); }
public bool startup() { try { ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("HuanYingSiYuanClient.TimerProc", new EventHandler(HuanYingSiYuanClient.getInstance().TimerProc)), 2000, 2857); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("TianTiClient.TimerProc", new EventHandler(TianTiClient.getInstance().TimerProc)), 2000, 2857); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("YongZheZhanChangClient.TimerProc", new EventHandler(YongZheZhanChangClient.getInstance().TimerProc)), 2000, 3389); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("KFCopyRpcClient.TimerProc", new EventHandler(KFCopyRpcClient.getInstance().TimerProc)), 2000, 2732); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("SpreadClient.TimerProc", new EventHandler(SpreadClient.getInstance().TimerProc)), 2000, 4285); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("AllyClient.TimerProc", new EventHandler(AllyClient.getInstance().TimerProc)), 2000, 5714); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("IPStatisticsClient.TimerProc", new EventHandler(IPStatisticsClient.getInstance().TimerProc)), 2000, 5000); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("JunTuanClient.TimerProc", new EventHandler(JunTuanClient.getInstance().TimerProc)), 2000, 2500); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("KuaFuWorldClient.TimerProc", new EventHandler(KuaFuWorldClient.getInstance().TimerProc)), 2000, 3389); lock (this.RuntimeData.Mutex) { if (null == this.RuntimeData.BackGroundThread) { this.RuntimeData.BackGroundThread = new Thread(new ThreadStart(this.BackGroudThreadProc)); this.RuntimeData.BackGroundThread.IsBackground = true; this.RuntimeData.BackGroundThread.Start(); } } } catch (Exception ex) { return(false); } return(true); }
public bool ProcessGetGVoiceSceneDataCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { GVoiceSceneData result = new GVoiceSceneData(); GVoicePriorityData priorityData = null; int bhid = client.ClientData.Faction; int junTuanId = client.ClientData.JunTuanId; int mapCode = client.ClientData.MapCode; MapTypes mapType = Global.GetMapType(mapCode); lock (this.RuntimeData.Mutex) { int type; if (this.RuntimeData.MapCode2GVoiceTypeDict.TryGetValue(mapCode, out type)) { string priority = null; if (type == 1) { if (!this.RuntimeData.ZhanMengGVoiceDict.TryGetValue(bhid, out priority)) { string[] ret = Global.SendToDB <int>(1112, bhid, client.ServerId); if (ret != null && ret.Length >= 1) { priority = ret[0]; this.RuntimeData.ZhanMengGVoiceDict[bhid] = priority; } } client.ClientData.GVoicePrioritys = priority; priorityData = new GVoicePriorityData { ID = bhid, Type = type, RoleIdList = priority }; } else if (type == 2) { if (!this.RuntimeData.JunTuanGVoiceDict.TryGetValue(junTuanId, out priority)) { priority = JunTuanClient.getInstance().GetJunTuanGVoicePrioritys(bhid); this.RuntimeData.JunTuanGVoiceDict[junTuanId] = priority; } client.ClientData.GVoicePrioritys = priority; priorityData = new GVoicePriorityData { ID = junTuanId, Type = type, RoleIdList = priority }; } int group; this.RuntimeData.MapCode2GVoiceGroupDict.TryGetValue(mapCode, out group); string id; if (mapType == MapTypes.Normal) { id = string.Format("{0}_{1}_{2}", GameManager.ServerId, group, priorityData.ID); } else { id = string.Format("{0}_{1}_{2}_{3}", new object[] { GameManager.ServerId, group, client.ClientData.FuBenSeqID, priorityData.ID }); } GVoiceSceneData data; if (!this.RuntimeData.FuBenSeqID2RoomName.TryGetValue(id, out data)) { data = new GVoiceSceneData(); data.RoomName = Guid.NewGuid().ToString("N"); this.RuntimeData.FuBenSeqID2RoomName[id] = data; } result.RoomName = data.RoomName; result.SDKGameID = this.RuntimeData.SDKGameID; result.SDKKey = this.RuntimeData.SDKKey; } } if (priorityData != null) { client.sendCmd <GVoicePriorityData>(1112, priorityData, false); } client.sendCmd <GVoiceSceneData>(nID, result, false); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }