Example #1
0
    public void OnNetworkReceive(NetPeer peer, NetPacketReader reader, DeliveryMethod deliveryMethod)
    {
        int packetID = reader.GetInt();

        switch (packetID)
        {
        case 2:
            Packet02CreateWorldObject worldPacket = new Packet02CreateWorldObject();
            worldPacket.Deserialize(reader);
            worldPacket.ExecuteClientSide();
            break;

        case 3:
            Packet03CreatePlayer createPlayer = new Packet03CreatePlayer();
            createPlayer.Deserialize(reader);
            createPlayer.ExecuteClientSide();
            break;

        case 4:
            Packet04PlayerMove playerMove = new Packet04PlayerMove();
            playerMove.Deserialize(reader);
            playerMove.ExecuteClientSide();
            break;
        }
    }
Example #2
0
    public void OnNetworkReceive(NetPeer peer, NetPacketReader reader, DeliveryMethod deliveryMethod)
    {
        int packetID = reader.GetInt();

        switch (packetID)
        {
        case 0:
            Packet00Connect connect = new Packet00Connect(reader);
            Debug.Log(connect.username + " | " + connect.password);
            break;

        case 4:
            Packet04PlayerMove playerMove = new Packet04PlayerMove();
            playerMove.Deserialize(reader);
            playerMove.ExecuteServerSide(peer, dataWriter);
            break;
        }
    }