Beispiel #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);
            }
        }
Beispiel #2
0
        private int GetCurrentRoundByTime(DateTime now, int CurrentSeasonID)
        {
            int result;

            if (!this.CheckOpenState(now))
            {
                result = 0;
            }
            else if (!KuaFuServerManager.IsGongNengOpened(114))
            {
                result = 0;
            }
            else
            {
                lock (this.MutexConfig)
                {
                    ZorkBattleSceneInfo sceneConfig = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>();
                    if (null == sceneConfig)
                    {
                        result = 0;
                    }
                    else
                    {
                        DateTime curSeasonTime = ZorkBattleUtils.GetSeasonDateTm(CurrentSeasonID);
                        if (now < curSeasonTime)
                        {
                            result = 1;
                        }
                        else
                        {
                            TimeSpan fromMonday = new TimeSpan((int)now.DayOfWeek, now.Hour, now.Minute, now.Second);
                            if (fromMonday.Days == 0)
                            {
                                fromMonday += new TimeSpan(7, 0, 0, 0);
                            }
                            int weekRound = 0;
                            for (int i = 0; i < sceneConfig.TimePoints.Count - 1; i += 2)
                            {
                                TimeSpan myTmp = sceneConfig.TimePoints[i + 1];
                                if (myTmp.Days == 0)
                                {
                                    myTmp += new TimeSpan(7, 0, 0, 0);
                                }
                                if (fromMonday > myTmp)
                                {
                                    weekRound++;
                                }
                            }
                            int week  = (now - curSeasonTime).Days % (7 * this.SeasonWeeks) / 7;
                            int round = week * sceneConfig.TimePoints.Count / 2 + weekRound + 1;
                            result = Math.Min(round, sceneConfig.SeasonFightRound + 1);
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #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);
             }
         }
     }
 }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
0
        private void MS_PrepareGame_Update(DateTime now, int param)
        {
            ZorkBattleSceneInfo   matchConfig    = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>();
            List <KF5v5PiPeiTeam> SignUpTeamList = this.PiPeiDict.Values.ToList <KF5v5PiPeiTeam>();

            if (SignUpTeamList.Count < matchConfig.MaxEnterNum - 1)
            {
                this.StateMachine.SetCurrState(Zork5v5StateMachine.StateType.NotifyEnter, now, param);
                LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_PrepareGame_Update To:{0} SeasonID:{1} Round:{2}", Zork5v5StateMachine.StateType.NotifyEnter, this.CurrentSeasonID, this.CurrentRound), null, true);
            }
            else
            {
                List <KF5v5PiPeiTeam> TeamStandByList = new List <KF5v5PiPeiTeam>(SignUpTeamList);
                if (TeamStandByList.Count > 0)
                {
                    Random r = new Random((int)now.Ticks);
                    int    i = 0;
                    while (TeamStandByList.Count > 0 && i < TeamStandByList.Count * 2)
                    {
                        int            idx  = r.Next(0, TeamStandByList.Count);
                        int            idx2 = r.Next(0, TeamStandByList.Count);
                        KF5v5PiPeiTeam tmp  = TeamStandByList[idx];
                        TeamStandByList[idx]  = TeamStandByList[idx2];
                        TeamStandByList[idx2] = tmp;
                        i++;
                    }
                }
                int currIdx = 0;
                for (int i = 0; i < TeamStandByList.Count / matchConfig.MaxEnterNum; i++)
                {
                    int zhanduiCount = 0;
                    int side         = 0;
                    KuaFu5v5FuBenData ZorkFuBenData = new KuaFu5v5FuBenData();
                    for (int teamIdx = currIdx; teamIdx < currIdx + matchConfig.MaxEnterNum; teamIdx++)
                    {
                        KF5v5PiPeiTeam team = TeamStandByList[teamIdx];
                        if (ZorkFuBenData.AddZhanDuiWithName(team.TeamID, team.ZhanDuiName, ref zhanduiCount, ref side))
                        {
                            TianTi5v5ZhanDuiData teamData = TianTi5v5Service.GetZhanDuiData(team.TeamID);
                            if (null != teamData)
                            {
                                foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList)
                                {
                                    KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData
                                    {
                                        ServerId = team.ServerID,
                                        RoleId   = role.RoleID,
                                        Side     = side
                                    };
                                    ZorkFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID);
                                }
                            }
                        }
                    }
                    currIdx += matchConfig.MaxEnterNum;
                    this.AssginKfFuben(ZorkFuBenData);
                }
                if (currIdx > 0)
                {
                    TeamStandByList.RemoveRange(0, currIdx);
                }
                if (TeamStandByList.Count >= matchConfig.MaxEnterNum - 1)
                {
                    int zhanduiCount = 0;
                    int side         = 0;
                    KuaFu5v5FuBenData ZorkFuBenData = new KuaFu5v5FuBenData();
                    for (int i = 0; i < TeamStandByList.Count; i++)
                    {
                        KF5v5PiPeiTeam team = TeamStandByList[i];
                        if (ZorkFuBenData.AddZhanDuiWithName(team.TeamID, team.ZhanDuiName, ref zhanduiCount, ref side))
                        {
                            TianTi5v5ZhanDuiData teamData = TianTi5v5Service.GetZhanDuiData(team.TeamID);
                            if (null != teamData)
                            {
                                foreach (TianTi5v5ZhanDuiRoleData role in teamData.teamerList)
                                {
                                    KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData
                                    {
                                        ServerId = team.ServerID,
                                        RoleId   = role.RoleID,
                                        Side     = side
                                    };
                                    ZorkFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, team.TeamID);
                                }
                            }
                        }
                    }
                    this.AssginKfFuben(ZorkFuBenData);
                }
                else if (TeamStandByList.Count > 0)
                {
                    foreach (KF5v5PiPeiTeam item in TeamStandByList)
                    {
                        this.BybZhanDuiIDSet.Add(item.TeamID);
                    }
                    string zhanduiIdArray = string.Join <int>("|", this.BybZhanDuiIDSet.ToArray <int>());
                    LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::轮空 SeasonID:{0} Round:{1} zhanduiId:{2} ", this.CurrentSeasonID, this.CurrentRound, zhanduiIdArray), null, true);
                }
                this.StateMachine.SetCurrState(Zork5v5StateMachine.StateType.NotifyEnter, now, param);
                LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::MS_PrepareGame_Update To:{0} SeasonID:{1} Round:{2}", Zork5v5StateMachine.StateType.NotifyEnter, this.CurrentSeasonID, this.CurrentRound), null, true);
            }
        }
