Beispiel #1
0
        public static int ZhanDuiRoleChangeState(int serverId, int zhanDuiID, int roleId, int state, int gameID)
        {
            KF5v5PiPeiTeam piPeiTeam;

            if (TianTi5v5Service.PiPeiDict.TryGetValue(zhanDuiID, out piPeiTeam))
            {
                if (state == 6 || state == 0)
                {
                    int oldGameId = 0;
                    lock (piPeiTeam)
                    {
                        oldGameId               = piPeiTeam.GameId;
                        piPeiTeam.GameId        = 0;
                        piPeiTeam.State         = 0;
                        piPeiTeam.ServerID      = serverId;
                        piPeiTeam.StateEndTicks = Global.NowTime.Ticks;
                    }
                    if (oldGameId > 0)
                    {
                        TianTi5v5Service.RemoveRoleFromFuBen(oldGameId, zhanDuiID);
                    }
                }
            }
            return(0);
        }
Beispiel #2
0
        public bool ReloadRankInfo(int rankType, KuaFuData <Dictionary <int, List <KFZorkRankInfo> > > ZorkBattleRankInfoDict)
        {
            bool ret = true;
            List <KFZorkRankInfo> rankList = new List <KFZorkRankInfo>();

            if (!ZorkBattleRankInfoDict.V.TryGetValue(rankType, out rankList))
            {
                rankList = (ZorkBattleRankInfoDict.V[rankType] = new List <KFZorkRankInfo>());
            }
            else
            {
                rankList.Clear();
            }
            try
            {
                if (rankType == 0)
                {
                    TianTi5v5Service.CalZorkBattleRankTeamJiFen(rankList);
                }
                else
                {
                    ret = this.Persistence.LoadZorkBattleRankInfo(rankType, rankList);
                }
                TimeUtil.AgeByNow(ref ZorkBattleRankInfoDict.Age);
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
                return(false);
            }
            return(ret);
        }
Beispiel #3
0
        public static int ZhanDuiRoleSignUp(int serverId, int gameType, int zhanDuiID, long zhanLi = 1L, int groupIndex = 1)
        {
            int result = 1;
            Lazy <KF5v5PiPeiTeam> lazy = new Lazy <KF5v5PiPeiTeam>(() => new KF5v5PiPeiTeam
            {
                TeamID        = zhanDuiID,
                GroupIndex    = groupIndex,
                ServerID      = serverId,
                ZhanDouLi     = zhanLi,
                StateEndTicks = TimeUtil.NOW()
            });
            KF5v5PiPeiTeam piPeiTeam = TianTi5v5Service.PiPeiDict.GetOrAdd(zhanDuiID, (int x) => lazy.Value);
            int            oldGameId = 0;

            lock (piPeiTeam)
            {
                oldGameId               = piPeiTeam.GameId;
                piPeiTeam.GameId        = 0;
                piPeiTeam.State         = 1;
                piPeiTeam.ServerID      = serverId;
                piPeiTeam.ZhanDouLi     = zhanLi;
                piPeiTeam.GroupIndex    = groupIndex;
                piPeiTeam.StateEndTicks = Global.NowTime.Ticks;
                int rndSecs = Global.GetRandomNumber(0, 10);
                LogManager.WriteLog(LogTypes.Info, string.Format("组队竞技战队随机延时,zhanduiid={0}, duanwei={1},time={2}", zhanDuiID, groupIndex, rndSecs), null, true);
            }
            if (oldGameId > 0)
            {
                TianTi5v5Service.RemoveRoleFromFuBen(oldGameId, zhanDuiID);
            }
            return(result);
        }
