Esempio n. 1
0
    public static void Send_Move(bool keydown, int direction, float time, float x, float y)
    {
        OnGameMove xmsg = new OnGameMove();

        xmsg.m_iKeyDown      = keydown;
        xmsg.m_iDirection    = direction;
        xmsg.m_iIntervalTime = time;

        xmsg.m_iPosX  = x;
        xmsg.m_iPosY  = y;
        xmsg.m_iOptID = Network.playerid;

        byte[] msgBytes;
        using (MemoryStream stream = new MemoryStream())
        {
            ProtoBuf.Serializer.Serialize(stream, xmsg);
            msgBytes = stream.ToArray();
        }

        OnGame ongame = new OnGame();

        ongame.gameData       = msgBytes;
        ongame.m_iRoomID      = Network.Myplayer.m_iRoomID;
        ongame.m_iTableID     = Network.gameInfo_sitdown.m_iTableID;
        ongame.m_icmd         = (int)GameID.Move;
        ongame.gameDataLength = msgBytes.Length;

        byte[] res;
        using (MemoryStream stream = new MemoryStream())
        {
            ProtoBuf.Serializer.Serialize(stream, ongame);
            res = stream.ToArray();
        }

        ClientHeader header = new ClientHeader();

        header = GetHeader(MessageID.CMD_PLAYGAME, res.Length);
        connector.SendMsg(header, res);
    }
Esempio n. 2
0
 /// <summary>
 /// Called when a move is received.
 /// </summary>
 /// <param name="ws">The websocket.</param>
 /// <param name="message">The message.</param>
 private void OnMove(WebSocketBase ws, MMove message)
 {
     ProcessGameMessage(message);
     curClock = message.Data.Clock;
     OnGameMove?.Invoke(this, new LilaGameMoveEvent(Client, this, message.Data));
 }