// 玩家准备完毕; public void ReadyPlayer(Player player) { int index = mNotReady.IndexOf(player); if (index < 0) { return; } mNotReady.RemoveAt(index); ReqMatch msg = new ReqMatch(); msg.UserID = player.mUserID; for (int i = 0; i < mPlayers.Count; ++i) { Player p = mPlayers[i]; // 更新客户端的Ready标志; NetWork.NotifyMessage <ReqMatch>(p.mUserID, STC.STC_MatchReady, msg); } if (mNotReady.Count <= 0 && mPlayers.Count >= mMaxCount) { IsVanish = true; OnTimeOver(); } }
public void ReqMatch(ReqMatch reqMatch) { uint userid = reqMatch.userid; uint roomType = reqMatch.fight_type; if (!CheckDataaVailability(userid)) { return; } System.Console.WriteLine("ReqMatch userid = {0}, roomType = {1}", userid, roomType); RoomType type = (RoomType)roomType; uint count = (uint)type; if (!m_MatchMap[type].Contains(userid)) { m_MatchMap[type].Enqueue(userid); uint playercount = count * 2; if (m_MatchMap[type].Count >= playercount) { List <uint> playeridlist = new List <uint>(); for (int i = 0; i < playercount; i++) { playeridlist.Add(m_MatchMap[type].Dequeue()); } Room room = m_RoomPool.Pop(); m_RoomDic[m_temp_roomid] = room; room.Init(playeridlist, m_temp_roomid); m_temp_roomid++; } } }
public void BeginMatch() { ReqMatch req = new ReqMatch(); req.UserID = GameController.mUserInfo.uid; NetWork.SendPacket <ReqMatch>(CTS.CTS_Match, req, null); }
static void OnMatch(byte[] data, Action5001 action) { ReqMatch reqMatch = ProtoBufUtils.Deserialize <ReqMatch>(data); Player player = PlayerManager.Instance.FindPlayer(reqMatch.UserID); if (player == null) { return; } RoomManager.Instance.Match(player); }
public void SendMatch(uint fight_type) { ReqMatch match = new ReqMatch(); match.userid = NetData.Instance.mUserData.Userid; match.fight_type = fight_type; using (MemoryStream stream = new MemoryStream()) { Serializer.Serialize(stream, match); Send(Protocol.ReqMatch, stream.ToArray()); } }
void NotifyMatchReady(byte[] data) { ReqMatch msg = ProtoBufUtils.Deserialize <ReqMatch>(data); if (msg.UserID == GameController.mUserInfo.uid) { readyBtn.interactable = false; } for (int i = 0; i < playerIDs.Length; ++i) { int uid = playerIDs[i]; if (msg.UserID != uid) { continue; } playerLocks[i].SetActive(true); } }
internal static void MessageHandle(AsyncUserToken asyncUserToken, byte tType, byte[] tData) { using (MemoryStream stream = new MemoryStream(tData)) { Console.WriteLine("收到消息类型 = {0}", (Protocol)tType); switch ((Protocol)tType) { case Protocol.ReqLogin: ReqLogin login = Serializer.Deserialize <ReqLogin>(stream); MessageHandle(asyncUserToken, login); break; case Protocol.ReqMatch: ReqMatch match = Serializer.Deserialize <ReqMatch>(stream); MessageHandle(asyncUserToken, match); break; case Protocol.ReqSelectHero: ReqSelectHero selectHero = Serializer.Deserialize <ReqSelectHero>(stream); MessageHandle(asyncUserToken, selectHero); break; } } }
internal static void MessageHandle(AsyncUserToken asyncUserToken, ReqMatch match) { asyncUserToken.mServer.m_RoomManager.ReqMatch(match); }