Beispiel #4
0
        public static bool InitConfig()
        {
            TianTi5v5Service.RankData.MaxPaiMingRank = 201;
            try
            {
                string   fileName         = "Config/TeamDuanWeiAward.xml";
                string   fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
                XElement xml = ConfigHelper.Load(fullPathFileName);
                IEnumerable <XElement> nodes = xml.Elements();
                foreach (XElement node in nodes)
                {
                    int StarRank = (int)ConfigHelper.GetElementAttributeValueLong(node, "StarRank", 201L);
                    TianTi5v5Service.RankData.MaxPaiMingRank = Math.Max(TianTi5v5Service.RankData.MaxPaiMingRank, StarRank);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteException(ex.ToString());
            }
            Dictionary <int, TianTi5v5ZhanDuiData> dict = new Dictionary <int, TianTi5v5ZhanDuiData>();

            lock (TianTi5v5Service.Mutex)
            {
                TianTi5v5Service.LoadZhanDuiRankData(TianTi5v5Service.RankData, TimeUtil.NowDateTime());
                if (!TianTi5v5Service.Persistence.LoadZhanDuiData(dict))
                {
                    return(false);
                }
                TianTi5v5Service.ZhanDuiDict = dict;
            }
            TianTi5v5Service.pTianTiPiPeiCfg = new List <TianTi5v5Service.PiPeiCfg>
            {
                new TianTi5v5Service.PiPeiCfg
                {
                    ID      = 0,
                    MinTime = 0,
                    MaxTime = 5
                },
                new TianTi5v5Service.PiPeiCfg
                {
                    ID      = 1,
                    MinTime = 5,
                    MaxTime = 10
                },
                new TianTi5v5Service.PiPeiCfg
                {
                    ID      = 3,
                    MinTime = 10,
                    MaxTime = 15
                },
                new TianTi5v5Service.PiPeiCfg
                {
                    ID      = 25,
                    MinTime = 15,
                    MaxTime = 60
                }
            };
            return(true);
        }
Beispiel #5
0
        public int GameFuBenComplete_ZorkBattle(ZorkBattleStatisticalData data)
        {
            int result = 0;

            try
            {
                lock (this.Mutex)
                {
                    KuaFu5v5FuBenData fubenData;
                    if (!this.FuBenDataDict.TryGetValue(data.GameId, out fubenData))
                    {
                        result = -4000;
                        return(result);
                    }
                    ClientAgentManager.Instance().RemoveKfFuben(this.GameType, fubenData.ServerId, (long)data.GameId);
                    this.FuBenDataDict.Remove(data.GameId);
                    foreach (KeyValuePair <int, int> item in fubenData.ZhanDuiDict)
                    {
                        this.ZhanDuiIDVsGameIDDict.Remove(item.Key);
                    }
                    foreach (KeyValuePair <int, TianTi5v5ZhanDuiData> item2 in data.ZhanDuiDict)
                    {
                        TianTi5v5ZhanDuiData zhanduiData = item2.Value;
                        TianTi5v5Service.UpdateZorkZhanDuiData(zhanduiData);
                    }
                    foreach (ZorkBattleRoleInfo client in data.ClientContextDataList)
                    {
                        this.Persistence.UpdateZorkBattleRoleData(client, true);
                    }
                    string zhanduiIdArray = string.Join <int>("|", data.ZhanDuiDict.Keys.ToArray <int>());
                    string strLog         = string.Format("Zork::GameFuBenComplete_ZorkBattle SeasonID:{0} GameID:{1} ZhanDuiIDWin:{2} ZhanDuiID:{3} Round:{2} ZhanDuiInfo:", new object[]
                    {
                        this.CurrentSeasonID,
                        data.GameId,
                        data.ZhanDuiIDWin,
                        zhanduiIdArray,
                        this.CurrentRound
                    });
                    foreach (KeyValuePair <int, TianTi5v5ZhanDuiData> item2 in data.ZhanDuiDict)
                    {
                        TianTi5v5ZhanDuiData zhanduiData = item2.Value;
                        strLog += string.Format(" [ZhanDuiID:{0} JiFen:{1}]", item2.Key, zhanduiData.ZorkJiFen);
                    }
                    LogManager.WriteLog(LogTypes.Analysis, strLog, null, true);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result = -11;
                LogManager.WriteLog(LogTypes.Error, "Zork5v5Service.GameFuBenComplete_ZorkBattle failed!", ex, true);
            }
            return(result);
        }
Beispiel #6
0
 private void UpdateTopZhanDuiInfo()
 {
     this.TopZhanDuiName = "";
     if (this.TopZhanDui > 0)
     {
         TianTi5v5ZhanDuiData zhanduiData = TianTi5v5Service.GetZhanDuiData(this.TopZhanDui);
         if (null != zhanduiData)
         {
             this.TopZhanDuiName = KuaFuServerManager.FormatName(zhanduiData.ZoneID, zhanduiData.ZhanDuiName);
         }
     }
 }
Beispiel #7
0
        public int SignUp_ZorkBattle(int zhanduiID, int serverID)
        {
            int result = 0;

            try
            {
                lock (this.Mutex)
                {
                    DateTime now = TimeUtil.NowDateTime();
                    if (!this.CheckOpenState(now))
                    {
                        result = -11004;
                        return(result);
                    }
                    if (this.StateMachine.GetCurrState() != Zork5v5StateMachine.StateType.SignUp && this.StateMachine.GetCurrState() != Zork5v5StateMachine.StateType.RankAnalyse)
                    {
                        result = -2001;
                        return(result);
                    }
                    TianTi5v5ZhanDuiData zhanduiData = TianTi5v5Service.GetZhanDuiData(zhanduiID);
                    if (null == zhanduiData)
                    {
                        result = -5;
                        return(result);
                    }
                    if (this.PiPeiDict.ContainsKey(zhanduiID))
                    {
                        result = -5;
                        return(result);
                    }
                    KF5v5PiPeiTeam pipeiTeam = new KF5v5PiPeiTeam
                    {
                        TeamID      = zhanduiID,
                        ServerID    = serverID,
                        GroupIndex  = this.CalDuanWeiByJiFen(zhanduiData.ZorkJiFen),
                        ZhanDouLi   = zhanduiData.ZhanDouLi,
                        ZorkJiFen   = zhanduiData.ZorkJiFen,
                        ZhanDuiName = KuaFuServerManager.FormatName(zhanduiData.ZoneID, zhanduiData.ZhanDuiName)
                    };
                    this.PiPeiDict[zhanduiID] = pipeiTeam;
                    LogManager.WriteLog(LogTypes.Analysis, string.Format("Zork::比赛报名 SeasonID:{0} Round:{1} ZhanDuiID:{2}", this.CurrentSeasonID, this.CurrentRound, zhanduiID), null, true);
                }
                return(result);
            }
            catch (Exception ex)
            {
                result = -11;
                LogManager.WriteLog(LogTypes.Error, "Zork5v5Service.SignUp_ZorkBattle failed!", ex, true);
            }
            return(result);
        }
Beispiel #8
0
 public static void RemoveRoleFromFuBen(int gameId, int zhanDuiID)
 {
     if (gameId > 0)
     {
         KuaFu5v5FuBenData fuBenData;
         if (TianTi5v5Service.FuBenDataDict.TryGetValue(gameId, out fuBenData))
         {
             lock (fuBenData)
             {
                 fuBenData.State = GameFuBenState.End;
                 int count = fuBenData.RemoveKuaFuFuBenZhanDui(zhanDuiID);
                 if (fuBenData.CanRemove())
                 {
                     TianTi5v5Service.RemoveGameFuBen(fuBenData);
                 }
             }
         }
     }
 }
Beispiel #9
0
        public static int UpdateEscapeZhanDui(int zhanDuiID, int jiFen, DateTime fightTime)
        {
            TianTi5v5ZhanDuiData zhanDuiData = TianTi5v5Service.GetZhanDuiData(zhanDuiID);
            int result;

            if (zhanDuiData != null)
            {
                if (jiFen != -2147483648)
                {
                    zhanDuiData.EscapeJiFen = jiFen;
                }
                zhanDuiData.EscapeLastFightTime = fightTime;
                TianTi5v5Service.Persistence.UpdateEscapeZhanDui(zhanDuiData);
                result = zhanDuiData.EscapeJiFen;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Beispiel #10
0
 private static void CheckGameFuBenTimerProc(DateTime now)
 {
     if (TianTi5v5Service.FuBenDataDict.Count > 0)
     {
         DateTime canRemoveTime = now.AddMinutes(-40.0);
         foreach (KuaFu5v5FuBenData fuBenData in TianTi5v5Service.FuBenDataDict.Values)
         {
             lock (fuBenData)
             {
                 if (fuBenData.CanRemove())
                 {
                     TianTi5v5Service.RemoveGameFuBen(fuBenData);
                 }
                 else if (fuBenData.EndTime < canRemoveTime)
                 {
                     TianTi5v5Service.RemoveGameFuBen(fuBenData);
                 }
             }
         }
     }
 }
Beispiel #11
0
 public static void ThreadProc(object state)
 {
     if (TianTi5v5Service.ThreadInit)
     {
         try
         {
             DateTime now = TimeUtil.NowDateTime();
             Global.UpdateNowTime(now);
             if (now > TianTi5v5Service.CheckRoleTimerProcTime)
             {
                 TianTi5v5Service.CheckRoleTimerProcTime = now.AddSeconds(1.428);
                 int signUpCnt;
                 int startCnt;
                 TianTi5v5Service.CheckRoleTimerProc(now, out signUpCnt, out startCnt);
                 ClientAgentManager.Instance().SetGameTypeLoad(TianTi5v5Service.GameType, signUpCnt, startCnt);
             }
             if (now > TianTi5v5Service.SaveServerStateProcTime)
             {
                 TianTi5v5Service.SaveServerStateProcTime = now.AddSeconds(30.0);
                 if (now.Hour >= 3 && now.Hour < 4)
                 {
                     TianTi5v5Service.ClearRolePairFightCount();
                     TianTi5v5Service.UpdateZhanDuiRankData(now, false);
                     ZhanDuiZhengBa_K.LoadSyncData(now, false);
                 }
             }
             if (now > TianTi5v5Service.CheckGameFuBenTime)
             {
                 TianTi5v5Service.CheckGameFuBenTime = now.AddSeconds(1000.0);
                 TianTi5v5Service.CheckGameFuBenTimerProc(now);
             }
             TianTi5v5Service.Persistence.DelayWriteDataProc();
         }
         catch (Exception ex)
         {
             LogManager.WriteExceptionUseCache(ex.ToString());
         }
     }
 }
Beispiel #12
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 #13
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 #14
0
        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);
        }
Beispiel #15
0
        private static void CheckRoleTimerProc(DateTime now, out int signUpCnt, out int startCount)
        {
            signUpCnt  = 0;
            startCount = 0;
            bool assgionGameFuBen   = true;
            long maxRemoveRoleTicks = now.AddHours(-1.0).Ticks;
            long waitTicks          = now.AddSeconds((double)(-(double)TianTi5v5Service.Persistence.SignUpWaitSecs1)).Ticks;
            long waitTicks2         = now.AddSeconds((double)(-(double)TianTi5v5Service.Persistence.SignUpWaitSecs3)).Ticks;
            long waitTicksAll       = now.AddSeconds((double)(-(double)TianTi5v5Service.Persistence.SignUpWaitSecsAll)).Ticks;
            long waitTicksMax       = now.AddSeconds((double)(-(double)TianTi5v5Service.Persistence.WaitForJoinMaxSecs)).Ticks;

            TianTi5v5Service.ProcessPiPeiList.Clear();
            List <int> removeList = new List <int>();

            foreach (KF5v5PiPeiTeam kuaFuRoleData in TianTi5v5Service.PiPeiDict.Values)
            {
                int oldGameId = 0;
                lock (kuaFuRoleData)
                {
                    if (kuaFuRoleData.State == 0 || kuaFuRoleData.State > 5)
                    {
                        if (kuaFuRoleData.StateEndTicks < maxRemoveRoleTicks)
                        {
                            kuaFuRoleData.State = 0;
                            removeList.Add(kuaFuRoleData.TeamID);
                            continue;
                        }
                    }
                    else if (kuaFuRoleData.State == 3 || kuaFuRoleData.State == 4)
                    {
                        if (kuaFuRoleData.StateEndTicks < now.Ticks)
                        {
                            kuaFuRoleData.State = 0;
                            removeList.Add(kuaFuRoleData.TeamID);
                            oldGameId = kuaFuRoleData.GameId;
                        }
                    }
                    else if (kuaFuRoleData.State == 1)
                    {
                        if (kuaFuRoleData.StateEndTicks < waitTicksMax)
                        {
                            kuaFuRoleData.State = 0;
                            removeList.Add(kuaFuRoleData.TeamID);
                            continue;
                        }
                    }
                }
                if (kuaFuRoleData.State == 1)
                {
                    signUpCnt++;
                    if (assgionGameFuBen)
                    {
                        RangeKey range = TianTi5v5Service.GetAssignRange(kuaFuRoleData.GroupIndex, kuaFuRoleData.StateEndTicks, waitTicks, waitTicks2, waitTicksAll);
                        assgionGameFuBen = TianTi5v5Service.AssignGameFuben(kuaFuRoleData, range, now);
                    }
                }
                else if (kuaFuRoleData.State == 2)
                {
                    signUpCnt++;
                }
                else if (kuaFuRoleData.State == 5)
                {
                    startCount++;
                }
                if (oldGameId > 0)
                {
                    TianTi5v5Service.RemoveRoleFromFuBen(oldGameId, kuaFuRoleData.TeamID);
                }
            }
            foreach (int id in removeList)
            {
                KF5v5PiPeiTeam kuaFuRoleDataTemp;
                if (TianTi5v5Service.PiPeiDict.TryRemove(id, out kuaFuRoleDataTemp))
                {
                    if (kuaFuRoleDataTemp.State == 1)
                    {
                        TianTi5v5Service.PiPeiDict.TryAdd(id, kuaFuRoleDataTemp);
                    }
                }
            }
        }