示例#1
0
        public void MoveItem(ISpellIcon spellIcon, int newSlot)
        {
            if (spellIcon.Slot == newSlot || newSlot < 0 || newSlot > SPELL_NUM_ROWS * SPELL_ROW_LENGTH)
            {
                return;
            }

            if (!_childItems.Contains(spellIcon))
            {
                throw new ArgumentException("The spell was not found!", nameof(spellIcon));
            }

            //update the registry
            var spellInDestinationSlot = _childItems.Find(x => x.Slot == newSlot);

            if (spellInDestinationSlot is SpellIcon)
            {
                _setSpellSlotInRegistry(spellIcon.Slot, spellInDestinationSlot.SpellData.ID);
            }
            else
            {
                _clearSlotInRegistry(spellIcon.Slot);
            }
            _setSpellSlotInRegistry(newSlot, spellIcon.SpellData.ID);

            //set the slots of old/new items
            spellInDestinationSlot.Slot = spellIcon.Slot;
            spellInDestinationSlot.SetDisplaySlot(GetDisplaySlotFromSlot(spellIcon.Slot));
            spellIcon.Slot = newSlot;
            spellIcon.SetDisplaySlot(GetDisplaySlotFromSlot(newSlot));
        }
		public void MoveItem(ISpellIcon spellIcon, int newSlot)
		{
			if (spellIcon.Slot == newSlot || newSlot < 0 || newSlot > SPELL_NUM_ROWS * SPELL_ROW_LENGTH)
				return;

			if (!_childItems.Contains(spellIcon))
				throw new ArgumentException("The spell was not found!", "spellIcon");

			//update the registry
			var spellInDestinationSlot = _childItems.Find(x => x.Slot == newSlot);
			if (spellInDestinationSlot is SpellIcon)
				_setSpellSlotInRegistry(spellIcon.Slot, spellInDestinationSlot.SpellData.ID);
			else
				_clearSlotInRegistry(spellIcon.Slot);
			_setSpellSlotInRegistry(newSlot, spellIcon.SpellData.ID);

			//set the slots of old/new items
			spellInDestinationSlot.Slot = spellIcon.Slot;
			spellInDestinationSlot.SetDisplaySlot(GetDisplaySlotFromSlot(spellIcon.Slot));
			spellIcon.Slot = newSlot;
			spellIcon.SetDisplaySlot(GetDisplaySlotFromSlot(newSlot));
		}