예제 #1
0
        public void SetPos(ValPair<float> pos, bool requestTileData = false)
        {
            Position = pos;
            Client.Send(TerrPacketType.UpdatePlayer, new UpdatePlayer(this));

            if (requestTileData)
                Client.Send(TerrPacketType.RequestInitialTileData, new ValPair<int>((int) pos.Val1, (int) pos.Val2));
        }
 public WorldProjectile(short uniqueId, ValPair<float> position, ValPair<float> velocity, float knockback, short damage, byte ownerPlayerId, short type, BitArray aiFlags, float[] ai = null)
 {
     UniqueId = uniqueId;
     Position = position;
     Velocity = velocity;
     Knockback = knockback;
     Damage = damage;
     OwnerPlayerId = ownerPlayerId;
     Type = type;
     Ai = ai;
 }
        protected override void ReadPayload(PayloadReader reader, TerrPacketType type)
        {
            CheckForValidType(type, TerrPacketType.ProjectileUpdate);

            UniqueId = reader.ReadInt16();
            Position = new ValPair<float>(reader);
            Velocity = new ValPair<float>(reader);
            Knockback = reader.ReadSingle();
            Damage = reader.ReadInt16();
            OwnerPlayerId = reader.ReadByte();
            Type = reader.ReadInt16();
            AiFlags = new BitArray(new[] { reader.ReadByte() });

            List<float> aiBuilder = new List<float>();

            for (byte i = 0; i < MaxAi; i++)
                if (AiFlags[i])
                    aiBuilder.Add(reader.ReadSingle());

            Ai = aiBuilder.ToArray();
        }
예제 #4
0
        protected override void ReadPayload(PayloadReader reader, TerrPacketType type)
        {
            CheckForValidType(type, TerrPacketType.UpdatePlayer);

            PlayerId = reader.ReadByte();
            Control = reader.ReadByte();
            Pulley = reader.ReadByte();
            SelectedItem = reader.ReadByte();
            Position = new ValPair<float>(reader);

            // the server doesn't send us the velocity if there is none, thus requiring us to skip reading it if position == lenght.
            if (reader.BaseStream.Position == reader.BaseStream.Length) return;
            Velocity = new ValPair<float>(reader);
        }
예제 #5
0
 internal UpdatePlayer(CurrentPlayer player)
 {
     PlayerId = player.PlayerId.Value;
     Control =
         new BitArray(new[]
         {
             player.IsGoingUp, player.IsGoingDown,
             player.IsGoingLeft, player.IsGoingRight, player.IsJumping,
             player.IsUsingItem, player.Direction
         }).ConvertToByte(false);
     Pulley = player.PulleyFlags;
     SelectedItem = player.SelectedItem;
     Position = player.Position ?? new ValPair<float>(0, 0);
     Velocity = player.Velocity ?? new ValPair<float>(0, 0);
 }
예제 #6
0
        protected override void ReadPayload(PayloadReader reader, TerrPacketType type)
        {
            CheckForValidType(type, TerrPacketType.UpdateItemDrop, TerrPacketType.UpdateItemDrop2);

            Item = new GameItem();
            UniqueId = reader.ReadInt16();
            Position = new ValPair<float>(reader);
            Velocity = new ValPair<float>(reader);
            Item.Stack = reader.ReadInt16();
            Item.Prefix = reader.ReadByte();
            NoDelay = reader.ReadByte();
            Item.Id = reader.ReadInt16();
        }
예제 #7
0
 public WorldItem(GameItem item, short itemId, ValPair<float> position, byte noDelay,  ValPair<float> velocity = null)
 {
     UniqueId = itemId;
     Position = position;
     Velocity = velocity ?? new ValPair<float>(0, 0);
     NoDelay = noDelay;
     Item = item;
 }
예제 #8
0
        protected override void ReadPayload(PayloadReader reader, TerrPacketType type)
        {
            CheckForValidType(type, TerrPacketType.NpcUpdate);

            UniqueId = reader.ReadInt16();
            Position = new ValPair<float>(reader);
            Velocity = new ValPair<float>(reader);
            TargetPlayerId = reader.ReadByte();
            Flags = new BitArray(new[] {reader.ReadByte()});
            /* 
               the size of the float[] Ai array is determined by ai flags at indexes 3, 4, 5, 6. 
               Each ai flag sets the ai array size to the previous size + 1. T
               he first one sets the size to 0, we ignore it.
            
               doesn't seem to work for now

            byte aiSize = 0;
            if (Flags[3])
                aiSize = 1;
            if (Flags[4])
                aiSize = 2;
            if (Flags[5])
                aiSize = 3;

            if (aiSize > 0)
            {
                Ai = new float[aiSize];
                for (byte i = 0; i < aiSize; i++)
                    Ai[i] = reader.ReadSingle();
            }

            NpcId = reader.ReadInt16();
            if (reader.BaseStream.Position != reader.BaseStream.Length)
            {
                Life = reader.ReadInt32();
                ReleaseOwner = reader.ReadByte();
            }
            */
        }