Ejemplo n.º 1
0
    public void SendReqGameStart()
    {
        ReqGameStart gameStart = new ReqGameStart();

        gameStart.userid = NetData.Instance.mUserData.Userid;
        gameStart.roomid = NetData.Instance.mFightData.RoomId;
        using (MemoryStream stream = new MemoryStream())
        {
            Serializer.Serialize(stream, gameStart);
            Send(Protocol.ReqGameStart, stream.ToArray());
        }
    }
Ejemplo n.º 2
0
        internal static void MessageHandle(byte tType, byte[] tData, byte[] bytes, Server tServer, IPEndPoint tSenderPoint)
        {
            uint     userid = 0;
            uint     roomid = 0;
            Protocol mType  = (Protocol)tType;

            using (MemoryStream stream = new MemoryStream(tData))
            {
                switch (mType)
                {
                case Protocol.ReqGameStart:
                    ReqGameStart reqGameStart = Serializer.Deserialize <ReqGameStart>(stream);
                    userid = reqGameStart.userid;
                    roomid = reqGameStart.roomid;
                    break;

                case Protocol.ReqStartMove:
                    ReqStartMove reqStartMove = Serializer.Deserialize <ReqStartMove>(stream);
                    userid = reqStartMove.userid;
                    roomid = reqStartMove.roomid;
                    break;

                case Protocol.ReqChangeDir:
                    ReqChangeDir reqChangeDir = Serializer.Deserialize <ReqChangeDir>(stream);
                    userid = reqChangeDir.userid;
                    roomid = reqChangeDir.roomid;
                    break;

                case Protocol.ReqEndMove:
                    ReqEndMove reqEndMove = Serializer.Deserialize <ReqEndMove>(stream);
                    userid = reqEndMove.userid;
                    roomid = reqEndMove.roomid;
                    break;
                }
            }
            if (userid != 0 && roomid != 0)
            {
                Room room = tServer.m_RoomManager.GetRoom(roomid);
                if (mType == Protocol.ReqGameStart)
                {
                    room.HeroReady(userid, tSenderPoint);
                }
                else
                {
                    if (room != null)
                    {
                        room.Receive(bytes, userid, tSenderPoint);
                    }
                }
            }
        }