Пример #1
0
        private void MS_GameStart_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 (this.LastUpdateTime.TimeOfDay.TotalSeconds < (double)endSeconds && (double)endSeconds <= now.TimeOfDay.TotalSeconds)
                        {
                            GameState = Zork5v5StateMachine.StateType.RankAnalyse;
                        }
                    }
                }
            }
            if (GameState == Zork5v5StateMachine.StateType.RankAnalyse)
            {
                this.StateMachine.SetCurrState(GameState, now, param);
                LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_GameStart_Update To:{0} SeasonID:{1} Round:{2}", GameState, this.CurrentSeasonID, this.CurrentRound), null, true);
            }
        }
Пример #2
0
 public StateHandler(Zork5v5StateMachine.StateType state, Action <DateTime, int> enter, Action <DateTime, int> updater, Action <DateTime, int> leaver)
 {
     this.State        = state;
     this.enterAction  = enter;
     this.updateAction = updater;
     this.leaveAction  = leaver;
 }
Пример #3
0
 private void MS_Init_Update(DateTime now, int param)
 {
     if (this.CheckOpenState(now))
     {
         if (KuaFuServerManager.IsGongNengOpened(114))
         {
             ZorkBattleSceneInfo           matchConfig = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>();
             Zork5v5StateMachine.StateType GameState   = Zork5v5StateMachine.StateType.Init;
             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 (now.TimeOfDay.TotalSeconds >= (double)signSeconds && now.TimeOfDay.TotalSeconds < (double)startSeconds)
                         {
                             GameState = Zork5v5StateMachine.StateType.SignUp;
                         }
                         else if (now.TimeOfDay.TotalSeconds >= (double)startSeconds && now.TimeOfDay.TotalSeconds < (double)endSeconds)
                         {
                             GameState = Zork5v5StateMachine.StateType.GameStart;
                         }
                     }
                 }
             }
             if (this.CurrentSeasonID > 0)
             {
                 if (this.CurrentSeasonID != this.ComputeCurrentSeasonID(now, this.CurrentSeasonID))
                 {
                     GameState = Zork5v5StateMachine.StateType.RankAnalyse;
                 }
             }
             else
             {
                 this.CurrentSeasonID = this.ComputeCurrentSeasonID(now, this.CurrentSeasonID);
                 this.Persistence.SaveZorkSeasonID(this.CurrentSeasonID);
                 this.CurrentRound = this.GetCurrentRoundByTime(now, this.CurrentSeasonID);
             }
             if (GameState != Zork5v5StateMachine.StateType.Init)
             {
                 this.StateMachine.SetCurrState(GameState, now, param);
                 LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_Init_Update To:{0} SeasonID:{1} Round:{2}", GameState, this.CurrentSeasonID, this.CurrentRound), null, true);
             }
         }
     }
 }
Пример #4
0
 public void SetCurrState(Zork5v5StateMachine.StateType state, DateTime now, int param)
 {
     Zork5v5StateMachine.StateHandler oldHandler = this.Handlers[(int)this._CurrState];
     if (oldHandler != null)
     {
         oldHandler.Leave(now, param);
     }
     this._CurrState = state;
     Zork5v5StateMachine.StateHandler newHandler = this.Handlers[(int)this._CurrState];
     this._CurrStateEnterTicks = now.Ticks;
     if (newHandler != null)
     {
         newHandler.Enter(now, param);
     }
 }
Пример #5
0
        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);
            }
        }
Пример #6
0
        private void MS_RankAnalyse_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;
                        int analyseSeconds = endSeconds + matchConfig.BattleSignSecs / 2;
                        if (this.LastUpdateTime.TimeOfDay.TotalSeconds < (double)analyseSeconds && (double)analyseSeconds <= now.TimeOfDay.TotalSeconds)
                        {
                            if (now.TimeOfDay.TotalSeconds > matchConfig.SecondsOfDay[i + 1])
                            {
                                GameState = Zork5v5StateMachine.StateType.Init;
                            }
                            else
                            {
                                GameState = Zork5v5StateMachine.StateType.SignUp;
                            }
                        }
                    }
                }
            }
            int CalSeasonID = this.ComputeCurrentSeasonID(now, this.CurrentSeasonID);

            if (this.CurrentSeasonID != CalSeasonID)
            {
                GameState = Zork5v5StateMachine.StateType.Init;
            }
            if (Zork5v5StateMachine.StateType.None != GameState)
            {
                this.HandleUnCompleteFuBenData();
                if (this.CurrentSeasonID != CalSeasonID)
                {
                    this.Persistence.SaveZorkSeasonID(this.CurrentSeasonID);
                    this.CurrentSeasonID = CalSeasonID;
                    TianTi5v5Service.ClearAllZhanDuiZorkData();
                    this.ZorkBattleRankInfoDict.V.Clear();
                    TimeUtil.AgeByNow(ref this.ZorkBattleRankInfoDict.Age);
                }
                else
                {
                    this.ReloadRankInfo(0, this.ZorkBattleRankInfoDict);
                    this.ReloadRankInfo(1, this.ZorkBattleRankInfoDict);
                }
                this.CurrentRound = this.GetCurrentRoundByTime(now, this.CurrentSeasonID);
                ZorkBattleSceneInfo sceneConfig = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>();
                if (this.CurrentRound > sceneConfig.SeasonFightRound)
                {
                    List <KFZorkRankInfo> rankList;
                    if (this.ZorkBattleRankInfoDict.V.TryGetValue(0, out rankList) && rankList.Count != 0)
                    {
                        this.TopZhanDui = rankList[0].Key;
                    }
                    else
                    {
                        this.TopZhanDui = 0;
                    }
                    this.Persistence.SaveZorkTopZhanDui(this.TopZhanDui);
                    this.UpdateTopZhanDuiInfo();
                    if (this.ZorkBattleRankInfoDict.V.TryGetValue(1, out rankList) && rankList.Count != 0)
                    {
                        this.TopKiller = rankList[0].Key;
                    }
                    else
                    {
                        this.TopKiller = 0;
                    }
                    this.Persistence.SaveZorkTopKiller(this.TopKiller);
                }
                this.StateMachine.SetCurrState(GameState, now, param);
                LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_RankAnalyse_Update To:{0} SeasonID:{1} Round:{2}", GameState, this.CurrentSeasonID, this.CurrentRound), null, true);
            }
        }