示例#1
0
    public static GameMessage PlayerInputDeserialize(Decompressor decompressor)
    {
        int          id     = decompressor.GetNumber(int.MaxValue);
        float        time   = CompressingUtils.GetTime(decompressor);
        PlayerAction action = (PlayerAction)decompressor.GetNumber(Enum.GetNames(typeof(PlayerAction)).Length);

        return(new PlayerInputMessage(action, id, time, false));
    }
示例#2
0
    public static GameMessage ClientConnectDeserialize(Decompressor decompressor)
    {
        int    id   = decompressor.GetNumber(int.MaxValue);
        float  time = CompressingUtils.GetTime(decompressor);
        String name = decompressor.GetString();

        return(new ClientConnectMessage(id, name, time, false));
    }
示例#3
0
    private static GameMessage ShotDeserialize(Decompressor decompressor)
    {
        int   id       = decompressor.GetNumber(GlobalSettings.MaxACK);
        float time     = CompressingUtils.GetTime(decompressor);
        int   targetid = decompressor.GetNumber(GlobalSettings.MaxPlayers);

        return(new ShotMessage(id, targetid, time, false));
    }
示例#4
0
    public static GameMessage ConnectedClientDeserialize(Decompressor decompressor)
    {
        int    mssgid    = decompressor.GetNumber(GlobalSettings.MaxACK);
        int    id        = decompressor.GetNumber(GlobalSettings.MaxPlayers);
        float  timeStamp = CompressingUtils.GetTime(decompressor);
        String name      = decompressor.GetString();

        return(new ClientConnectedMessage(mssgid, id, name, timeStamp, false));
    }
示例#5
0
    public static PlayerSnapshot SnapshotDeserialize(Decompressor decompressor)
    {
        int            id             = decompressor.GetNumber(GlobalSettings.MaxPlayers);
        PlayerSnapshot playerSnapshot = new PlayerSnapshot(id);

        playerSnapshot._TimeStamp   = CompressingUtils.GetTime(decompressor);
        playerSnapshot.Health       = decompressor.GetNumber(GlobalSettings.MaxHealth);
        playerSnapshot.Invulnerable = decompressor.GetBoolean();
        playerSnapshot.position     = CompressingUtils.GetPosition(decompressor);
        playerSnapshot.lastId       = decompressor.GetNumber(GlobalSettings.MaxACK);
        return(playerSnapshot);
    }
示例#6
0
    public static GameMessage WorldSnapshotDeserialize(Decompressor decompressor)
    {
        float time = CompressingUtils.GetTime(decompressor);

        int numberOfPlayers = decompressor.GetNumber(GlobalSettings.MaxPlayers);
        List <PlayerSnapshot> playerSnapshots = new List <PlayerSnapshot>();

        for (int i = 0; i < numberOfPlayers; i++)
        {
            playerSnapshots.Add(SnapshotDeserialize(decompressor));
        }
        return(new WorldSnapshotMessage(playerSnapshots, time));
    }