Exemplo n.º 1
0
        // 添加一个宠物物品
        public void AddPet(InventoryType.Id type, short slot, int itemId, bool cash, long expire, string name,
                           short level, short closeness, short fullness)
        {
            var addSlot = AddSlot(type, slot, itemId, 1, cash);

            _pets[addSlot] = new Pet(itemId, expire, name, level, closeness, fullness);
        }
Exemplo n.º 2
0
        private void Remove(InventoryType.Id type, short slot)
        {
            if (!_inventories.ContainsKey(type) || !_inventories[type].ContainsKey(slot))
            {
                return;
            }
            var s        = _inventories[type][slot];
            var uniqueId = s.UniqueId;

            _inventories[type].Remove(slot);
            switch (type)
            {
            case InventoryType.Id.EQUIPPED:
            case InventoryType.Id.EQUIP:
                _equips.Remove(uniqueId);
                break;

            case InventoryType.Id.CASH:
                _items.Remove(uniqueId);
                _pets.Remove(uniqueId);
                break;

            default:
                _items.Remove(uniqueId);
                break;
            }
        }
Exemplo n.º 3
0
        // 添加一个一般物品
        public void AddItem(InventoryType.Id type, short slot, int itemId, bool cash, long expire, short count,
                            string owner, short flags)
        {
            var addSlot = AddSlot(type, slot, itemId, count, cash);

            _items[addSlot] = new Item(itemId, expire, owner, flags);
        }
Exemplo n.º 4
0
 // 返回一个项目的id.如果插槽是空的返回0
 public int GetItemId(InventoryType.Id type, short slot)
 {
     if (_inventories.ContainsKey(type) && _inventories[type].ContainsKey(slot))
     {
         return(_inventories[type][slot].ItemId);
     }
     return(0);
 }
Exemplo n.º 5
0
        // 添加一个装备物品
        public void AddEquip(InventoryType.Id type, short slot, int itemId, bool cash, long expire, short slots,
                             short level, Dictionary <EquipStat.Id, short> stats, string owner, short flag, short itemLevel,
                             short itemExp, int vicious)
        {
            var addSlot = AddSlot(type, slot, itemId, 1, cash);

            _equips[addSlot] = new Equip(itemId, expire, owner, flag, slots, level, stats, itemLevel, itemExp, vicious);
        }
Exemplo n.º 6
0
 public short GetItemCount(InventoryType.Id type, short slot)
 {
     // 返回条目的数量.如果插槽是空的返回0
     if (_inventories.ContainsKey(type) && _inventories[type].ContainsKey(slot))
     {
         return(_inventories[type][slot].Count);
     }
     return(0);
 }
Exemplo n.º 7
0
        private void ChangeCount(InventoryType.Id type, short slot, short count)
        {
            if (!_inventories.ContainsKey(type) || !_inventories[type].ContainsKey(slot))
            {
                return;
            }
            var s = _inventories[type][slot];

            s.Count = count;
        }
Exemplo n.º 8
0
        public Equip GetEquip(InventoryType.Id type, short slot)
        {
            if (type != InventoryType.Id.EQUIPPED && type != InventoryType.Id.EQUIP)
            {
                return(null);
            }
            if (!_inventories.ContainsKey(type) || !_inventories[type].ContainsKey(slot))
            {
                return(null);
            }
            var equip = _inventories[type][slot];

            return(_equips.ContainsKey(equip.UniqueId) ? _equips[equip.UniqueId] : null);
        }
Exemplo n.º 9
0
        // 找到一个免费的槽在指定的库存。
        public short FindFreeSlot(InventoryType.Id type)
        {
            short counter = 1;

            foreach (var keyValuePair in _inventories[type])
            {
                if (keyValuePair.Key != counter)
                {
                    return(counter);
                }
                counter++;
            }

            return((short)(counter <= _slotMaxIma[type] ? counter : 0));
        }
Exemplo n.º 10
0
        private void Swap(InventoryType.Id firstType, short firstSlot, InventoryType.Id secondType, short secondSlot)
        {
            var first  = _inventories[firstType][firstSlot].Clone();
            var second = _inventories[secondType][secondSlot].Clone();

            _inventories[firstType][firstSlot]   = null;
            _inventories[firstType][firstSlot]   = second;
            _inventories[secondType][secondSlot] = null;
            _inventories[secondType][secondSlot] = first;
            if (_inventories[firstType][firstSlot].ItemId == 0)
            {
                Remove(firstType, firstSlot);
            }
            if (_inventories[secondType][secondSlot].ItemId == 0)
            {
                Remove(secondType, secondSlot);
            }
        }
Exemplo n.º 11
0
        // 修改库存信息的数据包。
        public void Modify(InventoryType.Id type, short slot, short mode, short arg, Movement move)
        {
            if (slot < 0)
            {
                slot = (short)-slot;
                type = InventoryType.Id.EQUIPPED;
            }

            arg = (short)(arg < 0 ? -arg : arg);
            switch ((Modification)mode)
            {
            case Modification.CHANGECOUNT:
                ChangeCount(type, slot, arg);
                break;

            case Modification.SWAP:
                switch (move)
                {
                case Movement.MOVE_INTERNAL:
                    Swap(type, slot, type, arg);
                    break;

                case Movement.MOVE_UNEQUIP:
                    Swap(InventoryType.Id.EQUIPPED, slot, InventoryType.Id.EQUIP, arg);
                    break;

                case Movement.MOVE_EQUIP:
                    Swap(InventoryType.Id.EQUIP, slot, InventoryType.Id.EQUIPPED, arg);
                    break;
                }

                break;

            case Modification.REMOVE:
                Remove(type, slot);
                break;
            }
        }
Exemplo n.º 12
0
 // 返回指定的项包含第一个槽
 public short FindItem(InventoryType.Id type, int itemId)
 {
     return((from keyValuePair in _inventories[type]
             where keyValuePair.Value.ItemId == itemId
             select keyValuePair.Key).FirstOrDefault());
 }
Exemplo n.º 13
0
 private int AddSlot(InventoryType.Id type, short slot, int itemId, short count, bool cash)
 {
     _runningUid++;
     _inventories[type][slot] = new Slot(_runningUid, itemId, count, cash);
     return(_runningUid);
 }
Exemplo n.º 14
0
 // 返回指定的格子库存
 public short GetSlotMax(InventoryType.Id type) => _slotMaxIma[type];
Exemplo n.º 15
0
 // 给指定的格子插入库存
 public void SetSlotMax(InventoryType.Id type, short value)
 {
     _slotMaxIma[type] = value;
 }