public void UnionAllyInit(GameClient client) { if (!KuaFuManager.KuaFuWorldKuaFuGameServer) { lock (AllyClient.getInstance()._Mutex) { int unionID = client.ClientData.Faction; int serverID = client.ServerId; bool isKF = client.ClientSocket.IsKuaFuLogin; if (unionID > 0) { BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, unionID, serverID); if (unionData != null && this.IsAllyOpen(unionData.QiLevel)) { EAlly result = AllyClient.getInstance().HUnionAllyInit(unionID, isKF); if (result == EAlly.EAddUnion) { this.UnionDataChange(unionID, serverID, false, 0); } else if (result != EAlly.Succ) { LogManager.WriteLog(LogTypes.Error, string.Format("战盟结盟:数据初始化失败 id={0}", result), null, true); } List <AllyData> list = AllyClient.getInstance().HAllyDataList(unionID, EAllyDataType.Ally); if (list != null && list.Count > 0) { client.ClientData.AllyList = list; } } } } } }
public bool UnionIsAlly(GameClient client, int targetID) { bool result; lock (AllyClient.getInstance()._Mutex) { if (client.ClientData.AllyList == null || client.ClientData.AllyList.Count <= 0) { result = false; } else { AllyData resultData = client.ClientData.AllyList.Find((AllyData data) => data.UnionID == targetID); bool isAllyMap = this.IsAllyMap(client.ClientData.MapCode); if (resultData != null && isAllyMap) { result = true; } else { result = false; } } } return(result); }
public bool destroy() { try { if (!HuanYingSiYuanClient.getInstance().destroy()) { return(false); } /* * if (!ElementWarClient.getInstance().destroy()) * { * return false; * }*/ if (!SpreadClient.getInstance().destroy()) { return(false); } if (!AllyClient.getInstance().destroy()) { return(false); } } catch (System.Exception ex) { return(false); } return(true); }
public bool showdown() { try { lock (this.RuntimeData.Mutex) { this.RuntimeData.BackGroundThread.Abort(); this.RuntimeData.BackGroundThread = null; } GlobalEventSource.getInstance().removeListener(12, KuaFuManager.getInstance()); if (!HuanYingSiYuanClient.getInstance().showdown()) { return(false); } if (!SpreadClient.getInstance().showdown()) { return(false); } if (!AllyClient.getInstance().showdown()) { return(false); } } catch (Exception ex) { return(false); } return(true); }
private List <AllyData> GetAllyData(GameClient client, EAllyDataType dataType) { List <AllyData> resultList = new List <AllyData>(); int unionID = client.ClientData.Faction; List <AllyData> result; if (unionID <= 0) { result = resultList; } else { BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, unionID, client.ServerId); if (unionData == null || !this.IsAllyOpen(unionData.QiLevel)) { result = resultList; } else { switch (dataType) { case EAllyDataType.Ally: { List <AllyData> list = AllyClient.getInstance().HAllyDataList(unionID, EAllyDataType.Ally); if (list != null && list.Count > 0) { resultList.AddRange(list); } list = AllyClient.getInstance().HAllyDataList(unionID, EAllyDataType.Request); if (list != null && list.Count > 0) { resultList.AddRange(list); } break; } case EAllyDataType.Accept: { List <AllyData> list = AllyClient.getInstance().HAllyDataList(unionID, EAllyDataType.Accept); if (list != null && list.Count > 0) { resultList.AddRange(list); } client.AllyTip[0] = 0; if (client.AllyTip[1] <= 0) { client._IconStateMgr.AddFlushIconState(14111, false); } client._IconStateMgr.AddFlushIconState(14112, false); client._IconStateMgr.SendIconStateToClient(client); break; } } result = resultList; } } return(result); }
private EAlly AllyOperate(GameClient client, int targetID, EAllyOperate operateType) { if (targetID <= 0) { return(EAlly.ENoTargetUnion); } int unionID = client.ClientData.Faction; if (unionID <= 0) { return(EAlly.EUnionJoin); } BangHuiDetailData myUnion = Global.GetBangHuiDetailData(-1, unionID, client.ServerId); if (myUnion == null) { return(EAlly.EUnionJoin); } if (!IsAllyOpen(myUnion.QiLevel)) { return(EAlly.EUnionLevel); } if (myUnion.BZRoleID != client.ClientData.RoleID) { return(EAlly.ENotLeader); } int countSum = 0; if (operateType == EAllyOperate.Agree) { int countAlly = AllyClient.getInstance().AllyCount(unionID); int countRequest = AllyClient.getInstance().AllyRequestCount(unionID); if (countAlly > 0 && IsAllyMax(countAlly)) { return(EAlly.EAllyMax); } countSum = countAlly + countRequest; if (countSum > 0 && IsAllyMax(countSum)) { return(EAlly.EAllyMax); } } EAlly result = (EAlly)AllyClient.getInstance().HAllyOperate(unionID, targetID, operateType); if (result == EAlly.AllyAgree) { countSum++; client.sendCmd((int)TCPGameServerCmds.CMD_SPR_UNION_ALLY_NUM, countSum.ToString()); } return(result); }
private EAlly AllyOperate(GameClient client, int targetID, EAllyOperate operateType) { EAlly result2; if (targetID <= 0) { result2 = EAlly.ENoTargetUnion; } else { int unionID = client.ClientData.Faction; if (unionID <= 0) { result2 = EAlly.EUnionJoin; } else { BangHuiDetailData myUnion = Global.GetBangHuiDetailData(-1, unionID, client.ServerId); if (myUnion == null) { result2 = EAlly.EUnionJoin; } else if (!this.IsAllyOpen(myUnion.QiLevel)) { result2 = EAlly.EUnionLevel; } else if (myUnion.BZRoleID != client.ClientData.RoleID) { result2 = EAlly.ENotLeader; } else { int countSum = 0; if (operateType == EAllyOperate.Agree) { int countAlly = AllyClient.getInstance().AllyCount(unionID); int countRequest = AllyClient.getInstance().AllyRequestCount(unionID); if (countAlly > 0 && this.IsAllyMax(countAlly)) { return(EAlly.EAllyMax); } countSum = countAlly + countRequest; if (countSum > 0 && this.IsAllyMax(countSum)) { return(EAlly.EAllyMax); } } EAlly result = AllyClient.getInstance().HAllyOperate(unionID, targetID, operateType); if (result == EAlly.AllyAgree) { client.sendCmd(1048, (countSum + 1).ToString(), false); } result2 = result; } } } return(result2); }
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); }
public void UnionDataChange(int unionID, int serverID, bool isDel = false, int unionLevel = 0) { if (!KuaFuManager.KuaFuWorldKuaFuGameServer) { if (unionID > 0) { if (isDel) { if (this.IsAllyOpen(unionLevel)) { EAlly result = AllyClient.getInstance().HUnionDel(unionID); if (result != EAlly.Succ) { LogManager.WriteLog(LogTypes.Error, string.Format("战盟结盟:战盟{0}解散失败 id={1}", unionID, result), null, true); } } } else { BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, unionID, serverID); if (unionData != null && this.IsAllyOpen(unionData.QiLevel)) { AllyData data = new AllyData(); data.UnionID = unionData.BHID; data.UnionZoneID = unionData.ZoneID; data.UnionName = unionData.BHName; data.UnionLevel = unionData.QiLevel; data.UnionNum = unionData.TotalNum; data.LeaderID = unionData.BZRoleID; data.LeaderName = unionData.BZRoleName; SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(data.LeaderID); if (null != clientData) { data.LeaderZoneID = clientData.ZoneID; } else { data.LeaderZoneID = unionData.ZoneID; } EAlly result = AllyClient.getInstance().HUnionDataChange(data); if (result != EAlly.Succ) { LogManager.WriteLog(LogTypes.Error, string.Format("战盟结盟:战盟数据变更失败 id={0}", result), null, true); } } } } } }
public void UnionDataChange(int unionID, int serverID, bool isDel = false, int unionLevel = 0) { if (unionID <= 0) { return; } if (isDel) { if (!IsAllyOpen(unionLevel)) { return; } EAlly result = AllyClient.getInstance().HUnionDel(unionID); if (result != EAlly.Succ) { LogManager.WriteLog(LogTypes.Error, string.Format("战盟结盟:战盟{0}解散失败 id={1}", unionID, result)); } } else { BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, unionID, serverID); if (unionData == null || !IsAllyOpen(unionData.QiLevel)) { return; } AllyData data = new AllyData(); data.UnionID = unionData.BHID; data.UnionZoneID = unionData.ZoneID; data.UnionName = unionData.BHName; data.UnionLevel = unionData.QiLevel; data.UnionNum = unionData.TotalNum; data.LeaderID = unionData.BZRoleID; data.LeaderName = unionData.BZRoleName; var clientData = Global.GetSafeClientDataFromLocalOrDB(data.LeaderID); data.LeaderZoneID = clientData.ZoneID; EAlly result = AllyClient.getInstance().HUnionDataChange(data); if (result != EAlly.Succ) { LogManager.WriteLog(LogTypes.Error, string.Format("战盟结盟:战盟数据变更失败 id={0}", result)); } } }
public bool UnionIsAlly(GameClient client, int targetID) { lock (AllyClient.getInstance()._Mutex) { if (client.ClientData.AllyList == null || client.ClientData.AllyList.Count <= 0) { return(false); } AllyData resultData = client.ClientData.AllyList.Find( delegate(AllyData data) { return(data.UnionID == targetID); }); bool isAllyMap = IsAllyMap(client.ClientData.MapCode); if (resultData != null && isAllyMap) { return(true); } return(false); } }
public bool showdown() { try { lock (RuntimeData.Mutex) { RuntimeData.BackGroundThread.Abort(); RuntimeData.BackGroundThread = null; } GlobalEventSource.getInstance().removeListener((int)EventTypes.PlayerLogout, getInstance()); if (!HuanYingSiYuanClient.getInstance().showdown()) { return(false); } /* * if (!ElementWarClient.getInstance().showdown()) * { * return false; * }*/ if (!SpreadClient.getInstance().showdown()) { return(false); } if (!AllyClient.getInstance().showdown()) { return(false); } } catch (System.Exception ex) { return(false); } return(true); }
public bool destroy() { try { if (!HuanYingSiYuanClient.getInstance().destroy()) { return(false); } if (!SpreadClient.getInstance().destroy()) { return(false); } if (!AllyClient.getInstance().destroy()) { return(false); } } catch (Exception ex) { return(false); } return(true); }
public void processEvent(EventObjectEx eventObject) { switch (eventObject.EventType) { case 10026: { KFNotifyAllyGameEvent e = eventObject as KFNotifyAllyGameEvent; int unionID = e.UnionID; List <AllyData> list = AllyClient.getInstance().HAllyDataList(unionID, EAllyDataType.Ally); int index = 0; GameClient client; while ((client = GameManager.ClientMgr.GetNextClient(ref index, false)) != null) { lock (AllyClient.getInstance()._Mutex) { if (client.ClientData.Faction == unionID) { client.ClientData.AllyList = list; } } } break; } case 10027: { KFNotifyAllyLogGameEvent e2 = eventObject as KFNotifyAllyLogGameEvent; if (null != e2) { List <AllyLogData> list2 = (List <AllyLogData>)e2.LogList; if (list2 != null && list2.Count > 0) { foreach (AllyLogData log in list2) { this.DBAllyLogAdd(log, 0); } } eventObject.Handled = true; } break; } case 10028: { KFNotifyAllyTipGameEvent e3 = eventObject as KFNotifyAllyTipGameEvent; if (null != e3) { int unionID = e3.UnionID; int tipID = e3.TipID; BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, unionID, GameManager.ServerId); if (unionData != null && this.IsAllyOpen(unionData.QiLevel)) { GameClient client = GameManager.ClientMgr.FindClient(unionData.BZRoleID); if (client == null) { break; } lock (AllyClient.getInstance()._Mutex) { if (tipID == 14112) { int countAlly = AllyClient.getInstance().AllyCount(unionID); if (countAlly > 0 && this.IsAllyMax(countAlly)) { break; } } client._IconStateMgr.AddFlushIconState(14111, false); client._IconStateMgr.AddFlushIconState((ushort)tipID, false); client._IconStateMgr.SendIconStateToClient(client); client._IconStateMgr.AddFlushIconState(14111, true); client._IconStateMgr.AddFlushIconState((ushort)tipID, true); client._IconStateMgr.SendIconStateToClient(client); switch (tipID) { case 14112: client.AllyTip[0] = 1; break; case 14113: client.AllyTip[1] = 1; break; } } } eventObject.Handled = true; } break; } case 10029: { int index = 0; GameClient client; while ((client = GameManager.ClientMgr.GetNextClient(ref index, false)) != null) { lock (AllyClient.getInstance()._Mutex) { client.ClientData.AllyList = null; this.UnionAllyInit(client); AllyClient.getInstance().HRankClear(); AllyClient.getInstance().HRankTopList(1); } } break; } } }
public void processEvent(EventObjectEx eventObject) { int eventType = eventObject.EventType; switch (eventType) { case (int)GlobalEventTypes.KFAllyStart: { int index = 0; GameClient client = null; while ((client = GameManager.ClientMgr.GetNextClient(ref index)) != null) { lock (AllyClient.getInstance()._Mutex) { client.ClientData.AllyList = null; UnionAllyInit(client); } } } break; case (int)GlobalEventTypes.Ally: { KFNotifyAllyGameEvent e = eventObject as KFNotifyAllyGameEvent; int unionID = (int)e.UnionID; List <AllyData> list = AllyClient.getInstance().HAllyDataList(unionID, EAllyDataType.Ally); int index = 0; GameClient client = null; while ((client = GameManager.ClientMgr.GetNextClient(ref index)) != null) { lock (AllyClient.getInstance()._Mutex) { if (client.ClientData.Faction != unionID) { continue; } client.ClientData.AllyList = list; } } } break; case (int)GlobalEventTypes.AllyLog: { KFNotifyAllyLogGameEvent e = eventObject as KFNotifyAllyLogGameEvent; if (null != e) { List <AllyLogData> list = (List <AllyLogData>)e.LogList; if (list != null && list.Count > 0) { foreach (var log in list) { DBAllyLogAdd(log, GameManager.LocalServerId); } } eventObject.Handled = true; } } break; case (int)GlobalEventTypes.AllyTip: { KFNotifyAllyTipGameEvent e = eventObject as KFNotifyAllyTipGameEvent; if (null != e) { int unionID = (int)e.UnionID; int tipID = (int)e.TipID; BangHuiDetailData unionData = Global.GetBangHuiDetailData(-1, unionID, GameManager.ServerId); if (unionData != null && IsAllyOpen(unionData.QiLevel)) { GameClient client = GameManager.ClientMgr.FindClient(unionData.BZRoleID); if (client == null) { return; } lock (AllyClient.getInstance()._Mutex) { if (tipID == (int)ActivityTipTypes.AllyAccept) { int countAlly = AllyClient.getInstance().AllyCount(unionID); if (countAlly > 0 && IsAllyMax(countAlly)) { return; } } client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.Ally, false); client._IconStateMgr.AddFlushIconState((ushort)tipID, false); client._IconStateMgr.SendIconStateToClient(client); client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.Ally, true); client._IconStateMgr.AddFlushIconState((ushort)tipID, true); client._IconStateMgr.SendIconStateToClient(client); switch (tipID) { case (int)ActivityTipTypes.AllyAccept: client.AllyTip[0] = 1; break; case (int)ActivityTipTypes.AllyMsg: client.AllyTip[1] = 1; break; } } } eventObject.Handled = true; } } break; } }
public bool startup() { try { ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("HuanYingSiYuanClient.TimerProc", HuanYingSiYuanClient.getInstance().TimerProc), 2000, 2857); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("TianTiClient.TimerProc", TianTiClient.getInstance().TimerProc), 2000, 1357); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("YongZheZhanChangClient.TimerProc", YongZheZhanChangClient.getInstance().TimerProc), 2000, 3389); //ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("MoRiJudgeClient.TimerProc", MoRiJudgeClient.getInstance().TimerProc), 2000, 1732); //ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("ElementWarClient.TimerProc", ElementWarClient.getInstance().TimerProc), 2000, 1732); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("KFCopyRpcClient.TimerProc", KFCopyRpcClient.getInstance().TimerProc), 2000, 1732); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("SpreadClient.TimerProc", SpreadClient.getInstance().TimerProc), 2000, 1732); ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("AllyClient.TimerProc", AllyClient.getInstance().TimerProc), 2000, 1732); lock (RuntimeData.Mutex) { if (null == RuntimeData.BackGroundThread) { RuntimeData.BackGroundThread = new Thread(BackGroudThreadProc); RuntimeData.BackGroundThread.IsBackground = true; RuntimeData.BackGroundThread.Start(); } } } catch (System.Exception ex) { return(false); } return(true); }
public bool initialize(ICoreInterface coreInterface) { try { CoreInterface = coreInterface; if (!InitConfig()) { return(false); } System.Runtime.Remoting.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 (!MoRiJudgeClient.getInstance().initialize(coreInterface)) * { * return false; * } * * if (!ElementWarClient.getInstance().initialize(coreInterface)) * { * return false; * }*/ if (!SpreadClient.getInstance().initialize(coreInterface)) { return(false); } if (!AllyClient.getInstance().initialize(coreInterface)) { return(false); } GlobalEventSource.getInstance().registerListener((int)EventTypes.PlayerLogout, getInstance()); } catch (System.Exception ex) { return(false); } return(true); }
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); }
private EAlly AllyRequest(GameClient client, int zoneID, string unionName) { EAlly result2; if (zoneID <= 0) { result2 = EAlly.EZoneID; } else if (string.IsNullOrEmpty(unionName)) { result2 = EAlly.EName; } else { int unionID = client.ClientData.Faction; if (unionID <= 0) { result2 = EAlly.EUnionJoin; } else { BangHuiDetailData myUnion = Global.GetBangHuiDetailData(-1, unionID, client.ServerId); if (myUnion == null) { result2 = EAlly.EUnionJoin; } else if (!this.IsAllyOpen(myUnion.QiLevel)) { result2 = EAlly.EUnionLevel; } else if (myUnion.ZoneID == zoneID && myUnion.BHName == unionName) { result2 = EAlly.EIsSelf; } else if (myUnion.BZRoleID != client.ClientData.RoleID) { result2 = EAlly.ENotLeader; } else if (!this.UnionMoneyIsMore(myUnion.TotalMoney)) { result2 = EAlly.EMoney; } else if (AllyClient.getInstance().UnionIsAlly(unionID, zoneID, unionName)) { result2 = EAlly.EIsAlly; } else if (AllyClient.getInstance().UnionIsRequest(unionID, zoneID, unionName)) { result2 = EAlly.EMore; } else if (AllyClient.getInstance().UnionIsAccept(unionID, zoneID, unionName)) { result2 = EAlly.EMore; } else { int countAlly = AllyClient.getInstance().AllyCount(unionID); int countRequest = AllyClient.getInstance().AllyRequestCount(unionID); if (countAlly > 0 && this.IsAllyMax(countAlly)) { result2 = EAlly.EAllyMax; } else { int countSum = countAlly + countRequest; if (countSum > 0 && this.IsAllyMax(countSum)) { result2 = EAlly.EAllyRequestMax; } else { EAlly result = AllyClient.getInstance().HAllyRequest(unionID, zoneID, unionName); if (result == EAlly.AllyRequestSucc) { int bhZoneID = 0; if (!GameManager.ClientMgr.SubBangHuiTongQian(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, this.AllyCostMoney, out bhZoneID)) { LogManager.WriteLog(LogTypes.Error, "战盟结盟 申请 扣除战盟资金失败", null, true); } } result2 = result; } } } } } return(result2); }