Beispiel #1
0
    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());
        }
    }