Пример #1
0
    public static void AddToInventory(int to, InventorySlot slot)
    {
        int dbid = GameServer.clients[to].player.dbid;

        using (Packet _packet = new Packet((int)ServerPackets.addToInventory))
        {
            SerializableObjects.InventorySlot sslot = NetworkManager.SlotToSerializable(slot);

            _packet.Write(sslot);
            _packet.Write(mysql.TotalItems(dbid));
            SendTCPData(to, _packet);
        }
    }
Пример #2
0
    public static InventorySlot SerializableToSlot(SerializableObjects.InventorySlot slot)
    {
        Item item = null;

        if (slot.item != null)
        {
            item = new Item()
            {
                id                  = slot.item.id,
                item_id             = slot.item.item_id,
                iconName            = slot.item.iconName,
                modelName           = slot.item.modelName,
                isDefaultItem       = slot.item.isDefaultItem,
                name                = slot.item.name,
                item_type           = slot.item.item_type,
                attack              = slot.item.attack,
                health              = slot.item.health,
                defence             = slot.item.defence,
                speed               = slot.item.speed,
                visibility          = slot.item.visibility,
                rotation            = slot.item.rotation,
                cannon_reload_speed = slot.item.cannon_reload_speed,
                crit_chance         = slot.item.crit_chance,
                cannon_force        = slot.item.cannon_force,
                stackable           = slot.item.stackable,
                energy              = slot.item.energy,
                max_energy          = slot.item.max_energy,
                max_health          = slot.item.max_health,
                overtime            = slot.item.overtime,
                buff_duration       = slot.item.buff_duration,
                cooldown            = slot.item.cooldown
            };
        }

        return(new InventorySlot()
        {
            slotID = slot.slotID,
            quantity = slot.quantity,
            item = item
        });
    }
Пример #3
0
 public void Write(SerializableObjects.InventorySlot _value)
 {
     byte[] data = ObjectToByteArray(_value);
     Write(data.Length);    // Add the length of the string to the packet
     buffer.AddRange(data); // Add the string itself
 }