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

            this.Trajectory =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.r = NetPacker.ByteToTinyFloat(reader.ReadByte());
            this.g = NetPacker.ByteToTinyFloat(reader.ReadByte());
            this.b = NetPacker.ByteToTinyFloat(reader.ReadByte());
            this.a = NetPacker.ByteToTinyFloat(reader.ReadByte());

            this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16());
            this.flag = NetPacker.SbyteToInt(reader.ReadSByte());

            this.owner = -1;
            this.Exists = true;
            this.rotation = GlobalFunctions.GetAngle(new Vector2(), Trajectory);
            this.frame = Rand.GetRandomFloat(0.3f, 0.7f);
        }
Beispiel #2
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 #3
0
        public Fog(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.Trajectory = new Vector2(80f, -30f);
            this.size = Rand.GetRandomFloat(6f, 8f);
            this.flag = Rand.GetRandomInt(0, 4);
            this.owner = -1;
            this.Exists = true;
            this.frame = (float)Math.PI * 2f;
            this.additive = true;
            this.rotation = Rand.GetRandomFloat(0f, 6.28f);
        }
Beispiel #4
0
        public Rocket(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.Trajectory =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.owner = NetPacker.SbyteToInt(reader.ReadSByte());

            this.frame = 4f;
            this.Exists = true;
        }
Beispiel #5
0
        public MuzzleFlash(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.Trajectory =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16());

            this.rotation = Rand.GetRandomFloat(0f, 6.28f);
            this.Exists = true;
            this.frame = 0.05f;
            this.additive = true;
        }
Beispiel #6
0
        public Heat(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.Trajectory =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16());

            this.flag = Rand.GetRandomInt(0, 4);
            this.owner = -1;
            this.Exists = true;
            this.rotation = Rand.GetRandomFloat(0f, 6.28f);
            this.frame = Rand.GetRandomFloat(.5f, .785f);
            this.refract = true;
        }
Beispiel #7
0
        public Bullet(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.Trajectory =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.owner = NetPacker.ShortToInt(reader.ReadInt16());

            this.rotation = GlobalFunctions.GetAngle(new Vector2(),
                Trajectory);
            this.Exists = true;
            this.frame = 0.5f;

            this.additive = true;
        }
Beispiel #8
0
        public Smoke(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.Trajectory =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.r = NetPacker.ByteToTinyFloat(reader.ReadByte());
            this.g = NetPacker.ByteToTinyFloat(reader.ReadByte());
            this.b = NetPacker.ByteToTinyFloat(reader.ReadByte());
            this.a = NetPacker.ByteToTinyFloat(reader.ReadByte());

            this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16());
            this.flag = NetPacker.SbyteToInt(reader.ReadSByte());

            this.owner = -1;
            this.Exists = true;
            this.frame = 1.0f;
        }
Beispiel #9
0
        public Fire(PacketReader reader)
        {
            this.Location =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.Trajectory =
                new Vector2(
                NetPacker.ShortToBigFloat(reader.ReadInt16()),
                NetPacker.ShortToBigFloat(reader.ReadInt16()));

            this.size = NetPacker.ShortToSmallFloat(reader.ReadInt16());
            this.flag = NetPacker.SbyteToInt(reader.ReadSByte());
            this.frame = NetPacker.ShortToSmallFloat(reader.ReadInt16());

            this.Exists = true;
            this.additive = true;
        }
 /* Given a highscores packet sent to a local player, handle that.
  * The packet itself is in the PacketReader r.
  */
 protected virtual void DoHighscoresPacket(LocalNetworkGamer to, PacketReader r, 
     NetworkGamer from, byte type)
 {
     PMR.Reader = r;
       byte n = 0;
       short tok = 0;
       switch (type)
       {
     case HighscoreItems:
       if (!from.IsLocal)
       {
     tok = r.ReadInt16();
     n = r.ReadByte();
     Trace.WriteLine(String.Format("Received {0} highscores in a packet from {1} (token {2})",
       n, from, tok));
     //  this happens during runtime, so I better not do too many scores at one time
     for (int i = 0; i != n; ++i)
     {
       Highscore hs = new Highscore();
       hs.MarshalThrough(PMR);
       Storage.Instance.AddHighscore(hs, true);
     }
     SendAck(tok, from);
       }
       break;
     case HighscoreItemsAck:
       tok = r.ReadInt16();
       Trace.WriteLine(String.Format("Received ack for pos {0} from {1}", tok, from));
       AckFrom(from, tok);
       break;
     default:
       Trace.WriteLine(String.Format("Swallowing packet type {0} from {1}", type, from));
       break;
       }
 }
Beispiel #11
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;
        }