コード例 #1
0
ファイル: ShotMessage.cs プロジェクト: nicokuyum/TAVJ
 public override void SerializeWithCompressor(Compressor c)
 {
     c.WriteNumber((int)MessageType.Shot, Enum.GetNames(typeof(MessageType)).Length);
     c.WriteNumber(_MessageId, GlobalSettings.MaxACK);
     CompressingUtils.WriteTime(c, _TimeStamp);
     c.WriteNumber(targetId, GlobalSettings.MaxPlayers);
 }
コード例 #2
0
 public override void SerializeWithCompressor(Compressor c)
 {
     c.WriteNumber((int)MessageType.PlayerInput, Enum.GetNames(typeof(MessageType)).Length);
     c.WriteNumber(_MessageId, int.MaxValue);
     CompressingUtils.WriteTime(c, _TimeStamp);
     c.WriteNumber((int)Action, Enum.GetNames(typeof(PlayerAction)).Length);
 }
コード例 #3
0
 public override void SerializeWithCompressor(Compressor c)
 {
     c.WriteNumber((int)MessageType.ClientConnect, Enum.GetNames(typeof(MessageType)).Length);
     c.WriteNumber(_MessageId, int.MaxValue);
     CompressingUtils.WriteTime(c, _TimeStamp);
     c.WriteString(name);
 }
コード例 #4
0
ファイル: MessageSerializer.cs プロジェクト: nicokuyum/TAVJ
    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));
    }
コード例 #5
0
ファイル: MessageSerializer.cs プロジェクト: nicokuyum/TAVJ
    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));
    }
コード例 #6
0
ファイル: MessageSerializer.cs プロジェクト: nicokuyum/TAVJ
    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));
    }
コード例 #7
0
 public override void SerializeWithCompressor(Compressor c)
 {
     c.WriteNumber((int)MessageType.ConnectConfirmation, Enum.GetNames(typeof(MessageType)).Length);
     c.WriteNumber(_MessageId, GlobalSettings.MaxACK);
     c.WriteNumber(id, GlobalSettings.MaxPlayers);
     CompressingUtils.WriteTime(c, _TimeStamp);
     c.WriteString(name);
 }
コード例 #8
0
ファイル: RotationMessage.cs プロジェクト: nicokuyum/TAVJ
    public override byte[] Serialize()
    {
        Compressor c = new Compressor();

        c.WriteNumber((int)MessageType.Rotation, Enum.GetNames(typeof(MessageType)).Length);
        CompressingUtils.WriteRotation(c, rot);
        return(c.GetBuffer());
    }
コード例 #9
0
 public void serializeWithCompressor(Compressor c)
 {
     c.WriteNumber(id, GlobalSettings.MaxPlayers);
     CompressingUtils.WriteTime(c, _TimeStamp);
     c.WriteNumber(this.Health, GlobalSettings.MaxHealth);
     c.PutBit(this.Invulnerable);
     CompressingUtils.WritePosition(c, position);
     c.WriteNumber(lastId, GlobalSettings.MaxACK);
 }
コード例 #10
0
ファイル: MessageSerializer.cs プロジェクト: nicokuyum/TAVJ
    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));
    }
コード例 #11
0
    public override byte[] Serialize()
    {
        Compressor compressor = new Compressor();

        compressor.WriteNumber((int)MessageType.ClientConnect, Enum.GetNames(typeof(MessageType)).Length);
        compressor.WriteNumber(_MessageId, int.MaxValue);
        CompressingUtils.WriteTime(compressor, _TimeStamp);
        compressor.WriteString(name);
        return(compressor.GetBuffer());
    }
コード例 #12
0
    public override byte[] Serialize()
    {
        Compressor compressor = new Compressor();

        compressor.WriteNumber((int)MessageType.PlayerInput, Enum.GetNames(typeof(MessageType)).Length);
        compressor.WriteNumber(_MessageId, int.MaxValue);
        CompressingUtils.WriteTime(compressor, _TimeStamp);
        compressor.WriteNumber((int)Action, Enum.GetNames(typeof(PlayerAction)).Length);
        return(compressor.GetBuffer());
    }
