Exemple #1
0
        public static int ZhanDuiJoin(int zhanDuiID, int jiFen, int readyNum)
        {
            DateTime now = TimeUtil.NowDateTime();
            int      result;

            if (!EscapeBattleConsts.CheckOpenState(now))
            {
                result = -11004;
            }
            else
            {
                TianTi5v5ZhanDuiData zhanDuiData = TianTi5v5Service.GetZhanDuiData(zhanDuiID);
                if (null == zhanDuiData)
                {
                    result = -4031;
                }
                else
                {
                    lock (EscapeBattle_K.Mutex)
                    {
                        EscapeBattle_K.JoinPkData joinData;
                        if (!EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out joinData))
                        {
                            joinData = new EscapeBattle_K.JoinPkData
                            {
                                ZhanDuiID = zhanDuiID
                            };
                            EscapeBattle_K.JoinDict[zhanDuiID] = joinData;
                        }
                        joinData.DuanWeiJiFen = zhanDuiData.EscapeJiFen;
                        joinData.ZhanDuiName  = zhanDuiData.ZhanDuiName;
                        joinData.ZoneId       = zhanDuiData.ZoneID;
                        joinData.ReadyNum     = readyNum;
                        if (readyNum > 0)
                        {
                            joinData.ReadyState = true;
                            joinData.State      = 2;
                        }
                        else if (readyNum == 0)
                        {
                            joinData.ReadyState = false;
                        }
                    }
                    result = 0;
                }
            }
            return(result);
        }
Exemple #2
0
        private static void ZhanDuiChangeState(EscapeBattle_K.JoinPkData pkData, int state)
        {
            int zhanDuiState = 0;

            if (state >= 5)
            {
                pkData.InGame = false;
                zhanDuiState  = 0;
            }
            pkData.State = zhanDuiState;
            int sid = KuaFuServerManager.GetServerIDFromZoneID(pkData.ZoneId);

            ClientAgentManager.Instance().SendMsg(sid, KFCallMsg.New <int[]>(KuaFuEventTypes.EscapeBattle_GameState, new int[]
            {
                pkData.ZhanDuiID,
                pkData.CurrGameID,
                zhanDuiState
            }));
        }
Exemple #3
0
 private static bool PrepareMatchList()
 {
     EscapeBattle_K.JoinList.Clear();
     foreach (EscapeBattle_K.JoinPkData item in EscapeBattle_K.JoinDict.Values.ToList <EscapeBattle_K.JoinPkData>())
     {
         if (item.ReadyState && item.ReadyNum >= EscapeBattleConsts.MinRoleNumPerGame && !item.InGame)
         {
             EscapeBattle_K.JoinList.Add(new EscapeBattle_K.JoinPkData
             {
                 ZhanDuiID    = item.ZhanDuiID,
                 ZoneId       = item.ZoneId,
                 ZhanDuiName  = item.ZhanDuiName,
                 ReadyNum     = item.ReadyNum,
                 DuanWeiJiFen = item.DuanWeiJiFen
             });
         }
     }
     if (EscapeBattle_K.JoinList.Count >= EscapeBattleConsts.MinZhanDuiNumPerGame)
     {
         EscapeBattleMatchConfig config = EscapeBattle_K._Config.MatchConfigList[0];
         EscapeBattle_K.JoinList.Sort((EscapeBattle_K.JoinPkData x, EscapeBattle_K.JoinPkData y) => x.DuanWeiJiFen - y.DuanWeiJiFen);
         List <int> notMatchList = new List <int>();
         int        needLeftNum  = EscapeBattle_K.JoinList.Count % config.MatchTeamNum;
         if (needLeftNum != 0)
         {
             int leftNum = 0;
             int rnd     = Global.GetRandomNumber(0, EscapeBattle_K.JoinList.Count);
             for (int i = rnd; i < EscapeBattle_K.JoinList.Count + rnd; i++)
             {
                 EscapeBattle_K.JoinPkData item = EscapeBattle_K.JoinList[i % EscapeBattle_K.JoinList.Count];
                 if (EscapeBattle_K.LastMatchList.Contains(item.ZhanDuiID) && !notMatchList.Contains(item.ZhanDuiID))
                 {
                     notMatchList.Add(item.ZhanDuiID);
                     leftNum++;
                     if (leftNum >= needLeftNum)
                     {
                         break;
                     }
                 }
             }
             if (leftNum < needLeftNum)
             {
                 for (int i = rnd; i < EscapeBattle_K.JoinList.Count + rnd; i++)
                 {
                     EscapeBattle_K.JoinPkData item = EscapeBattle_K.JoinList[i % EscapeBattle_K.JoinList.Count];
                     if (!EscapeBattle_K.NotMatchList.Contains(item.ZhanDuiID) && !notMatchList.Contains(item.ZhanDuiID))
                     {
                         notMatchList.Add(item.ZhanDuiID);
                         leftNum++;
                         if (leftNum >= needLeftNum)
                         {
                             break;
                         }
                     }
                 }
             }
             if (leftNum < needLeftNum)
             {
                 for (int i = rnd; i < EscapeBattle_K.JoinList.Count + rnd; i++)
                 {
                     EscapeBattle_K.JoinPkData item = EscapeBattle_K.JoinList[i % EscapeBattle_K.JoinList.Count];
                     if (!notMatchList.Contains(item.ZhanDuiID))
                     {
                         notMatchList.Add(item.ZhanDuiID);
                         leftNum++;
                         if (leftNum >= needLeftNum)
                         {
                             break;
                         }
                     }
                 }
             }
             EscapeBattle_K.JoinList.RemoveAll((EscapeBattle_K.JoinPkData x) => notMatchList.Contains(x.ZhanDuiID));
         }
         EscapeBattle_K.NotMatchList  = notMatchList;
         EscapeBattle_K.LastMatchList = EscapeBattle_K.JoinList.ConvertAll <int>((EscapeBattle_K.JoinPkData x) => x.ZhanDuiID);
         EscapeBattle_K.JoinList      = EscapeBattle_K.JoinList.RandomSortList <EscapeBattle_K.JoinPkData>();
     }
     return(true);
 }