示例#1
0
        private Packet GenerateJoinPacket()
        {
            var packet = Packet.Obtain();

            EventSerializer.SerializeIntoBuffer(packet.Buffer, Event.Join);
            packet.Buffer.Flush();
            return(packet);
        }
示例#2
0
        private Packet GenerateInputPacket()
        {
            var packet = Packet.Obtain();

            EventSerializer.SerializeIntoBuffer(packet.Buffer, Event.Input);
            packet.Buffer.PutInt(_id);
            _playerInput.SerializeIntoBuffer(packet.Buffer);
            packet.Buffer.Flush();
            return(packet);
        }
示例#3
0
        private void SendHits()
        {
            var packet = Packet.Obtain();

            EventSerializer.SerializeIntoBuffer(packet.Buffer, Event.Hit);
            var shoots = _playerInput.GetShootsNotProcessedByServer();

            packet.Buffer.PutInt(_id);
            packet.Buffer.PutInt(shoots.Count);
            foreach (var shoot in shoots)
            {
                packet.Buffer.PutInt(shoot.Key);
                packet.Buffer.PutInt(shoot.Value.Hitted);
            }
            packet.Buffer.Flush();
            Logger.Log("C: Sending hits", false, "cyan");
            StartCoroutine(SendPacketAddingLatency(packet));
        }