Ejemplo n.º 1
0
        void update_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (_client.ServerConnection == null)
            {
                return;
            }
            if (ControllablePlayer.ControllablePlayerInstance != null && ControllablePlayer.ControllablePlayerInstance.UniqueID != 0)
            {
                if (Vector2.Distance(_lastSentPosition, ControllablePlayer.ControllablePlayerInstance.Position) > 0.002f)
                {
                    Packets.MovePacket movePacket = Packets.CreateMovementPacket(ControllablePlayer.ControllablePlayerInstance);

                    NetOutgoingMessage outMsg = _client.CreateMessage();
                    Packets.WritePacket(ref outMsg, ref movePacket);
                    SendPacket(outMsg, _client.ServerConnection, NetDeliveryMethod.UnreliableSequenced);

                    _lastSentPosition = ControllablePlayer.ControllablePlayerInstance.Position;
                }
            }
        }