private void _unfillSlots(EquipItem ei) { foreach (GameTypes.EquipmentSlots es in ei.getSlots()) { mSlotMap.Remove(es); } }
private void _fillSlots(EquipItem ei) { foreach (GameTypes.EquipmentSlots es in ei.getSlots()) { mSlotMap[es] = ei; } }
public void unequipItem(EquipItem ei) { //make sure the item is actually in the inventory Item it = getItemOfType(ei.getType()); //does it have the item if (!it) { Debug.LogWarning("The inventory doesnt have this item."); return; } //make sure its in there if (hasSlots(ei.getSlots()) == false) { Debug.LogWarning("The inventory doesnt have this item equipped."); return; } if (_checkSlots(ei) == false) { Debug.LogWarning("The inventory doesnt have this item equipped. Or perhaps its not in all of the necessary slots."); return; } ei.unequip(); _removeEffectsFomrUnit(ei); _unfillSlots(ei); }
private bool _checkSlots(EquipItem ei) { //Returns false if the item isnt in all of the slots foreach (GameTypes.EquipmentSlots es in ei.getSlots()) { if (mSlotMap[es] != ei) { return(false); } } return(true); }
public void equipItem(EquipItem eitem) { //Debug.Log("Equipment inventory is equipping the item."); //make sure the item is actually in the inventory Item it = getItemOfType(eitem.getType()); //does it have the item if (!it) { Debug.LogWarning("The inventory doesnt have this item"); return; } //is there enough of it? if (it.getAmount() < 1) { Debug.LogWarning("The inventory doesnt have enough of this item"); return; } //Is the slot for this item valid for this inventory List <GameTypes.EquipmentSlots> slots = eitem.getSlots(); if (!hasSlots(slots)) { Debug.LogError("The inventory doesnt have the slots for this item."); return; } //check if the slot is already filled if (slotsFilled(slots) == true) { //clear the slot of the item it contains clearSlots(slots); } //equip the item eitem.equip(); //add the attributes to the UnitStats _applyEffectsToUnit(eitem); //add it to the map _fillSlots(eitem); }