IEnumerator PointerStay() { yield return(null); if (inventoryWindow.CurrentUpgradeItemSlot != -1) { for (int i = 0; i < characterInventory.InventoryManage.Count; i++) // upgrade item { if (inventoryWindow.CurrentUpgradeItemSlot == characterInventory.InventoryManage[i].CurrentInventorySlot && characterInventory.InventoryManage[i].isASecondary == 0 && (characterInventory.InventoryManage[i].DamageOrValue > 0 || characterInventory.InventoryManage[i].Defense > 0) && characterInventory.InventoryManage[i].Rarity != "Mythic") { //if we are wearing the item to be upgraded, then destroy and make icon into uitexture if (inventoryWindow.CurrentUpgradeItemSlot == armorSwitch.CurrentHelmetIteration) { characterInventory.InventoryButtonRects[characterInventory.InventoryManage[i].CurrentInventorySlot].transform.GetComponentInChildren <Image>().color = new Color(1, 1, 1, 0.66f); armorSwitch.DestroyObject(armorSwitch.CurrentHelmet, 1); } else if (inventoryWindow.CurrentUpgradeItemSlot == armorSwitch.CurrentChestplateIteration) { characterInventory.InventoryButtonRects[characterInventory.InventoryManage[i].CurrentInventorySlot].transform.GetComponentInChildren <Image>().color = new Color(1, 1, 1, 0.66f); armorSwitch.DestroyObject(armorSwitch.CurrentChestplate, 0); } else if (inventoryWindow.CurrentUpgradeItemSlot == armorSwitch.CurrentLegsIteration) { characterInventory.InventoryButtonRects[characterInventory.InventoryManage[i].CurrentInventorySlot].transform.GetComponentInChildren <Image>().color = new Color(1, 1, 1, 0.66f); armorSwitch.DestroyObject(armorSwitch.CurrentLegs, 2); } else if (inventoryWindow.CurrentUpgradeItemSlot == wepSwitch.CurrentWeaponItemSlot) { characterInventory.InventoryButtonRects[characterInventory.InventoryManage[i].CurrentInventorySlot].transform.GetComponentInChildren <Image>().color = new Color(1, 1, 1, 0.66f); wepSwitch.DropObject(wepSwitch.CurrentWeaponItemSlot); } PreviousUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.InventoryManage[i].tSprite; PreviousUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; AfterUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.InventoryManage[i].tSprite; AfterUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; if (characterInventory.InventoryManage[i].Defense > 0) { HoverRarity(characterInventory.InventoryManage[i].Rarity, "Armor"); } else { HoverRarity(characterInventory.InventoryManage[i].Rarity, "Weapon"); } transform.Find("UpgradeChance").GetComponentInChildren <Text>().text = "Success: " + CurrentSuccessRate.ToString() + "% \n" + "Destroy(Failure): " + CurrentDestroyRate.ToString() + "% "; CurrentPointerEnterName = string.Empty; CurrentUpgradeIndex = inventoryWindow.CurrentUpgradeItemSlot; inventoryWindow.CurrentUpgradeItemSlot = -1; inventoryWindow.UpgradeIndex = -1; break; } else if (inventoryWindow.CurrentUpgradeItemSlot == characterInventory.InventoryManage[i].CurrentInventorySlot && characterInventory.InventoryButtonsIcons[characterInventory.InventoryManage[i].CurrentInventorySlot].sprite.name.Contains("Shard")) // remove shard and then attempt upgrade { if (characterInventory.InventoryManage[i].Rarity + " Weapon" == AfterRarity || characterInventory.InventoryManage[i].Rarity + " Armor" == AfterRarity) { if (characterGUI.NearACraftingStation("Shard") == false || characterGUI.EquippedCraftingTool("Blacksmithing") == false) { break; } GameObject shard = PhotonNetwork.Instantiate(characterInventory.InventoryManage[i].SlotName, characterGUI.CurrentCraftingStation.transform.position + new Vector3(0, 2, 0), Quaternion.identity, 0); shard.GetComponent <Collider>().isTrigger = true; shard.GetComponent <Rigidbody>().isKinematic = true; shard.transform.SetParent(characterGUI.CurrentCraftingStation.transform); shard.transform.localPosition = new Vector3(-0.5f, 0.5f, 0.8f); shard.transform.localRotation = Quaternion.Euler(-90, 0, 0); GameObject weapon = PhotonNetwork.Instantiate(characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName, characterGUI.CurrentCraftingStation.transform.position + new Vector3(0, 2, 0), Quaternion.identity, 0); weapon.GetComponent <Collider>().isTrigger = true; weapon.GetComponent <Rigidbody>().isKinematic = true; weapon.transform.SetParent(characterGUI.CurrentCraftingStation.transform); if (characterInventory.InventoryManage[i].Rarity + " Armor" == AfterRarity) { if (characterInventory.InventoryManage[i].SlotName.Contains("Chest")) { weapon.transform.localPosition = new Vector3(-0.447f, -1.059f, 0.012f); weapon.transform.localRotation = Quaternion.Euler(-90, 0, 90); } else if (characterInventory.InventoryManage[i].SlotName.Contains("Helmet")) { weapon.transform.localPosition = new Vector3(-0.9f, -1.862f, 0.6f); weapon.transform.localRotation = Quaternion.Euler(0, 0, 0); } else if (characterInventory.InventoryManage[i].SlotName.Contains("Legs")) { weapon.transform.localPosition = new Vector3(-0.9f, -1.862f, 0.6f); weapon.transform.localRotation = Quaternion.Euler(0, 0, 0); } } else { weapon.transform.localPosition = new Vector3(-0.9f, 0.5f, 0.4f); weapon.transform.localRotation = Quaternion.Euler(-90, 0, 0); } mainGUI.timeElapsedProgressBar = 4.9f + Time.time; mainGUI.StartCoroutine(mainGUI.ActivateProgressBar(0.055f, "Upgrading " + characterInventory.InventoryManage[i].SlotName)); characterGUI.StartCoroutine("CheckMovement"); //if (Tools.ToolList[a].ToolId != 1 && Tools.ToolList[a].ToolId != 850) movement.NetworkSetHandAnimations("Crafting", 3); //characterGUI.StartCoroutine(characterGUI.CraftingComponents("Tools", a, 1)); // crafting components shown on table/furnace yield return(new WaitForSeconds(3.925f)); movement.NetworkSetHandAnimations("Crafting", 0); // crafting animation 0 mainGUI.CheckMovementProgressBar = false; PhotonNetwork.Destroy(shard); PhotonNetwork.Destroy(weapon); characterInventory.InventoryButtonsIcons[characterInventory.InventoryManage[i].CurrentInventorySlot].sprite = characterInventory.DefaultSprite; characterInventory.InventoryButtonsIcons[characterInventory.InventoryManage[i].CurrentInventorySlot].transform.GetComponentInChildren <Mask>().showMaskGraphic = false; characterInventory.InventoryButtonRects[characterInventory.InventoryManage[i].CurrentInventorySlot].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); characterInventory.InventoryManage.RemoveAt(i); CreateRarity(); } else { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("You must use the correct shard.")); } break; } } } if (CurrentPointerEnterName != PreviousUpgradedIcon.name) { StopCoroutine(PointerStay()); } else if (CurrentPointerEnterName == PreviousUpgradedIcon.name) { StartCoroutine(PointerStay()); } }
public void dropitem(GameObject PreviousButtonLocation) { for (int i = 0; i < InventoryManage.Count; i++) // misc and pots { if (InventoryManage[i].CurrentInventorySlot == int.Parse(PreviousButtonLocation.name) && InventoryManage[i].isASecondary == 1) { Image DropAmountImageRef = Instantiate(DropAmountImage, new Vector2(0, 0), transform.rotation) as Image; DropAmountImageRef.transform.SetParent(terrain.canvas.transform); DropAmountImageRef.transform.localScale = new Vector3(1, 1, 1); DropAmountImageRef.GetComponent <RectTransform>().localPosition = new Vector2(0, 0); DropAmountImageRef.transform.Find("Image").Find("ImageSprite").GetComponent <Image>().sprite = InventoryManage[i].tSprite; DropAmountImageRef.GetComponentInChildren <Button>().onClick.AddListener(() => DropStackAmounts(DropAmountImageRef, PreviousButtonLocation)); } else if (InventoryManage[i].CurrentInventorySlot == int.Parse(PreviousButtonLocation.name) && InventoryManage[i].isASecondary == 0) // for weapons/armors that are primary { if (InventoryManage[i].CurrentInventorySlot == SwitchWeapons.CurrentWeaponItemSlot) { InventoryButtonRects[SwitchWeapons.CurrentWeaponItemSlot].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); SwitchWeapons.DropObject(InventoryManage[i].CurrentInventorySlot); SwitchWeapons.DestroyObject(SwitchWeapons.CurrentProjectileObject, 1); } else if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentChestplateIteration || InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentHelmetIteration || InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentLegsIteration) // armor { if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentChestplateIteration) { InventoryButtonRects[SwitchArmor.CurrentChestplateIteration].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); } else if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentHelmetIteration) { InventoryButtonRects[SwitchArmor.CurrentHelmetIteration].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); } else if (InventoryManage[i].CurrentInventorySlot == SwitchArmor.CurrentLegsIteration) { InventoryButtonRects[SwitchArmor.CurrentLegsIteration].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); } SwitchArmor.DropObject(InventoryManage[i].CurrentInventorySlot); } GameObject Item = PhotonNetwork.Instantiate(InventoryManage[i].SlotName, terrain.Player.transform.position + new Vector3(0, 2, 0) + terrain.Player.transform.forward, terrain.Player.transform.rotation, 0) as GameObject; terrain.canvas.GetPhotonView().RPC("AddandRemoveDropList", PhotonTargets.AllBufferedViaServer, InventoryManage[i].SlotName, InventoryManage[i].Rarity, Item.GetPhotonView().viewID, InventoryManage[i].DamageOrValue, InventoryManage[i].WeaponAttackSpeed, InventoryManage[i].CritRate, InventoryManage[i].ArmorPenetration, InventoryManage[i].Defense, InventoryManage[i].Health, InventoryManage[i].Stamina, -1, 1, 0, 1, DroppedItemList.Count); if (Item.GetComponentInChildren <SkinnedMeshRenderer>()) { Item.GetComponentInChildren <SkinnedMeshRenderer>().material = new Material(Item.GetComponentInChildren <SkinnedMeshRenderer>().material); // create new instance for material seperate from rocks/trees } else { Item.GetComponentInChildren <MeshRenderer>().material = new Material(Item.GetComponentInChildren <MeshRenderer>().material); // create new instance for material seperate from rocks/trees } Color color = Color.white; if (InventoryManage[i].Rarity == "Rare") { color = Color.blue; } if (InventoryManage[i].Rarity == "Epic") { color = Color.magenta; } if (InventoryManage[i].Rarity == "Unique") { color = Color.red; } if (InventoryManage[i].Rarity == "Legendary") { color = Color.green; } if (InventoryManage[i].Rarity == "Mythic") { color = Color.cyan; } SwitchArmor.gameObject.GetPhotonView().RPC("MultiplayerGlow", PhotonTargets.AllBufferedViaServer, Item.GetPhotonView().viewID, color.r, color.g, color.b); InventoryManage.RemoveAt(i); // remove from inventorymanage and add to droplist PreviousButtonLocation.transform.Find("ImageScript").GetComponent <Image>().sprite = DefaultSprite; PreviousButtonLocation.transform.GetComponentInChildren <Mask>().showMaskGraphic = false; } } }