Beispiel #1
0
        public Shockwave(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.size = NetPacker.ShortToMidFloat(reader.ReadInt16());
            this.refract = reader.ReadBoolean();

            this.owner = -1;
            this.Exists = true;
            this.frame = .5f;
        }
Beispiel #2
0
        public void ReadNetworkPacket(PacketReader packetReader, GameTime gameTime, TimeSpan latency)
        {
            float packetSendTime = packetReader.ReadSingle();
            bool pIsAlive = packetReader.ReadBoolean();
            if (pIsAlive)
            {
                float px = packetReader.ReadSingle();
                float py = packetReader.ReadSingle();
                float vx = packetReader.ReadSingle();
                float vy = packetReader.ReadSingle();
                rawPostion = new Vector2(px, py);
                rawVelocity = new Vector2(vx, vy);
            }

            //if (enableSmoothing)
            //{
            //    // Start a new smoothing interpolation from our current
            //    // state toward this new state we just received.
            //    previousState = displayState;
            //    currentSmoothing = 1;
            //}
            //else
            //{
            //    currentSmoothing = 0;
            //}

            //// Read what time this packet was sent.
            //float packetSendTime = packetReader.ReadSingle();

            //// Read simulation state from the network packet.
            //simulationState.Position = packetReader.ReadVector2();
            //simulationState.Velocity = packetReader.ReadVector2();
            //simulationState.TankRotation = packetReader.ReadSingle();
            //simulationState.TurretRotation = packetReader.ReadSingle();

            //// Read remote inputs from the network packet.
            //tankInput = packetReader.ReadVector2();
            //turretInput = packetReader.ReadVector2();

            //// Optionally apply prediction to compensate for
            //// how long it took this packet to reach us.
            //if (enablePrediction)
            //{
            //    ApplyPrediction(gameTime, latency, packetSendTime);
            //}
        }
Beispiel #3
0
        /// <summary>
        /// Create a new ShipInput object based on the data in the packet.
        /// </summary>
        /// <param name="packetReader">The packet with the data.</param>
        public ShipInput(PacketReader packetReader)
        {
            // safety-check the parameters, as they must be valid
            if (packetReader == null)
            {
                throw new ArgumentNullException("packetReader");
            }

            // read the data
            LeftStick = packetReader.ReadVector2();
            RightStick = packetReader.ReadVector2();
            MineFired = packetReader.ReadBoolean();
        }
Beispiel #4
0
        public void ReadFromNet(PacketReader reader)
        {
            Loc.X = NetPacker.ShortToBigFloat(reader.ReadInt16());
            Loc.Y = NetPacker.ShortToBigFloat(reader.ReadInt16());

            Anim = NetPacker.ShortToInt(reader.ReadInt16());
            AnimFrame = NetPacker.ShortToInt(reader.ReadInt16());
            AnimName = charDef.GetAnimation(Anim).name;
            frame = NetPacker.ShortToMidFloat(reader.ReadInt16());

            if (reader.ReadBoolean())
                State = CharState.Air;
            else
                State = CharState.Grounded;

            if (reader.ReadBoolean())
                Face = CharDir.Right;
            else
                Face = CharDir.Left;

            Trajectory.X = NetPacker.ShortToBigFloat(reader.ReadInt16());
            Trajectory.Y = NetPacker.ShortToBigFloat(reader.ReadInt16());

            KeyRight = reader.ReadBoolean();
            KeyLeft = reader.ReadBoolean();

            HP = NetPacker.ShortToInt(reader.ReadInt16());

            ReceivedNetUpdate = true;
        }