public MagicType GetArmourMagicType() { foreach (var item in _inventoryItems) { if (item.Item.ItemType == ItemType.eARMOUR) { ArmourItemData armourItem = (ArmourItemData)item.Item; return(armourItem.MagicalType); } } return(MagicType.eNONE); }
public float GetArmourValue() { float value = 0; foreach (var item in _inventoryItems) { if (item.Item.ItemType == ItemType.eARMOUR) { ArmourItemData armourItem = (ArmourItemData)item.Item; value += armourItem.Value; } } return(value); }
public ArmourItemData GetEquippedArmour(ArmourItemData.SlotType armourSlotType) { foreach (var inventoryItem in _inventoryItems) { if (inventoryItem.Item.ItemType == ItemType.eARMOUR) { ArmourItemData inventoryArmour = (ArmourItemData)inventoryItem.Item; if (inventoryArmour.ArmourSlotType == armourSlotType) { return((ArmourItemData)inventoryItem.Item); } } } return(null); }
void RemoveItemUI(InventoryItem item) { if (item == null) { return; } if (item.Item.ItemType == ItemType.eARMOUR) { ArmourItemData armourItem = (ArmourItemData)item.Item; switch (armourItem.ArmourSlotType) { case ArmourItemData.SlotType.eHEAD: HeadButton.image.sprite = DefaultPreviewSprite; HeadButton.GetComponent <InventoryItemButton>().Item = null; break; case ArmourItemData.SlotType.eCHEST: BodyButton.image.sprite = DefaultPreviewSprite; BodyButton.GetComponent <InventoryItemButton>().Item = null; break; case ArmourItemData.SlotType.eLEGS: LegsButton.image.sprite = DefaultPreviewSprite; LegsButton.GetComponent <InventoryItemButton>().Item = null; break; default: throw new ArgumentOutOfRangeException(); } } else if (item.Item.ItemType == ItemType.eWEAPON) { WeaponItemData weaponItem = (WeaponItemData)item.Item; if (weaponItem.IsMainHand) { MainHandButton.image.sprite = DefaultPreviewSprite; MainHandButton.GetComponent <InventoryItemButton>().Item = null; } else { OffHandButton.image.sprite = DefaultPreviewSprite; OffHandButton.GetComponent <InventoryItemButton>().Item = null; } } }
void AddUIItem(InventoryItem item) { if (item.Item.ItemType == ItemType.eARMOUR) { ArmourItemData armourItem = (ArmourItemData)item.Item; switch (armourItem.ArmourSlotType) { case ArmourItemData.SlotType.eHEAD: HeadButton.image.sprite = armourItem.PreviewSprite; HeadButton.GetComponent <InventoryItemButton>().Item = item; HeadButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment; break; case ArmourItemData.SlotType.eCHEST: BodyButton.image.sprite = armourItem.PreviewSprite; BodyButton.GetComponent <InventoryItemButton>().Item = item; BodyButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment; break; case ArmourItemData.SlotType.eLEGS: LegsButton.image.sprite = armourItem.PreviewSprite; LegsButton.GetComponent <InventoryItemButton>().Item = item; LegsButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment; break; default: throw new ArgumentOutOfRangeException(); } } else if (item.Item.ItemType == ItemType.eWEAPON) { WeaponItemData weaponItem = (WeaponItemData)item.Item; if (weaponItem.IsMainHand) { MainHandButton.image.sprite = weaponItem.PreviewSprite; MainHandButton.GetComponent <InventoryItemButton>().Item = item; MainHandButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment; } else { OffHandButton.image.sprite = weaponItem.PreviewSprite; OffHandButton.GetComponent <InventoryItemButton>().Item = item; OffHandButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment; } } }
public void EquipArmour(ArmourItemData armourItem, Inventory partyInventory) { //check if the magic type of the item is the same as the rest if (armourItem.MagicalType != _armourMagicType && hasArmour()) { return; } //Remove the item from the part inventory partyInventory.RemoveItem(armourItem.Name); BaseItemData itemToRemove = null; //check if a armour is already in the equipment foreach (var inventoryItem in _inventoryItems) { if (inventoryItem.Item.ItemType == ItemType.eARMOUR) { ArmourItemData inventoryArmour = (ArmourItemData)inventoryItem.Item; if (inventoryArmour.ArmourSlotType == armourItem.ArmourSlotType) { //armour item already equipped, add it back to the party inventory partyInventory.AddItem(inventoryItem.Item); //remove armour piece from equipment itemToRemove = inventoryItem.Item; break; } } } if (itemToRemove != null) { RemoveItem(itemToRemove.Name); } //Add it to the equipment AddItem(armourItem); _armourMagicType = armourItem.MagicalType; }
public static ArmourItemData RandomArmour(SpriteManager spriteManager) { loadAdjvectives(); string itemName; ArmourItemData armourItem = ScriptableObject.CreateInstance <ArmourItemData>(); armourItem.DatabaseName = System.Guid.NewGuid().ToString(); //decide what type of armour to generate armourItem.ArmourSlotType = (ArmourItemData.SlotType)Random.Range(0, 3); armourItem.ArmourType = (ArmourItemData.Type)Random.Range(0, 3); string magicName = string.Empty; //random magic 30 change the item has magic if (Random.value <= .45f) { armourItem.MagicalType = (MagicType)Random.Range(1, 4); switch (armourItem.MagicalType) { case MagicType.eNONE: break; case MagicType.eTOMATO: magicName = "Tomato"; break; case MagicType.eCHEESE: magicName = "Cheese"; break; case MagicType.ePESTO: magicName = "Pesto"; break; default: break; } } else { armourItem.MagicalType = MagicType.eNONE; } switch (armourItem.ArmourSlotType) { case ArmourItemData.SlotType.eHEAD: itemName = "Cicioneddos Helemt"; switch (armourItem.ArmourType) { case ArmourItemData.Type.eLIGHT: //light helmet if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(1, 5); } else { armourItem.Value = Random.Range(1, 3); } break; case ArmourItemData.Type.eMEDIUM: // medium helmet if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(2, 6); } else { armourItem.Value = Random.Range(2, 4); } break; case ArmourItemData.Type.eHEAVY: // heavy helmet if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(3, 7); } else { armourItem.Value = Random.Range(3, 5); } break; default: throw new ArgumentOutOfRangeException(); } break; case ArmourItemData.SlotType.eCHEST: itemName = "Lasagna Chest"; switch (armourItem.ArmourType) { case ArmourItemData.Type.eLIGHT: //light chest if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(2, 6); } else { armourItem.Value = Random.Range(2, 4); } break; case ArmourItemData.Type.eMEDIUM: // medium chest if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(3, 7); } else { armourItem.Value = Random.Range(3, 5); } break; case ArmourItemData.Type.eHEAVY: // heavy chest if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(4, 8); } else { armourItem.Value = Random.Range(4, 6); } break; default: throw new ArgumentOutOfRangeException(); } break; case ArmourItemData.SlotType.eLEGS: itemName = "Gnocchi Boots"; switch (armourItem.ArmourType) { case ArmourItemData.Type.eLIGHT: //light helmet if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(1, 5); } else { armourItem.Value = Random.Range(1, 3); } break; case ArmourItemData.Type.eMEDIUM: // medium helmet if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(2, 6); } else { armourItem.Value = Random.Range(2, 4); } break; case ArmourItemData.Type.eHEAVY: // heavy helmet if (armourItem.MagicalType != MagicType.eNONE) { armourItem.Value = Random.Range(3, 7); } else { armourItem.Value = Random.Range(3, 5); } break; default: throw new ArgumentOutOfRangeException(); } break; default: throw new ArgumentOutOfRangeException(); } //Random description armourItem.Description = "TODO:: Add a random description"; armourItem.BaseMoneyValue = Random.Range(5, 30); armourItem.PreviewSprite = spriteManager.GetRandomArmourIcon(armourItem.ArmourSlotType); //select random name if (magicName != string.Empty) { armourItem.Name = ArmourAdjectives[Random.Range(0, ArmourAdjectives.Count)] + " " + magicName + " " + itemName; } else { armourItem.Name = ArmourAdjectives[Random.Range(0, ArmourAdjectives.Count)] + " " + itemName; } return(armourItem); }