/// <summary> /// Retrieve the armor equipped in the given slot. /// </summary> public Armor GetEquippedArmor(Armor.ArmorSlot slot) { return(equippedEquipment.Find(delegate(Equipment equipment) { Armor armor = equipment as Armor; return ((armor != null) && (armor.Slot == slot)); }) as Armor); }
/// <summary> /// Unequip any armor in the given slot. /// </summary> public void UnequipArmor(Armor.ArmorSlot slot) { equippedEquipment.RemoveAll(delegate(Equipment equipment) { Armor armor = equipment as Armor; return((armor != null) && (armor.Slot == slot)); }); RecalculateEquipmentStatistics(); RecalculateTotalDefenseRanges(); }
//Unequips the piece of armor in the given slot public void UnequipArmor(Armor.ArmorSlot slotToRemove_) { //Making sure there's a free inventory slot first if (this.CheckForEmptySlot() < 1) { return; } //Finding the correct slot to equip the armor, adding it to the inventory, and setting the slot to null switch (slotToRemove_) { case Armor.ArmorSlot.Head: this.AddItemToInventory(this.helm.GetComponent <Item>()); this.helm = null; break; case Armor.ArmorSlot.Torso: this.AddItemToInventory(this.chestPiece.GetComponent <Item>()); this.chestPiece = null; break; case Armor.ArmorSlot.Legs: this.AddItemToInventory(this.leggings.GetComponent <Item>()); this.leggings = null; break; case Armor.ArmorSlot.Hands: this.AddItemToInventory(this.gloves.GetComponent <Item>()); this.gloves = null; break; case Armor.ArmorSlot.Feet: this.AddItemToInventory(this.shoes.GetComponent <Item>()); this.shoes = null; break; case Armor.ArmorSlot.Cloak: this.AddItemToInventory(this.cloak.GetComponent <Item>()); this.cloak = null; break; case Armor.ArmorSlot.Necklace: this.AddItemToInventory(this.necklace.GetComponent <Item>()); this.necklace = null; break; case Armor.ArmorSlot.Ring: this.AddItemToInventory(this.ring.GetComponent <Item>()); this.ring = null; break; } }
// Only a helmet can go into this slot public override Item SwapItem(Item i = null) { Item temp = HeldItem; Armor ATemp = null; if (i != null) { ATemp = i.GetComponent <Armor>(); } else { HeldItem = i; SetHeldItem(); UpdateItemDisplay(); } if (ATemp != null) { Armor.ArmorSlot aSlot = ATemp.GetSlot(); if (aSlot == Armor.ArmorSlot.Footware) { HeldItem = i; SetHeldItem(); UpdateItemDisplay(); } else { temp = i; } } else { temp = i; } if (HeldItem != null) { Durability = HeldItem.durability; } else { Durability = 100; } SetDurability(Durability); return(temp); }
//Equip Methods //Only useful for players, enemies can have their equipment predefined without these methods public static void equipOn(Actor targetActor, Armor.ArmorSlot slot, Armor targetArmor) { int targetSlot = (int)slot; //check for compatability if (targetArmor.armorSlot != slot) { Console.WriteLine("This doesn't go here!"); return; } if (targetArmor.armorType == Armor.ArmorTypes.HEAVY && isHeavyTrained(targetActor)) { if (targetActor.ArmorSlotsArray[targetSlot] != null) //unequip existing item { Inventory.Add(targetActor.ArmorSlotsArray[targetSlot]); Console.WriteLine(targetActor.ArmorSlotsArray[targetSlot].name + " has been returned to Inventory."); } } targetActor.ArmorSlotsArray[targetSlot] = targetArmor; Inventory.Remove(targetArmor); }
//Function called from CheckForInvalidIDs to loop through the given armor list private void CheckList(List <IDTag> listToCheck_, string nameOfList_, Armor.ArmorSlot armorSlot_) { //Looping through all of the armor in our list for (int a1 = 0; a1 < listToCheck_.Count; ++a1) { //If this slot in the list is empty, we throw a debug if (listToCheck_[a1] == null) { Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR: ArmorIDList.CheckList " + nameOfList_ + ": Empty slot in armor list at index " + a1); } //If this ID has the wrong enum tag, we throw a debug else if (listToCheck_[a1].objType != IDTag.ObjectType.ItemArmor) { Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR: ArmorIDList.CheckList " + nameOfList_ + ": Invalid ID type at index " + a1); } //If this object doesn't have the armor component, we throw a debug else if (listToCheck_[a1].GetComponent <Armor>() == null) { Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR: ArmorIDList.CheckList " + nameOfList_ + ": Object at index " + a1 + " doesn't have the Armor component."); } //If this armor doesn't fit in the designated armor slot, we throw a debug else if (listToCheck_[a1].GetComponent <Armor>().slot != armorSlot_) { Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR: ArmorIDList.CheckList " + nameOfList_ + ": Object at index " + a1 + " doesn't fit in the " + armorSlot_ + " slot."); } } //Looping through the list again with nested for loops to check each ID against all other ID numbers for (int x = 0; x < listToCheck_.Count - 1; ++x) { for (int y = x + 1; y < listToCheck_.Count; ++y) { //If the ID numbers are the same we need to throw a debug if (listToCheck_[x].numberID == listToCheck_[y].numberID) { Debug.LogError(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR: ArmorIDList.CheckList " + nameOfList_ + ": Duplicate ID numbers on index " + x + " and " + y); } } } }
//Function used to change the armor at the given slot to the new one public void ChangeArmorItemAtSlot(Armor.ArmorSlot slot_, Armor armorToChangeTo_) { //Making sure the armor to change to actually matches the slot it's being equipped to if (armorToChangeTo_ != null && armorToChangeTo_.slot != slot_) { return; } //Finding the correct slot to replace switch (slot_) { case Armor.ArmorSlot.Head: this.helm = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; case Armor.ArmorSlot.Torso: this.chestPiece = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; case Armor.ArmorSlot.Legs: this.leggings = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; case Armor.ArmorSlot.Feet: this.shoes = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; case Armor.ArmorSlot.Hands: this.gloves = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; case Armor.ArmorSlot.Necklace: this.necklace = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; case Armor.ArmorSlot.Cloak: this.cloak = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; case Armor.ArmorSlot.Ring: this.ring = armorToChangeTo_; if (armorToChangeTo_ != null) { armorToChangeTo_.transform.SetParent(this.transform); } break; } //Updating this inventory's weight this.FindArmorStats(); }
public EquippedArmor(Player owner, Armor.ArmorSlot slot) { this.owner = owner; this.slot = slot; }