Ejemplo n.º 1
0
        internal PlayerInventory(PlayerInventory value)
        {
            InternalItems = new GameItem[InventorySize];

            for (byte i = 0; i < InventorySize; i++)
                InternalItems[i] = new GameItem(value.InternalItems[i]);
        }
Ejemplo n.º 2
0
        internal void SetItem(byte index, GameItem additem)
        {
            if(index > InventorySize) throw new ArgumentException("Item index is out of range.");

            GameItem item = new GameItem(additem);
            item.SlotId = index;
            InternalItems[index] = item;
        }
Ejemplo n.º 3
0
 internal GameItem(GameItem value)
 {
     PlayerId = value.PlayerId;
     SlotId = value.SlotId;
     Stack = value.Stack;
     Prefix = value.Prefix;
     Id = value.Id;
 }
Ejemplo n.º 4
0
        public PlayerInventory(GameItem[] items = null)
        {
            InternalItems = items?.Length == InventorySize ? items : new GameItem[InventorySize];

            // check if any of the objects in the array are null and replace them if they are. also assign corrent slot ids
            for (byte i = 0; i < InventorySize; i++)
            {
                if (InternalItems[i] == null)
                    InternalItems[i] = new GameItem();

                InternalItems[i].SlotId = i;
            }
        }
Ejemplo n.º 5
0
        ///<summary>Sets an item in the bot players inventory at the given slot id.</summary>
        public void SetItem(GameItem setItem, byte slotId)
        {
            // check for out of range slotid
            if (slotId >= PlayerInventory.InventorySize) throw new ArgumentOutOfRangeException(nameof(slotId));

            GameItem item = new GameItem(setItem)
            {
                PlayerId = PlayerId,
                SlotId = slotId
            };
            Inventory.InternalItems[slotId] = item;

            Client.Send(TerrPacket.Create(TerrPacketType.SetInventory, item.CreatePayload()));
        }
Ejemplo n.º 6
0
 private void GiveItem(Player player, GameItem item)
     => _client.Send(TerrPacketType.UpdateItemDrop,
         new WorldItem(item, 400, player.Position, 0));
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 9
0
        protected override void ReadPayload(PayloadReader reader, TerrPacketType type)
        {
            CheckForValidType(type, TerrPacketType.TravellingMerchantInventory);

            for (byte i = 0; i < Size; i++)
            {
                byte slot = reader.ReadByte();
                Items[i] = new GameItem(reader.ReadByte()) {SlotId = slot};
            }
        }