void Update() { if (_itemID != -1) { _iconToDraw = manager.itemList[_itemID].ItemIcon; _tempArmor = manager.itemList[_itemID] as ArmorItem; _tempWeapon = manager.itemList[_itemID] as WeaponItem; } else { _iconToDraw = null; } if (_iconToDraw != null) { imageSlot.color = new Color(1, 1, 1, 1); imageSlot.texture = _iconToDraw; } else { imageSlot.color = new Color(0, 0, 0, 0); } }
public void EquipArmor(ArmorItem armor) { switch (armor.MyEquipPosition) { case ItemData.EquipPosition.Cape: cape.EquipArmor(armor); break; case ItemData.EquipPosition.Gloves: gloves.EquipArmor(armor); break; case ItemData.EquipPosition.Hat: hat.EquipArmor(armor); break; case ItemData.EquipPosition.Necklace: necklace.EquipArmor(armor); break; case ItemData.EquipPosition.Pants: pants.EquipArmor(armor); break; case ItemData.EquipPosition.Shirt: Debug.Log("Equipping a shirt"); shirt.EquipArmor(armor); break; case ItemData.EquipPosition.Shoes: shoes.EquipArmor(armor); break; case ItemData.EquipPosition.Wings: wings.EquipArmor(armor); break; } }
public void TestArmorNameByRarity(EquipmentManager.EquipSlot slot, int armorRatingPosition, GameItem.ItemRarity rarity, string description) { ArmorItem armor = new ArmorItem(rarity, slot); double[] minArmor = new double[6]; double[] maxArmor = new double[6]; minArmor[armorRatingPosition] = 1; maxArmor[armorRatingPosition] = 5; double[] minSpeed = new double[6]; double[] maxSpeed = new double[6]; minSpeed[armorRatingPosition] = 1; maxSpeed[armorRatingPosition] = 5; double[] minDamage = new double[6]; double[] maxDamage = new double[6]; minDamage[armorRatingPosition] = 1; maxDamage[armorRatingPosition] = 5; string name = ItemSpawner.GenerateArmorName(5, armor, minArmor, maxArmor, minSpeed, maxSpeed, minDamage, maxDamage); string[] ssize = name.Split(null); Assert.AreEqual(ssize[0], description); }
void OnGUI() { if (itemManager != null) { List <WeaponItem> weaponList = new List <WeaponItem>(); List <ArmorItem> armorList = new List <ArmorItem>(); newItemID = _itemList.Count; for (int i = 0; i < _itemList.Count; i++) { if (_itemList[i].GetType() == typeof(WeaponItem)) { weaponList.Add((WeaponItem)_itemList[i]); } if (_itemList[i].GetType() == typeof(ArmorItem)) { armorList.Add((ArmorItem)_itemList[i]); } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Item Type: "); currentItemToCreate = (ItemToCreate)EditorGUILayout.EnumPopup(currentItemToCreate); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("General Attributes:", EditorStyles.boldLabel); newItemID = EditorGUILayout.IntField("ID (BE CAREFUL): ", newItemID); newItemName = EditorGUILayout.TextField("Name: ", newItemName); newItemDesc = EditorGUILayout.TextField("Description: ", newItemDesc); newItemValue = EditorGUILayout.IntField("Item Value: ", newItemValue); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Icon: "); newItemIcon = (Texture2D)EditorGUILayout.ObjectField(newItemIcon, typeof(Texture2D), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Rarity: "); newItemRarity = (RarityTypes)EditorGUILayout.EnumPopup(newItemRarity); EditorGUILayout.EndHorizontal(); switch (currentItemToCreate) { case ItemToCreate.Weapon: EditorGUILayout.LabelField("Weapon-Specific Attributes:", EditorStyles.boldLabel); newWeaponMaxDamage = EditorGUILayout.IntField("Max Damage: ", newWeaponMaxDamage); newWeaponMinDamage = EditorGUILayout.IntField("Min Damage: ", newWeaponMinDamage); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Damage Type: "); newWeaponDamageType = (DamageType)EditorGUILayout.EnumPopup(newWeaponDamageType); EditorGUILayout.EndHorizontal(); break; case ItemToCreate.Armor: EditorGUILayout.LabelField("Armor-Specific Attributes:", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Armor Slot: "); newArmorSlot = (ArmorSlot)EditorGUILayout.EnumPopup(newArmorSlot); EditorGUILayout.EndHorizontal(); newArmorLvl = EditorGUILayout.IntField("Armor Level: ", newArmorLvl); break; } if (GUILayout.Button("Add New Item")) { switch (currentItemToCreate) { case ItemToCreate.Weapon: WeaponItem newWeapon = (WeaponItem)ScriptableObject.CreateInstance <WeaponItem>(); newWeapon.Name = newItemName; newWeapon.ItemDescription = newItemDesc; newWeapon.ItemID = newItemID; newWeapon.ItemIcon = newItemIcon; newWeapon.Value = newItemValue; newWeapon.Rarity = newItemRarity; newWeapon.MaxDamage = newWeaponMaxDamage; newWeapon.MinDamage = newWeaponMinDamage; newWeapon.TypeOfDamage = newWeaponDamageType; newWeapon.ItemTypeV = (ItemType)currentItemToCreate; _itemList.Add(newWeapon); break; case ItemToCreate.Armor: ArmorItem newArmor = (ArmorItem)ScriptableObject.CreateInstance <ArmorItem>(); newArmor.Name = newItemName; newArmor.ItemDescription = newItemDesc; newArmor.ItemID = newItemID; newArmor.ItemIcon = newItemIcon; newArmor.Value = newItemValue; newArmor.Rarity = newItemRarity; newArmor.ArmorLevel = newArmorLvl; newArmor.Slot = newArmorSlot; newArmor.ItemTypeV = (ItemType)currentItemToCreate; _itemList.Add(newArmor); break; } } EditorGUILayout.Space(); showingLists = EditorGUILayout.Foldout(showingLists, "Item Database"); EditorGUI.indentLevel = 2; // if (showingLists){ // EditorGUILayout.LabelField("Total items: " + _itemList.Count); // EditorGUILayout.LabelField("Total weapons: " + weaponList.Count); // EditorGUILayout.LabelField("Total armor items: " + armorList.Count); // EditorGUILayout.Space(); // // scrollPos = EditorGUILayout.BeginScrollView(scrollPos); // EditorGUI.indentLevel -= 1; // showingWeapons = EditorGUILayout.Foldout(showingWeapons, "Weapons"); // if (showingWeapons){ // EditorGUI.indentLevel += 2; // for (int i = 0; i < weaponList.Count; i++){ // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField(weaponList[i].Name); // if (GUILayout.Button("-")){ // _itemList.Remove(_itemList[i]); // } // EditorGUILayout.EndHorizontal(); // EditorGUI.indentLevel +=1; // weaponList[i].ItemID = EditorGUILayout.IntField ("ID: ", weaponList[i].ItemID); // weaponList[i].Name = EditorGUILayout.TextField ("Name: ", weaponList[i].Name); // weaponList[i].ItemDescription = EditorGUILayout.TextField ("Description: ", weaponList[i].ItemDescription); // weaponList[i].Value = EditorGUILayout.IntField ("Value: ", weaponList[i].Value); // weaponList[i].MaxDamage = EditorGUILayout.IntField ("Max Damage: ", weaponList[i].MaxDamage); // weaponList[i].MinDamage = EditorGUILayout.IntField ("Min Damage: ", weaponList[i].MinDamage); // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.PrefixLabel("Damage Type: "); // weaponList[i].TypeOfDamage = (DamageType)EditorGUILayout.EnumPopup(weaponList[i].TypeOfDamage); // EditorGUILayout.EndHorizontal(); // EditorGUI.indentLevel -=1; // } // EditorGUI.indentLevel -= 2; // } // showingArmor = EditorGUILayout.Foldout(showingArmor, "Armor Items"); // if (showingArmor){ // EditorGUI.indentLevel += 2; // for (int i = 0; i < armorList.Count; i++){ // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField(armorList[i].Name); // if (GUILayout.Button("-")){ // _itemList.Remove(_itemList[i]); // } // EditorGUILayout.EndHorizontal(); // EditorGUI.indentLevel +=1; // armorList[i].ItemID = EditorGUILayout.IntField ("ID: ", armorList[i].ItemID); // armorList[i].Name = EditorGUILayout.TextField ("Name: ", armorList[i].Name); // armorList[i].ItemDescription = EditorGUILayout.TextField ("Description: ", armorList[i].ItemDescription); // armorList[i].Value = EditorGUILayout.IntField ("Value: ", armorList[i].Value); // armorList[i].ArmorLevel = EditorGUILayout.IntField("Armor Level: ", armorList[i].ArmorLevel); // EditorGUI.indentLevel -=1; // } // EditorGUI.indentLevel -= 2; // } // EditorGUILayout.EndScrollView(); // } EditorGUI.indentLevel -= 2; showingIDList = EditorGUILayout.Foldout(showingIDList, "ID list"); EditorGUI.indentLevel = 2; if (showingIDList) { for (int i = 0; i < _itemList.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(_itemList[i].ItemID.ToString() + ":\t" + _itemList[i].Name); if (GUILayout.Button("Edit")) { AssetDatabase.OpenAsset(_itemList[i]); } if (GUILayout.Button("Remove")) { if (EditorUtility.DisplayDialog("Are you sure you want to remove object?", "Cannot be undone", "Remove", "Cancel")) { _itemList.Remove(_itemList[i]); } } EditorGUILayout.EndHorizontal(); } } // if (showingLists = true) EditorGUILayout.EndScrollView(); } }
public void OnPointerClick(PointerEventData eventData) { // Debug.Log("This slot has been clicked"); if (eventData.button == PointerEventData.InputButton.Left) { Debug.Log("You clicked with your left button"); if (Inventory.MyInstance.FromSlot == null && !IsEmpty)//if we dont have something to move { //You have not picked an item up from the inventory and this slot has something in it. if (Hand.MyInstance.MyMoveable != null) { Debug.Log("If this shows up, then you are moving an item from the equipscreen into the inventory"); //If the hand has something on it anyway, then you have picked it from the equipscreen //So this section here deals with what happens when you pull an equipped item back into the inventory, but only if it swaps places with something if (Hand.MyInstance.MyMoveable is ArmorItem) { if (MyItem is ArmorItem && (MyItem as ArmorItem).MyEquipPosition == (Hand.MyInstance.MyMoveable as ArmorItem).MyEquipPosition) { Debug.Log("MyItem is: " + MyItem); //If the item in this slot is the same type of item, then they will swap places if (MyItem != Hand.MyInstance.MyMoveable as Item) { Debug.Log("These two items are not the same"); Inventory.MyInstance.FindItemInInventoryAndRemove(MyItem); (MyItem as ArmorItem).Equip(); //this eventually leads back to the equiparmor in equipbutton, which it should Inventory.MyInstance.AddItem(Hand.MyInstance.MyMoveable as Item); (Hand.MyInstance.MyMoveable as Item).Slot = this; //Makes sure i cant set the slot to the other inventory by accident } else { Debug.Log("These two items are the same"); (Hand.MyInstance.MyMoveable as Item).Slot = this; (MyItem as ArmorItem).Equip(); } Hand.MyInstance.Drop(); } } if (Hand.MyInstance.MyMoveable is WeaponItem) { if (MyItem is WeaponItem && (MyItem as WeaponItem).MyEquipPosition == (Hand.MyInstance.MyMoveable as WeaponItem).MyEquipPosition) { Debug.Log("MyItem is: " + MyItem + ". MyItem is the item that is currently in this slot"); if (MyItem != Hand.MyInstance.MyMoveable as Item) { Inventory.MyInstance.FindItemInInventoryAndRemove(MyItem); //This removes the item from the inventory. It works as intended (MyItem as WeaponItem).Equip(); Debug.Log("MyItem is: " + MyItem + ". MyItem is the item that is currently in this slot"); //This switches places with the item you click on, meaning the item on the slot ends up on the equipbutton //It leads into the item, which leads into the equipweapon function on the equipscreen Debug.Log("The item in the hand is a: " + Hand.MyInstance.MyMoveable); Inventory.MyInstance.AddItem(Hand.MyInstance.MyMoveable as Item); (Hand.MyInstance.MyMoveable as Item).Slot = this; //This makes sure that I cant accidentally set the slot to the other inventory } else { (Hand.MyInstance.MyMoveable as Item).Slot = this; (MyItem as WeaponItem).Equip(); } Hand.MyInstance.Drop(); } } } else { //In this case, the hand is empty, so you are free to pick shit up Debug.Log("Taking the item: " + MyItem.name); Hand.MyInstance.TakeMoveable(MyItem as IMoveable); (Hand.MyInstance.MyMoveable as Item).Slot = this; //this just updates what the slot is Inventory.MyInstance.FromSlot = this; Inventory.MyInstance.equipInventory.FromSlot = this; } } else if (Inventory.MyInstance.FromSlot == null && IsEmpty) { //This also cannot be executed if you have something moving, but in this case the slot IS empty. if (Hand.MyInstance.MyMoveable is ArmorItem) { ArmorItem armor = (ArmorItem)Hand.MyInstance.MyMoveable; AddItem(armor); EquipScreen.MyInstance.MySelectedButton.DequipArmor(); Inventory.MyInstance.AddItem(Hand.MyInstance.MyMoveable as Item); (Hand.MyInstance.MyMoveable as Item).Slot = this; Hand.MyInstance.Drop(); } if (Hand.MyInstance.MyMoveable is WeaponItem) { WeaponItem weapon = (WeaponItem)Hand.MyInstance.MyMoveable; AddItem(weapon); EquipScreen.MyInstance.MySelectedButton.DequipWeapon(); Inventory.MyInstance.AddItem(Hand.MyInstance.MyMoveable as Item); (Hand.MyInstance.MyMoveable as Item).Slot = this; Hand.MyInstance.Drop(); } } else if (Inventory.MyInstance.FromSlot != null)//if we have something to move { //If the inventory has something in its fromslot, which means theres an item on the move Debug.Log("There is something in the FromSlot"); if (PutItemBack() || MergeItems(Inventory.MyInstance.FromSlot) || SwapItems(Inventory.MyInstance.FromSlot) || AddItems(Inventory.MyInstance.FromSlot.itemStack)) { Hand.MyInstance.Drop(); Inventory.MyInstance.FromSlot = null; Inventory.MyInstance.equipInventory.FromSlot = null; } } } if (eventData.button == PointerEventData.InputButton.Right && Hand.MyInstance.MyMoveable == null) { UseItem(); } }
public void getArmors() { bool inArmorSection = false; string name = ""; string title = ""; int id = 0; int armor = 0; float reduction = 0.0f; int worth = 0; int amount = 0; XmlReader reader = XmlReader.Create((new StringReader(xmldoc.InnerXml))); while (reader.Read() && inArmorSection == false) { if (reader.NodeType.Equals(XmlNodeType.Element) && reader.Name.Equals("Armor")) { inArmorSection = true; break; } } while (reader.Read()) { if (reader.NodeType.Equals(XmlNodeType.EndElement) && reader.Name.Equals("Armor")) { break; } else if (reader.NodeType.Equals(XmlNodeType.EndElement) && reader.Name.Equals("BaseItem")) { items[id] = new ArmorItem(id, name, armor, reduction, title, amount, worth); } else if (reader.NodeType.Equals(XmlNodeType.Element)) { if (reader.HasAttributes) { name = reader.GetAttribute("name"); } else if (reader.Name.Equals("title")) { reader.Read(); title = reader.Value; } else if (reader.Name.Equals("worth")) { reader.Read(); worth = int.Parse(reader.Value); } else if (reader.Name.Equals("amount")) { reader.Read(); amount = int.Parse(reader.Value); } else if (reader.Name.Equals("armor")) { reader.Read(); armor = int.Parse(reader.Value); } else if (reader.Name.Equals("reduction")) { reader.Read(); reduction = float.Parse(reader.Value); } else if (reader.Name.Equals("id")) { reader.Read(); id = int.Parse(reader.Value); } } } }
public void EquipArmor(ArmorItem newArmor) { inventoryObject.EquipArmor(newArmor); armor.AddItem(newArmor); armor.ShowIcon(true); }
public void AddArmorItem(ArmorItem item) { Equipment.Armor = item; ArmorValue.InitialValue = item.armorValue; UpdateArmor.Raise(); }
public void OnDiscard(int discard_num, BagInfo bag) { if (discard_num <= 0) { return; } bool isequip = false; switch (Item.ItemType) { case ItemType.Weapon: WeaponItem weapon = Item as WeaponItem; if (weapon == null) { break; } isequip = weapon.IsEqu; break; case ItemType.Armor: ArmorItem armor = Item as ArmorItem; if (armor == null) { break; } isequip = armor.IsEqu; break; case ItemType.Jewelry: JewelryItem jewelry = Item as JewelryItem; if (jewelry == null) { break; } isequip = jewelry.IsEqu; break; } if (isequip) { throw new System.Exception("装备中的物品不能丢弃"); } if (Quantity <= 0) { throw new System.Exception("该物品为空"); } if (!bag.itemList.Exists(i => i.Item == Item)) { throw new System.Exception("该物品未在行囊里"); } int finallyDiscard = StackAble ? Quantity - discard_num > 0 ? discard_num : Quantity : 1; //Debug.Log("最终丢弃数为" + finallyDiscard); Quantity -= finallyDiscard; bag.Current_Weight -= Item.Weight * finallyDiscard; if (Quantity <= 0) { bag.Current_Size -= 1; bag.itemList.Remove(this); } bag.CheckSizeAndWeight(); }
/// <summary> /// Event function for updating the armor text /// </summary> /// <param name="newItem"></param> /// <param name="oldItem"></param> private void UpdateArmorUI(ArmorItem newItem, ArmorItem oldItem) { SetAmorValue(); }
public void RemoveArmor() { armor = null; }
public void EquipArmor(ArmorItem newArmor) { armor = newArmor; }
public Task <ArmorItem> PickArmor(ArmorItem defaultItem) { return(PickArmor(GameState, defaultItem)); }
public void TestArmorDescription(EquipmentManager.EquipSlot slot, string description) { ArmorItem armor = new ArmorItem(slot); Assert.AreEqual(description, ItemSpawner.GenerateArmorDesc(5, armor)); }
public void Equip(ArmorItem item) { inventory.Remove(item); Unequip(item.type); armor[item.type] = item; }
public void AddItemToInventory(ArmorItem item) { inventory.Add(item); }
public void LoseItem(ItemBase item, int lose_num) { if (item == null || lose_num <= 0) { return; } if (Current_Size <= 0) { throw new System.Exception("背包为空"); } ItemInfo tempitem = itemList.Find(i => i.Item == item); if (tempitem == null) { throw new System.Exception("该物品未在行囊中"); } bool isequip = false; switch (tempitem.Item.ItemType) { case ItemType.Weapon: WeaponItem weapon = tempitem.Item as WeaponItem; if (weapon == null) { break; } isequip = weapon.IsEqu; break; case ItemType.Armor: ArmorItem armor = tempitem.Item as ArmorItem; if (armor == null) { break; } isequip = armor.IsEqu; break; case ItemType.Jewelry: JewelryItem jewelry = tempitem.Item as JewelryItem; if (jewelry == null) { break; } isequip = jewelry.IsEqu; break; case ItemType.Mount: MountItem mount = tempitem.Item as MountItem; if (mount == null) { break; } isequip = mount.IsEqu; break; } if (isequip) { throw new System.Exception("该物品已装备"); } if (tempitem.Quantity <= 0) { throw new System.Exception("该物品为空"); } int finallyDiscard = tempitem.StackAble ? tempitem.Quantity - lose_num > 0 ? lose_num : tempitem.Quantity : 1; tempitem.Quantity -= finallyDiscard; Current_Weight -= tempitem.Item.Weight * finallyDiscard; if (tempitem.Quantity <= 0) { Current_Size -= 1; itemList.Remove(tempitem); } CheckSizeAndWeight(); }
public void DequipArmor() { icon.color = Color.white; icon.enabled = false; equippedArmorItem = null; }
/// <summary> /// Generation function designed to build an armor item for spawning. Can fit any slot. /// </summary> /// <param name="seed">Seed to use for generation, useful for testing. Set this to system time during playtime.</param> /// <param name="rarity">Minimum item rarity, defaults to common. Higher rarity items have better stats implicitly.</param> /// <returns>A weapon item, with name and description pre-set based on the item spec.</returns> public static ArmorItem GenerateArmor(int seed, int quality, GameItem.ItemRarity rarity = GameItem.ItemRarity.COMMON, bool useSeed = true) { // Some constants to use for calculations: double[] minArmorRarityRatings = { 1, 2, 3, 4, 5 }; // Scaling factor for minimum based on rarity. Min * RarityRating = Absolute Minimum double[] minArmorRatings = { 5, 10, 15, 5, 1, 1 }; // Minimum rating per armor slot, in enum order. double[] maxArmorRatings = { 20, 50, 100, 10, 5, 5 }; // Maximum rating per armor slot, in enum order. double[] minSpeedRarityRatings = { 1, 1.25, 1.5, 1.75, 2 }; // Scaling factor for minimum based on rarity. double[] minSpeedRatings = { 0, 1, 0, 0, 1, 1 }; // Minimum rating per armor slot, in enum order. double[] maxSpeedRatings = { 2, 5, 2, 1, 5, 5 }; // Maximum rating per armor slot, in enum order. double[] minDamageRarityRatings = { 1, 1.25, 1.5, 1.75, 2 }; // Scaling factor for minimum based on rarity. double[] minDamageRatings = { 0, 0, 0, 1, 1, 1 }; // Minimum rating per armor slot, in enum order. double[] maxDamageRatings = { 2, 2, 2, 5, 5, 5 }; // Maximum rating per armor slot, in enum order. // For reference, ENUM Order: HEAD, LEGS, CHEST, GLOVES, RING, NECK. // Note we are using the system's random, and not Unity's in order to use a seed. Random random = GetRandom(seed, useSeed); // Select rarity first; this determines effectiveness. int totalWeight = 0; for (int i = 0; i < rarityWeights.Length; i++) { totalWeight += rarityWeights[i]; } int randRarity = random.Next(totalWeight); int trueRarity = -1; totalWeight = rarityWeights[0]; for (int i = 1; i < rarityWeights.Length && trueRarity == -1; i++) { if (randRarity < totalWeight) { trueRarity = i - 1; } totalWeight += rarityWeights[i]; } // Rarity is guaurnteed to increase for every X floors of depth. trueRarity += (quality / floorRarityBoostThreshold); if (trueRarity > 4) { trueRarity = 4; } // Determine slot for armor. int trueSlot = random.Next(Enum.GetNames(typeof(EquipmentManager.EquipSlot)).Length); // Determine sprite info (somehow). TODO (I'm not sure how to do this) // Calculate the armor's values. double weightedMinArmor = minArmorRatings[trueSlot] * minArmorRarityRatings[trueRarity]; if (weightedMinArmor > maxArmorRatings[trueSlot]) { weightedMinArmor = maxArmorRatings[trueSlot]; } double weightedMinSpeed = minSpeedRatings[trueSlot] * minSpeedRarityRatings[trueRarity]; if (weightedMinArmor > maxSpeedRatings[trueSlot]) { weightedMinArmor = maxSpeedRatings[trueSlot]; } double weightedMinDamage = minDamageRatings[trueSlot] * minDamageRarityRatings[trueRarity]; if (weightedMinArmor > maxDamageRatings[trueSlot]) { weightedMinArmor = maxDamageRatings[trueSlot]; } double armor = random.NextDouble() * (maxArmorRatings[trueSlot] - weightedMinArmor) + weightedMinArmor; double speed = random.NextDouble() * (maxSpeedRatings[trueSlot] - weightedMinSpeed) + weightedMinSpeed; double damage = random.NextDouble() * (maxDamageRatings[trueSlot] - weightedMinDamage) + weightedMinDamage; // Determine, based on rarity, if armor is allowed to have speed or damage. if (trueRarity < 1) { speed = 0; damage = 0; } else if (trueRarity < 2) { if (speed > damage) { damage = 0; } else { speed = 0; } } // Build the armor item. ArmorItem newItem = new ArmorItem((EquipmentManager.EquipSlot)trueSlot, armor, speed, damage) { Rarity = (GameItem.ItemRarity)trueRarity }; // Generate a name. newItem.Name = GenerateArmorName(seed, newItem, minArmorRatings, maxArmorRatings, minSpeedRatings, maxSpeedRatings, minDamageRatings, maxDamageRatings, useSeed); // Generate a description. newItem.Description = GenerateArmorDesc(seed, newItem, useSeed); // Pick a value rating. (Should probably be another utility method). newItem.Value = GenerateItemValue(newItem); // Generate a unique ID (this might require some internal memory somewhere to keep track of what IDs have already been assigned, probably another utility function). newItem.ItemID = GenerateItemID(); // Return the finished item. return(newItem); }
public void AssignArmor(object TheArmor) { ArmorItem Item = (ArmorItem)TheArmor; switch (Item.GetArmorPos()) { case Armorpiece.Head: if (EquippedArmor[0] != null) { AC -= EquippedArmor[0].GetAC(); EquippedArmor[0] = Item; AC += Item.GetAC(); } else { EquippedArmor[0] = Item; AC += Item.GetAC(); } break; case Armorpiece.Chest: if (EquippedArmor[1] != null) { AC -= EquippedArmor[1].GetAC(); EquippedArmor[1] = Item; AC += Item.GetAC(); } else { EquippedArmor[1] = Item; AC += Item.GetAC(); } break; case Armorpiece.Legs: if (EquippedArmor[2] != null) { AC -= EquippedArmor[2].GetAC(); EquippedArmor[2] = Item; AC += Item.GetAC(); } else { EquippedArmor[2] = Item; AC += Item.GetAC(); Console.WriteLine(AC); } break; case Armorpiece.Hands: if (EquippedArmor[3] != null) { AC -= EquippedArmor[3].GetAC(); EquippedArmor[3] = Item; AC += Item.GetAC(); } else { EquippedArmor[3] = Item; AC += Item.GetAC(); } break; default: Console.WriteLine("Error"); break; } }
private void CharacterManagerOnArmorChanged(ArmorItem armor) { _armorButton.GetComponent <Image>().sprite = armor != null ? armor.Image : _unequippedSprite; }