Beispiel #7
0
 public void InitConfig()
 {
     try
     {
         lock (this.MutexConfig)
         {
             DateTime.TryParse(KuaFuServerManager.systemParamsList.GetParamValueByName("ZorkStartTime"), out this.ZorkStartTime);
             this.SceneDataDict.Clear();
             string   fileName         = "Config/ZorkActivityRules.xml";
             string   fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
             XElement xml = ConfigHelper.Load(fullPathFileName);
             IEnumerable <XElement> xmlItems = xml.Elements();
             foreach (XElement node in xmlItems)
             {
                 ZorkBattleSceneInfo sceneItem = new ZorkBattleSceneInfo();
                 int id      = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID", 0L);
                 int mapCode = (int)ConfigHelper.GetElementAttributeValueLong(node, "MapCode", 0L);
                 sceneItem.Id               = id;
                 sceneItem.MapCode          = mapCode;
                 sceneItem.MaxEnterNum      = (int)ConfigHelper.GetElementAttributeValueLong(node, "MaxEnterNum", 0L);
                 sceneItem.PrepareSecs      = (int)ConfigHelper.GetElementAttributeValueLong(node, "PrepareSecs", 0L);
                 sceneItem.FightingSecs     = (int)ConfigHelper.GetElementAttributeValueLong(node, "FightingSecs", 0L);
                 sceneItem.ClearRolesSecs   = (int)ConfigHelper.GetElementAttributeValueLong(node, "ClearRolesSecs", 0L);
                 sceneItem.BattleSignSecs   = (int)ConfigHelper.GetElementAttributeValueLong(node, "BattleSignSecs", 0L);
                 sceneItem.SeasonFightRound = (int)ConfigHelper.GetElementAttributeValueLong(node, "SeasonFightDay", 0L);
                 string[] fields = node.Attribute("TimePoints").Value.Split(new char[]
                 {
                     ',',
                     '-',
                     '|'
                 });
                 for (int i = 0; i < fields.Length; i += 3)
                 {
                     TimeSpan dayPart = new TimeSpan(Convert.ToInt32(fields[i]), 0, 0, 0);
                     TimeSpan time    = DateTime.Parse(fields[i + 1]).TimeOfDay.Add(dayPart);
                     TimeSpan time2   = DateTime.Parse(fields[i + 2]).TimeOfDay.Add(dayPart);
                     sceneItem.TimePoints.Add(time);
                     sceneItem.TimePoints.Add(time2);
                 }
                 for (int i = 0; i < sceneItem.TimePoints.Count; i++)
                 {
                     TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds);
                     sceneItem.SecondsOfDay.Add(ts.TotalSeconds);
                 }
                 for (int i = 0; i < sceneItem.TimePoints.Count; i++)
                 {
                     TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds);
                     sceneItem.SecondsOfDay.Add(ts.TotalSeconds);
                 }
                 this.SceneDataDict[id] = sceneItem;
                 this.SeasonWeeks       = Math.Max(this.SeasonWeeks, (int)Math.Ceiling((double)sceneItem.SeasonFightRound / (double)(sceneItem.TimePoints.Count / 2)));
             }
             this.ZorkLevelRangeList.Clear();
             fileName         = "Config/ZorkDanAward.xml";
             fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
             xml      = ConfigHelper.Load(fullPathFileName);
             xmlItems = xml.Elements();
             foreach (XElement node in xmlItems)
             {
                 ZorkBattleAwardConfig item = new ZorkBattleAwardConfig();
                 item.ID            = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID", 0L);
                 item.RankValue     = (int)ConfigHelper.GetElementAttributeValueLong(node, "RankValue", 0L);
                 item.WinRankValue  = (int)ConfigHelper.GetElementAttributeValueLong(node, "WinRankValue", 0L);
                 item.LoseRankValue = (int)ConfigHelper.GetElementAttributeValueLong(node, "LoseRankValue", 0L);
                 this.ZorkLevelRangeList.Add(item);
                 this.ZorkLevelRangeList.Sort(delegate(ZorkBattleAwardConfig left, ZorkBattleAwardConfig righit)
                 {
                     int result;
                     if (left.ID > righit.ID)
                     {
                         result = -1;
                     }
                     else if (left.ID > righit.ID)
                     {
                         result = 1;
                     }
                     else
                     {
                         result = 0;
                     }
                     return(result);
                 });
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
     }
 }