private void MS_NotifyEnter_Update(DateTime now, int param) { ZorkBattleSceneInfo matchConfig = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>(); Zork5v5StateMachine.StateType GameState = Zork5v5StateMachine.StateType.None; for (int i = 0; i < matchConfig.TimePoints.Count - 1; i += 2) { if (now.DayOfWeek == (DayOfWeek)matchConfig.TimePoints[i].Days) { int RoundSeconds = matchConfig.BattleSignSecs + matchConfig.PrepareSecs + matchConfig.FightingSecs + matchConfig.ClearRolesSecs; int MatchPerRound = (int)(matchConfig.SecondsOfDay[i + 1] - matchConfig.SecondsOfDay[i]) / RoundSeconds; for (int matchloop = 0; matchloop < MatchPerRound; matchloop++) { int signSeconds = (int)matchConfig.SecondsOfDay[i] + RoundSeconds * matchloop; int startSeconds = signSeconds + matchConfig.BattleSignSecs; int endSeconds = startSeconds + RoundSeconds - matchConfig.BattleSignSecs; if ((double)startSeconds <= now.TimeOfDay.TotalSeconds && now.TimeOfDay.TotalSeconds < (double)endSeconds) { GameState = Zork5v5StateMachine.StateType.GameStart; } } } } if (GameState == Zork5v5StateMachine.StateType.GameStart) { foreach (KuaFu5v5FuBenData item in this.FuBenDataDict.Values) { KuaFu5v5FuBenData SyncData = item; ClientAgentManager.Instance().BroadCastAsyncEvent(this.EvItemGameType, new AsyncDataItem(KuaFuEventTypes.Zork5v5NtfEnter, new object[] { SyncData }), 0); } this.StateMachine.SetCurrState(GameState, now, param); LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_NotifyEnter_Update To:{0} SeasonID:{1} Round:{2}", GameState, this.CurrentSeasonID, this.CurrentRound), null, true); } }
private static void UpDateTick(object sender) { try { char[] ChArray = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'W', 'V', 'U', 'X', 'Y', 'Z' }; string str = ""; for (int i = 0; i < (int)sender; i++) { str += ChArray[i % ChArray.Length]; } long allnum = 0L; long sunum = 0L; while (TestS2KFCommunication.Flag) { allnum += 1L; if (allnum > 50000L) { break; } try { ClientAgentManager.Instance().BroadCastMsg(KFCallMsg.New <string>(KuaFuEventTypes.Test, str), 0); sunum += 1L; } catch (Exception ex) { LogManager.WriteException(ex.ToString()); Console.WriteLine("UpDateTick Exception"); } } Console.WriteLine(string.Format("发送allnum={0}, sunum={1}", allnum - 1L, sunum)); } catch (Exception ex) { LogManager.WriteException(ex.ToString()); Console.WriteLine("UpDateTick Exception"); } }
public static bool AssignGameFuben(KF5v5PiPeiTeam kuaFuRoleData, RangeKey range, DateTime now) { int roleCount = 0; DateTime stateEndTime = now.AddSeconds((double)TianTi5v5Service.EnterGameSecs); List <KuaFuFuBenRoleData> updateRoleDataList = new List <KuaFuFuBenRoleData>(); KuaFu5v5FuBenData KuaFu5v5FuBenData = new KuaFu5v5FuBenData(); int side = 0; int removeZhanDuiIDFromPiPeiList = 0; KF5v5PiPeiTeam team = kuaFuRoleData; if (Consts.TianTiRoleCountTotal > 1) { foreach (Tuple <KF5v5PiPeiTeam, int, int, int> z in TianTi5v5Service.ProcessPiPeiList) { if (z.Item2 >= range.Left && z.Item2 <= range.Right) { if (kuaFuRoleData.GroupIndex >= z.Item3 && kuaFuRoleData.GroupIndex <= z.Item4) { if (TianTi5v5Service.CanAddFuBenRole(kuaFuRoleData.TeamID, z.Item1.TeamID)) { removeZhanDuiIDFromPiPeiList = z.Item1.TeamID; team = z.Item1; if (KuaFu5v5FuBenData.AddZhanDui(team.TeamID, ref roleCount, ref side)) { TianTi5v5ZhanDuiData teamData; if (TianTi5v5Service.ZhanDuiDict.TryGetValue(team.TeamID, out teamData)) { foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList) { KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData { ServerId = team.ServerID, RoleId = role.RoleID, Side = side }; KuaFu5v5FuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID); } } } } } } } if (removeZhanDuiIDFromPiPeiList == 0) { TianTi5v5Service.ProcessPiPeiList.Add(new Tuple <KF5v5PiPeiTeam, int, int, int>(kuaFuRoleData, kuaFuRoleData.GroupIndex, range.Left, range.Right)); return(true); } TianTi5v5Service.ProcessPiPeiList.RemoveAll((Tuple <KF5v5PiPeiTeam, int, int, int> x) => x.Item1.TeamID == removeZhanDuiIDFromPiPeiList); TianTi5v5Service.ProcessPiPeiList.RemoveAll((Tuple <KF5v5PiPeiTeam, int, int, int> x) => x.Item1.TeamID == kuaFuRoleData.TeamID); } team = kuaFuRoleData; if (KuaFu5v5FuBenData.AddZhanDui(team.TeamID, ref roleCount, ref side)) { TianTi5v5ZhanDuiData teamData; if (TianTi5v5Service.ZhanDuiDict.TryGetValue(team.TeamID, out teamData)) { foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList) { KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData { ServerId = team.ServerID, RoleId = role.RoleID, Side = side }; KuaFu5v5FuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID); } } } try { int kfSrvId = 0; int gameId = TianTi5v5Service.Persistence.GetNextGameId(); bool createSuccess = ClientAgentManager.Instance().AssginKfFuben(TianTi5v5Service.GameType, (long)gameId, roleCount, out kfSrvId); if (createSuccess) { KuaFu5v5FuBenData.ServerId = kfSrvId; KuaFu5v5FuBenData.GameId = gameId; KuaFu5v5FuBenData.GameType = (int)TianTi5v5Service.GameType; KuaFu5v5FuBenData.EndTime = Global.NowTime.AddMinutes(8.0); KuaFu5v5FuBenData.LoginInfo = KuaFuServerManager.GetKuaFuLoginInfo(kuaFuRoleData.ServerID, kfSrvId); TianTi5v5Service.AddGameFuBen(KuaFu5v5FuBenData); TianTi5v5Service.Persistence.LogCreateTianTiFuBen(KuaFu5v5FuBenData.GameId, KuaFu5v5FuBenData.ServerId, 0, roleCount); foreach (int zhanDuiID in KuaFu5v5FuBenData.ZhanDuiDict.Keys) { KF5v5PiPeiTeam kuaFuRoleDataTemp; if (TianTi5v5Service.PiPeiDict.TryGetValue(zhanDuiID, out kuaFuRoleDataTemp)) { kuaFuRoleDataTemp.State = 3; kuaFuRoleDataTemp.StateEndTicks = stateEndTime.Ticks; kuaFuRoleDataTemp.GameId = KuaFu5v5FuBenData.GameId; } } KuaFu5v5FuBenData.State = GameFuBenState.Start; TianTi5v5Service.NotifyFuBenRoleEnterGame(KuaFu5v5FuBenData); TianTi5v5Service.AddRolePairFightCount(KuaFu5v5FuBenData); return(true); } return(false); } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(false); }
public void KFSendStageData() { ClientAgentManager.Instance().BroadCastMsg(KFCallMsg.New <KFStageData>(KuaFuEventTypes.BoCaiStageChange, this.GetKFStageData()), 0); }
public void KFSendPeriodsData() { ClientAgentManager.Instance().BroadCastMsg(KFCallMsg.New <OpenLottery>(KuaFuEventTypes.BoCaiPeriodsData, this.GetOpenLottery()), 0); }
private static bool CreateGameFuBen(DateTime now, params EscapeBattle_K.JoinPkData[] joinArr) { for (int side = 1; side <= joinArr.Length; side++) { joinArr[side - 1].Side = side; if (joinArr[side - 1].InGame) { return(true); } } int toServerId = 0; int gameId = TianTiPersistence.Instance.GetNextGameId(); if (ClientAgentManager.Instance().AssginKfFuben(EscapeBattle_K.GameType, (long)gameId, 10, out toServerId)) { EscapeBattleFuBenData copyData = new EscapeBattleFuBenData(); copyData.GameID = (long)gameId; copyData.ServerID = toServerId; EscapeBattleNtfEnterData data = new EscapeBattleNtfEnterData(); data.ToServerId = toServerId; data.GameId = gameId; EscapeBattlePkLogData log = new EscapeBattlePkLogData(); log.Season = EscapeBattle_K.SyncData.Season; log.StartTime = now; log.GameID = gameId; log.ToServerID = toServerId; EscapeBattleMatchConfig config = EscapeBattle_K._Config.MatchConfigList[0]; log.EndTime = now.AddSeconds((double)config.TotalSecs); foreach (EscapeBattle_K.JoinPkData joinRole in joinArr) { copyData.SideDict[(long)joinRole.ZhanDuiID] = joinRole.Side; copyData.RoleDict.AddRange(TianTi5v5Service.GetZhanDuiMemberIDs(joinRole.ZhanDuiID)); joinRole.ToServerID = toServerId; joinRole.CurrGameID = gameId; joinRole.CopyData = copyData; joinRole.InGame = true; data.ZhanDuiIDList.Add(joinRole.ZhanDuiID); log.ZhanDuiIDs.Add(joinRole.ZhanDuiID); log.ZoneIDs.Add(joinRole.ZoneId); log.ZhanDuiNames.Add(joinRole.ZhanDuiName); EscapeBattle_K.JoinPkData zhandui; if (EscapeBattle_K.JoinDict.TryGetValue(joinRole.ZhanDuiID, out zhandui)) { zhandui.InGame = true; zhandui.CurrGameID = gameId; zhandui.Side = joinRole.Side; zhandui.ToServerID = toServerId; zhandui.CopyData = copyData; zhandui.State = 3; zhandui.ReadyState = false; zhandui.ReadyNum = 0; } } EscapeBattle_K.AsyncEvQ.Enqueue(KFCallMsg.New <EscapeBattleNtfEnterData>(KuaFuEventTypes.EscapeBattle_NotifyEnter, data)); EscapeBattle_K.ThisLoopPkLogs[gameId] = log; if (!EscapeBattle_K.NeedUpdateRank) { EscapeBattle_K.NeedUpdateRank = true; } LogManager.WriteLog(LogTypes.Trace, string.Format("大逃杀第{0}赛季战队成员通知入场,GameID={1},zhanduiIDs={2}", EscapeBattle_K.SyncData.Season, data.GameId, string.Join <int>(",", log.ZhanDuiIDs)), null, true); return(true); } LogManager.WriteLog(LogTypes.Warning, string.Format("大逃杀第{0}赛季分配游戏服务器失败", EscapeBattle_K.SyncData.Season), null, true); return(false); }
private static bool CreateGameFuBen(DateTime now, ZhanDuiZhengBaMatchConfig matchConfig, ZhanDuiZhengBa_K.JoinRolePkData joinRole1, ZhanDuiZhengBa_K.JoinRolePkData joinRole2) { bool result; if (joinRole1.CurrGameID > 0) { result = true; } else { int betterZhanDuiID = (joinRole1.Rank < joinRole2.Rank) ? joinRole1.ZhanDuiID : joinRole2.ZhanDuiID; int toServerId = 0; int gameId = TianTiPersistence.Instance.GetNextGameId(); if (ClientAgentManager.Instance().AssginKfFuben(ZhanDuiZhengBa_K.GameType, (long)gameId, 10, out toServerId)) { ZhanDuiZhengBaFuBenData copyData = new ZhanDuiZhengBaFuBenData(); copyData.GameID = (long)gameId; copyData.SideDict[(long)joinRole1.ZhanDuiID] = 1; copyData.SideDict[(long)joinRole2.ZhanDuiID] = 2; copyData.BetterZhanDuiID = betterZhanDuiID; copyData.ConfigID = matchConfig.ID; copyData.JoinGrade = (int)matchConfig.JoinGrade; copyData.NewGrade = (int)matchConfig.WillUpGrade; copyData.ServerID = toServerId; copyData.RoleDict.AddRange(TianTi5v5Service.GetZhanDuiMemberIDs(joinRole1.ZhanDuiID)); if (joinRole1.ZhanDuiID != joinRole2.ZhanDuiID) { copyData.RoleDict.AddRange(TianTi5v5Service.GetZhanDuiMemberIDs(joinRole2.ZhanDuiID)); } joinRole1.ToServerID = (joinRole2.ToServerID = toServerId); joinRole1.CurrGameID = (joinRole2.CurrGameID = gameId); joinRole1.CopyData = (joinRole2.CopyData = copyData); joinRole1.WaitReqEnter = (joinRole2.WaitReqEnter = true); ZhanDuiZhengBaNtfEnterData data = new ZhanDuiZhengBaNtfEnterData(); data.ZhanDuiID1 = joinRole1.ZhanDuiID; data.ZhanDuiID2 = joinRole2.ZhanDuiID; data.ToServerId = toServerId; data.GameId = gameId; data.Day = ZhanDuiZhengBa_K.SyncData.RealActID; ZhanDuiZhengBa_K.AsyncEvQ.Enqueue(KFCallMsg.New <ZhanDuiZhengBaNtfEnterData>(KuaFuEventTypes.ZhanDuiZhengBa_NotifyEnter, data)); LogManager.WriteLog(LogTypes.Info, string.Format("战队争霸第{0}轮战队成员通知入场,zhanduiID1={1},zhanduiID2={2}", ZhanDuiZhengBa_K.SyncData.RealActID, joinRole1.ZhanDuiID, joinRole2.ZhanDuiID), null, true); ZhanDuiZhengBaPkLogData log = new ZhanDuiZhengBaPkLogData(); log.Month = ZhanDuiZhengBa_K.SyncData.Month; log.ID = ZhanDuiZhengBa_K.SyncData.RealActID; log.ZhanDuiID1 = joinRole1.ZhanDuiID; log.ZoneID1 = joinRole1.ZoneId; log.ZhanDuiName1 = joinRole1.RoleName; log.ZhanDuiID2 = joinRole2.ZhanDuiID; log.ZoneID2 = joinRole2.ZoneId; log.ZhanDuiName2 = joinRole2.RoleName; log.StartTime = now; log.BetterZhanDuiID = betterZhanDuiID; log.GameID = (long)gameId; ZhanDuiZhengBa_K.ThisLoopPkLogs[gameId] = log; result = true; } else { LogManager.WriteLog(LogTypes.Error, string.Format("战队争霸第{0}轮分配游戏服务器失败,zhanduiID1={1},zhanduiID2={2}", ZhanDuiZhengBa_K.SyncData.RealActID, joinRole1.ZhanDuiID, joinRole2.ZhanDuiID), null, true); result = false; } } return(result); }
public static void TimerProc() { ClientAgentManager.Instance().SendAsyncKuaFuMsg(); }