public YongZheZhanChangFuBenData GetKuaFuFuBenData(int gameId) { YongZheZhanChangFuBenData yongZheZhanChangFuBenData = null; lock (this.Mutex) { if (this.FuBenDataDict.TryGetValue(gameId, out yongZheZhanChangFuBenData)) { return(yongZheZhanChangFuBenData); } } if (yongZheZhanChangFuBenData == null) { IYongZheZhanChangService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { yongZheZhanChangFuBenData = kuaFuService.GetFuBenData(gameId); if (null != yongZheZhanChangFuBenData) { lock (this.Mutex) { this.FuBenDataDict[gameId] = yongZheZhanChangFuBenData; } } } catch (Exception ex) { yongZheZhanChangFuBenData = null; } } } return(yongZheZhanChangFuBenData); }
public bool KuaFuLogin(KuaFuServerLoginData kuaFuServerLoginData) { YongZheZhanChangFuBenData YongZheZhanChangFuBenData = this.GetKuaFuFuBenData((int)kuaFuServerLoginData.GameId); if (YongZheZhanChangFuBenData != null && YongZheZhanChangFuBenData.State < GameFuBenState.End) { if (YongZheZhanChangFuBenData.ServerId == GameManager.ServerId) { if (YongZheZhanChangFuBenData.RoleDict.ContainsKey(kuaFuServerLoginData.RoleId)) { kuaFuServerLoginData.FuBenSeqId = YongZheZhanChangFuBenData.SequenceId; KuaFuRoleData kuaFuRoleData = this.GetKuaFuRoleDataFromServer(kuaFuServerLoginData.ServerId, kuaFuServerLoginData.RoleId); if (kuaFuRoleData.GameId == YongZheZhanChangFuBenData.GameId) { return(true); } } } } return(false); }
public bool OnInitGame(GameClient client) { KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client); YongZheZhanChangFuBenData 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) { YongZheZhanChangFuBenData newFuBenData = YongZheZhanChangClient.getInstance().GetKuaFuFuBenData((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; } } } KuaFuFuBenRoleData kuaFuFuBenRoleData; bool result; if (!fuBenData.RoleDict.TryGetValue(client.ClientData.RoleID, out kuaFuFuBenRoleData)) { result = false; } else { int posX; int posY; this.GetBirthPoint(client, out posX, out posY); lock (this.RuntimeData.Mutex) { kuaFuServerLoginData.FuBenSeqId = fuBenData.SequenceId; KuaFuBossSceneInfo sceneInfo; if (!this.RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo)) { return(false); } client.ClientData.MapCode = sceneInfo.MapCode; } client.ClientData.PosX = posX; client.ClientData.PosY = posY; client.ClientData.FuBenSeqID = kuaFuServerLoginData.FuBenSeqId; result = true; } return(result); }
public void EventCallBackHandler(int eventType, params object[] args) { try { switch (eventType) { case (int)KuaFuEventTypes.RoleSignUp: case (int)KuaFuEventTypes.RoleStateChange: { if (args.Length == 1) { KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData; if (null != kuaFuRoleData) { UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId); } } } break; case (int)KuaFuEventTypes.UpdateAndNotifyEnterGame: { if (args.Length == 1) { KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData; if (null != kuaFuRoleData) { UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId); YongZheZhanChangFuBenData fuBenData = GetKuaFuFuBenData(kuaFuRoleData.GameId); if (null != fuBenData && fuBenData.State == GameFuBenState.Start) { KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData() { RoleId = kuaFuRoleData.RoleId, GameType = kuaFuRoleData.GameType, GameId = kuaFuRoleData.GameId, EndTicks = kuaFuRoleData.StateEndTicks, }; kuaFuServerLoginData.ServerId = ClientInfo.ServerId; lock (Mutex) { KuaFuServerInfo kuaFuServerInfo; if (ServerIdServerInfoDict.TryGetValue(fuBenData.ServerId, out kuaFuServerInfo)) { kuaFuServerLoginData.ServerIp = kuaFuServerInfo.Ip; kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port; } } switch ((GameTypes)kuaFuRoleData.GameType) { case GameTypes.YongZheZhanChang: CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), (int)SceneUIClasses.YongZheZhanChang); break; case GameTypes.KuaFuBoss: CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), (int)SceneUIClasses.KuaFuBoss); break; case GameTypes.KingOfBattle: CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), (int)SceneUIClasses.KingOfBattle); break; } } } } } break; case (int)KuaFuEventTypes.UpdateLhlyBhData: { if (args.Length == 1) { LangHunLingYuBangHuiDataEx data = args[0] as LangHunLingYuBangHuiDataEx; CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyBangHuiDataGameEvent(data), (int)SceneUIClasses.LangHunLingYu); } } break; case (int)KuaFuEventTypes.UpdateLhlyCityData: { if (args.Length == 1) { LangHunLingYuCityDataEx data = args[0] as LangHunLingYuCityDataEx; CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityDataGameEvent(data), (int)SceneUIClasses.LangHunLingYu); } } break; case (int)KuaFuEventTypes.UpdateLhlyOtherCityList: { if (args.Length == 1) { Dictionary <int, List <int> > data = args[0] as Dictionary <int, List <int> >; CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyOtherCityListGameEvent(data), (int)SceneUIClasses.LangHunLingYu); } } break; case (int)KuaFuEventTypes.UpdateLhlyCityOwnerList: { if (args.Length == 1) { List <LangHunLingYuKingHist> data = args[0] as List <LangHunLingYuKingHist>; CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerHistGameEvent(data), (int)SceneUIClasses.LangHunLingYu); } } break; case (int)KuaFuEventTypes.UpdateLhlyCityOwnerAdmire: { if (args.Length == 2) { int rid = (int)args[0]; int admirecount = (int)args[1]; CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerAdmireGameEvent(rid, admirecount), (int)SceneUIClasses.LangHunLingYu); } } break; } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } }
public bool OnInitGame(GameClient client) { int posX; int posY; int side; KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client); YongZheZhanChangFuBenData fuBenData; lock (RuntimeData.Mutex) { if (!RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData)) { fuBenData = null; } else if (fuBenData.State >= GameFuBenState.End) { return(false); } } if (null == fuBenData) { //从中心查询副本信息 YongZheZhanChangFuBenData newFuBenData = YongZheZhanChangClient.getInstance().GetKuaFuFuBenData((int)kuaFuServerLoginData.GameId); if (newFuBenData == null || newFuBenData.State == GameFuBenState.End) { LogManager.WriteLog(LogTypes.Error, "获取不到有效的副本数据," + newFuBenData == null ? "fuBenData == null" : "fuBenData.State == GameFuBenState.End"); return(false); } lock (RuntimeData.Mutex) { if (!RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData)) { fuBenData = newFuBenData; fuBenData.SequenceId = GameCoreInterface.getinstance().GetNewFuBenSeqId(); RuntimeData.FuBenItemData[fuBenData.GameId] = fuBenData; } } } KuaFuFuBenRoleData kuaFuFuBenRoleData; if (!fuBenData.RoleDict.TryGetValue(client.ClientData.RoleID, out kuaFuFuBenRoleData)) { return(false); } client.ClientData.BattleWhichSide = kuaFuFuBenRoleData.Side; side = GetBirthPoint(client, out posX, out posY); if (side <= 0) { LogManager.WriteLog(LogTypes.Error, "无法获取有效的阵营和出生点,进入跨服失败,side=" + side); return(false); } YongZheZhanChangSceneInfo sceneInfo; lock (RuntimeData.Mutex) { kuaFuServerLoginData.FuBenSeqId = fuBenData.SequenceId; if (!RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo)) { return(false); } client.ClientData.MapCode = sceneInfo.MapCode; } client.ClientData.PosX = posX; client.ClientData.PosY = posY; client.ClientData.FuBenSeqID = kuaFuServerLoginData.FuBenSeqId; return(true); }
public void EventCallBackHandler(AsyncDataItem item) { try { int eventType = (int)item.EventType; object[] args = item.Args; int num = eventType; switch (num) { case 0: case 1: if (args.Length == 1) { KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData; if (null != kuaFuRoleData) { this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId); } } break; case 2: case 4: case 5: break; case 3: if (args.Length == 1) { KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData; if (null != kuaFuRoleData) { this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId); YongZheZhanChangFuBenData fuBenData = this.GetKuaFuFuBenData(kuaFuRoleData.GameId); if (fuBenData != null && fuBenData.State == GameFuBenState.Start) { KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData { RoleId = kuaFuRoleData.RoleId, GameType = kuaFuRoleData.GameType, GameId = (long)kuaFuRoleData.GameId, EndTicks = kuaFuRoleData.StateEndTicks }; kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId; KuaFuServerInfo kuaFuServerInfo; if (KuaFuManager.getInstance().TryGetValue(fuBenData.ServerId, out kuaFuServerInfo)) { kuaFuServerLoginData.ServerIp = kuaFuServerInfo.Ip; kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port; } GameTypes gameType = (GameTypes)kuaFuRoleData.GameType; switch (gameType) { case GameTypes.YongZheZhanChang: this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 27); break; case GameTypes.KuaFuBoss: this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 31); break; default: if (gameType == GameTypes.KingOfBattle) { this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 39); } break; } } } } break; case 6: if (args.Length == 1) { LangHunLingYuBangHuiDataEx data = args[0] as LangHunLingYuBangHuiDataEx; this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyBangHuiDataGameEvent(data), 35); } break; case 7: if (args.Length == 1) { LangHunLingYuCityDataEx data2 = args[0] as LangHunLingYuCityDataEx; this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityDataGameEvent(data2), 35); } break; case 8: if (args.Length == 1) { Dictionary <int, List <int> > data3 = args[0] as Dictionary <int, List <int> >; this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyOtherCityListGameEvent(data3), 35); } break; case 9: if (args.Length == 1) { List <LangHunLingYuKingHist> data4 = args[0] as List <LangHunLingYuKingHist>; this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerHistGameEvent(data4), 35); } break; case 10: if (args.Length == 2) { int rid = (int)args[0]; int admirecount = (int)args[1]; this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerAdmireGameEvent(rid, admirecount), 35); } break; default: if (num == 9997) { if (GMCommands.EnableGMSetAllServerTime && item.Args.Length == 4) { string[] a = new string[item.Args.Length]; for (int i = 0; i < a.Length; i++) { a[i] = (item.Args[i] as string); if (string.IsNullOrEmpty(a[i])) { return; } } if (a[0] == "-settime") { GMCommands.GMSetTime(null, a, false); } } } break; } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } }