示例#1
0
        public void Remove(ClothingItem item)
        {
            Backpack.Remove(item);

            var slot = GetSlot(item);
            if (slot.Value == item)
                slot.Value = null;

            item.OnToggle -= Toggle;
        }
示例#2
0
 private EZData.VariableContext<ClothingItem> GetSlot(ClothingItem item)
 {
     switch(item.Slot)
     {
     case Slot.Shoulders: return ShouldersEzVariableContext;
     case Slot.Bracers: return BracersEzVariableContext;
     case Slot.Boots: return BootsEzVariableContext;
     }
     return null;
 }
示例#3
0
        public void Add(ClothingItem item)
        {
            item.OnToggle += Toggle;

            Backpack.Add(item);
        }
示例#4
0
        private void Toggle(ClothingItem item)
        {
            var slot = GetSlot(item); // find a slot corresponding to the item
            if (slot.Value == item) // if item is equipped
            {
                slot.Value = null; // remove it from slot
                Backpack.Add(item); // and put to backpack
            }
            else // otherwise if item is not equipped
            {
                if (slot.Value != null)
                    Backpack.Add(slot.Value); // clear the slot if it was used

                Backpack.Remove(item); // take item from backpack
                slot.Value = item; // and put to the slot
            }
        }
示例#5
0
        public void Add(ClothingItem item)
        {
            item.OnToggle += Toggle;

            Backpack.Add(item);
        }