public void EquipArmor(Armor armor) { switch (armor.MyArmorType) { case ArmorType.Head: Head.EquipArmor(armor); break; case ArmorType.Chest: Chest.EquipArmor(armor); break; case ArmorType.MainHand: MainHand.EquipArmor(armor); break; case ArmorType.Offhand: Offhand.EquipArmor(armor); break; case ArmorType.Charm: Charm1.EquipArmor(armor); break; } }
private void ConstructCatalog(GetCatalogItemsResult result) { items = result.Catalog; renderCatalog = true; itemIcons = new Dictionary <string, Texture2D>(); for (int x = 0; x < items.Count; x++) { Dictionary <string, string> customData = JsonReader.Deserialize <Dictionary <string, string> >(items[x].CustomData); itemIcons.Add(items[x].ItemId, icons[customData["Icon"]]); if (listEquipments && items[x].ItemClass.Equals("Mainhand") && !PlayFabGameBridge.mainhandType.ContainsKey(items[x].ItemId)) { // Use unique id of weapon to add new item. // float.Parse(customData["Frequency"]) string newMainhandName = items[x].ItemId; Weapon newMainhand = new Weapon { /*Parse custom data here*/ }; PlayFabGameBridge.mainhandName.Add(newMainhandName); PlayFabGameBridge.mainhandType.Add(newMainhandName, newMainhand); } if (listEquipments && items[x].ItemClass.Equals("Offhand") && !PlayFabGameBridge.offhandType.ContainsKey(items[x].ItemId)) { // Use unique id of offhand to add new item. string newOffhandName = items[x].ItemId; Offhand newOffhand = new Offhand { /*Parse custom data here*/ }; PlayFabGameBridge.offhandName.Add(newOffhandName); PlayFabGameBridge.offhandType.Add(newOffhandName, newOffhand); } if (listEquipments && items[x].ItemClass.Equals("Armor") && !PlayFabGameBridge.armorType.ContainsKey(items[x].ItemId)) { // Use unique id of armor to add new item. string newArmorName = items[x].ItemId; Armor newArmor = new Armor { /*Parse custom data here*/ }; PlayFabGameBridge.armorName.Add(newArmorName); PlayFabGameBridge.armorType.Add(newArmorName, newArmor); } if (listPotions && items[x].ItemClass.Equals("Potions") && !PlayFabGameBridge.potionType.ContainsKey(items[x].ItemId)) { // Use unique id of potion to add new item. string newPotionName = items[x].ItemId; Potion newPotion = new Potion { /*Parse custom data here*/ }; PlayFabGameBridge.potionName.Add(newPotionName); PlayFabGameBridge.potionType.Add(newPotionName, newPotion); } } Time.timeScale = 1; }
public void Construct(HeroInventory heroInventory) { HeroInventory = heroInventory; gameObject.SetActive(true); if (Helmet != null) { Helmet.Construct(heroInventory.Helmet); } if (Armor != null) { Armor.Construct(heroInventory.Armor); } if (Weapon != null) { Weapon.Construct(heroInventory.Weapon); } if (Offhand != null) { Offhand.Construct(heroInventory.Offhand); } }
public Gear removeWeapon(Gear newlyEquippedWeapon, bool canDuelEquip = true, int removedWeaponIndex = -1) { Gear removed = null; if (removedWeaponIndex != -1) { removed = equippedWeapons[removedWeaponIndex]; if (removed != null && removed.ItemType == ITypes.Offhand) { Offhand spellbook = (Offhand)equippedWeapons[1]; foreach (ElementAttributes e in spellbook.Element) { Hero.Element.Remove(e); } } equippedWeapons[removedWeaponIndex] = null; } else if (Hero.heroRole == Classes.Sentinel || Hero.heroRole == Classes.Juggernaut) { if (newlyEquippedWeapon.ItemType == ITypes.Armor) { removed = equippedWeapons[1]; equippedWeapons[1] = null; } else { removed = equippedWeapons[0]; equippedWeapons[0] = null; } } else if (!canDuelEquip) { removed = equippedWeapons[0]; equippedWeapons[0] = null; } else { if (equippedWeapons[0] != null && equippedWeapons[0].EquipableIn.Contains(Slots.Hand_Both)) { removed = equippedWeapons[0]; equippedWeapons[0] = null; } else if (newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Primary) && newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Auxillary)) { removed = equippedWeapons[1]; equippedWeapons[1] = null; } else if (newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Primary)) { removed = equippedWeapons[0]; equippedWeapons[0] = null; } else if (newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Auxillary)) { removed = equippedWeapons[1]; if (removed != null && removed.ItemType == ITypes.Offhand) { Offhand spellbook = (Offhand)equippedWeapons[1]; foreach (ElementAttributes e in spellbook.Element) { Hero.Element.Remove(e); } } equippedWeapons[1] = null; } } if (removed != null) { if (Hero.heroRole == Classes.Sentinel || Hero.heroRole == Classes.Juggernaut) { slotsOpen = 2; } else if (!canDuelEquip) { slotsOpen += 2; } else { slotsOpen += (removed.EquipableIn.Contains(Slots.Hand_Both)) ? 2 : 1; } } return(removed); }
public void equipWeapon(Gear weapon, Hero hero, bool duelEquip) { int handsTaken = (weapon.EquipableIn.Contains(Enums.Slots.Hand_Both)) ? 2 : 1; bool equipped = false; if (!duelEquip && Hero.heroRole != Classes.Sentinel && Hero.heroRole != Classes.Juggernaut) { if (equippedWeapons[0] == null) { equippedWeapons[0] = weapon; equipped = true; } } else if (Hero.heroRole == Classes.Sentinel || Hero.heroRole == Classes.Juggernaut) { if (weapon.ItemType == ITypes.Armor && equippedWeapons[1] == null) { equippedWeapons[1] = weapon; equipped = true; } else { equippedWeapons[0] = weapon; equipped = true; } } else { for (int i = 0; i < weapon.EquipableIn.Count && !equipped; i++) { switch (weapon.EquipableIn[i]) { case Slots.Hand_Both: if (equippedWeapons[0] == null && equippedWeapons[1] == null && slotsOpen == 2) { equippedWeapons[0] = weapon; equipped = true; } break; case Slots.Hand_Primary: if (equippedWeapons[0] == null && slotsOpen >= 1) { equippedWeapons[0] = weapon; equipped = true; } break; case Slots.Hand_Auxillary: if (equippedWeapons[1] == null && slotsOpen >= 1) { equippedWeapons[1] = weapon; if (weapon.ItemType == ITypes.Offhand) { Offhand spellbook = (Offhand)weapon; foreach (ElementAttributes e in spellbook.Element) { if (Hero.Element != null && !Hero.Element.Contains(e)) { Hero.Element.Add(e); } else if (Hero.Element == null) { Hero.Element.Add(e); } } } equipped = true; } break; } } } if (equipped) { if (!duelEquip) { slotsOpen -= 2; } else { slotsOpen -= (equipped) ? handsTaken : 0; } } }