public EquipmentSlotData(EquipmentSlotData other) { item = other.item; primary = other.primary; locked = other.locked; empty = other.empty; }
public EquipmentData(EquipmentData other) { head = new EquipmentSlotData(other.head); torso = new EquipmentSlotData(other.torso); legs = new EquipmentSlotData(other.legs); feet = new EquipmentSlotData(other.feet); leftArm = new EquipmentSlotData(other.leftArm); rightArm = new EquipmentSlotData(other.rightArm); }
public EquipmentData() { head = new EquipmentSlotData(); torso = new EquipmentSlotData(); legs = new EquipmentSlotData(); feet = new EquipmentSlotData(); leftArm = new EquipmentSlotData(); rightArm = new EquipmentSlotData(); }
public void Unequip(ItemData item) { foreach (var slotType in GetValidSlotTypes()) { EquipmentSlotData slot = GetEquipmentSlot(slotType); if (slot.Item == item && slot.Primary) { Unequip(item.GetSlotCombination(slotType)); return; } } }
public IList <EquippedItemInfo> GetEquippedItems() { var result = new List <EquippedItemInfo>(); foreach (EquipmentSlotType slotType in System.Enum.GetValues(typeof(EquipmentSlotType))) { if (slotType == EquipmentSlotType.None) { continue; } EquipmentSlotData slotData = GetEquipmentSlot(slotType); ItemData item = slotData.Item; if (item != null && slotData.Primary) { result.Add(new EquippedItemInfo(item, slotType)); } } return(result.AsReadOnly()); }
public CanEquipResult CanEquip(EquipmentSlotCombination slotCombination) { var result = new CanEquipResult(); bool primaryConflictDetected = false; bool secondaryConflictDetected = false; foreach (var slotType in slotCombination.SlotsTaken) { EquipmentSlotData slotData = GetEquipmentSlot(slotType); if (slotData == null) { result.Status = CanEquipStatus.No_Impossible; return(result); } if (!slotData.Empty) { result.AddConflictingItem(slotData.Item); if (slotType == slotCombination.PrimarySlot) { primaryConflictDetected = true; } else { secondaryConflictDetected = true; } } } if (primaryConflictDetected && !secondaryConflictDetected) { result.Status = CanEquipStatus.No_PrimaryConflict; } else if (secondaryConflictDetected) { result.Status = CanEquipStatus.No_SecondaryConflict; } else { result.Status = CanEquipStatus.Yes; } return(result); }
public ItemData Unequip(EquipmentSlotType slotType) { EquipmentSlotData slot = GetEquipmentSlot(slotType); if (slot.Empty) { Debug.LogWarning("Slot already empty"); return(null); } else { EquipmentSlotCombination slotCombination; ItemData item = slot.Item; if (slot.Primary) { slotCombination = item.GetSlotCombination(slotType); } else { slotCombination = item.GetSlotCombinationWithSecondarySlot(slotType); } return(Unequip(slotCombination)); } }
protected override void LoadDataInternal() { if (!isInitialized) { return; } InventoryData inventoryData = parentMenu.InventoryData; ItemData itemData = null; int count = 0; bool itemIconEnabled = false; bool locked = false; if (!slotId.isEquipmentSlot) { InventorySlotData inventorySlotData = inventoryData.GetInventorySlotData(slotId.inventorySlotId); if (!inventorySlotData.Empty) { itemData = inventorySlotData.Item; itemIconEnabled = true; } count = inventorySlotData.Count; } else if (slotId.isEquipmentSlot) { EquipmentSlotData eqSlotData = inventoryData.EquipmentData.GetEquipmentSlot(slotId.equipmentSlotType); if (!eqSlotData.Empty) { itemData = eqSlotData.Item; if (eqSlotData.Primary) { itemIconEnabled = true; } else { locked = true; } } } if (itemData != null) { if (itemData.IsType(ItemType.Weapon)) { UnitWeaponCombiner combiner = new UnitWeaponCombiner(parentMenu.UnitData, itemData.WeaponData); if (!combiner.CanUse) { locked = true; } } } if (itemIconEnabled) { itemIcon.enabled = true; itemIcon.texture = parentMenu.ItemIconAtlas; itemIcon.uvRect = parentMenu.GetItemIconUvRect(itemData); } else { itemIcon.enabled = false; } lockIcon.enabled = locked; if (count > 1) { countText.text = count.ToString(); } else { countText.text = ""; } nameText.text = eqSlotName; if (parentMenu.IsSelected(slotId)) { borderImage.color = selectedBorderColor; } else { borderImage.color = deselectedBorderColor; } }