コード例 #13
0
ファイル: ShotMessage.cs プロジェクト: nicokuyum/TAVJ
    public override byte[] Serialize()
    {
        Compressor c = new Compressor();

        c.WriteNumber((int)MessageType.Shot, Enum.GetNames(typeof(MessageType)).Length);
        c.WriteNumber(_MessageId, GlobalSettings.MaxACK);
        CompressingUtils.WriteTime(c, _TimeStamp);
        c.WriteNumber(targetId, GlobalSettings.MaxPlayers);
        return(c.GetBuffer());
    }
コード例 #14
0
 public override void SerializeWithCompressor(Compressor c)
 {
     c.WriteNumber((int)MessageType.WorldSnapshot, Enum.GetNames(typeof(MessageType)).Length);
     CompressingUtils.WriteTime(c, time);
     c.WriteNumber(_numberOfPlayers, GlobalSettings.MaxPlayers);
     foreach (PlayerSnapshot playerSnapshot in _playerSnapshots)
     {
         playerSnapshot.serializeWithCompressor(c);
     }
 }
コード例 #15
0
    public override byte[] Serialize()
    {
        Compressor compressor = new Compressor();

        compressor.WriteNumber((int)MessageType.ConnectConfirmation, Enum.GetNames(typeof(MessageType)).Length);
        compressor.WriteNumber(_MessageId, GlobalSettings.MaxACK);
        compressor.WriteNumber(id, GlobalSettings.MaxPlayers);
        CompressingUtils.WriteTime(compressor, _TimeStamp);
        compressor.WriteString(name);
        return(compressor.GetBuffer());
    }
コード例 #16
0
    public byte[] serialize()
    {
        Compressor compressor = new Compressor();

        compressor.WriteNumber(id, GlobalSettings.MaxPlayers);
        CompressingUtils.WriteTime(compressor, _TimeStamp);
        compressor.WriteNumber(this.Health, GlobalSettings.MaxHealth);
        compressor.PutBit(this.Invulnerable);
        CompressingUtils.WritePosition(compressor, position);
        compressor.WriteNumber(lastId, GlobalSettings.MaxACK);
        return(compressor.GetBuffer());
    }
コード例 #17
0
ファイル: MessageSerializer.cs プロジェクト: nicokuyum/TAVJ
    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);
    }
コード例 #18
0
    public override byte[] Serialize()
    {
        Compressor compressor = new Compressor();

        compressor.WriteNumber((int)MessageType.WorldSnapshot, Enum.GetNames(typeof(MessageType)).Length);
        CompressingUtils.WriteTime(compressor, time);
        compressor.WriteNumber(_numberOfPlayers, GlobalSettings.MaxPlayers);
        foreach (PlayerSnapshot playerSnapshot in _playerSnapshots)
        {
            playerSnapshot.serializeWithCompressor(compressor);
        }
        return(compressor.GetBuffer());
    }
コード例 #19
0
ファイル: MessageSerializer.cs プロジェクト: nicokuyum/TAVJ
    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));
    }
コード例 #20
0
ファイル: RotationMessage.cs プロジェクト: nicokuyum/TAVJ
 public override void SerializeWithCompressor(Compressor c)
 {
     c.WriteNumber((int)MessageType.Rotation, Enum.GetNames(typeof(MessageType)).Length);
     CompressingUtils.WriteRotation(c, rot);
 }
コード例 #21
0
ファイル: MessageSerializer.cs プロジェクト: nicokuyum/TAVJ
    public static GameMessage RotationDeserialize(Decompressor decompressor)
    {
        Vector3 rot = CompressingUtils.GetRotation(decompressor);

        return(new RotationMessage(rot));
    }