コード例 #1
0
    IEnumerator GatherAnimation()
    {
        Collider[] hColliders = Physics.OverlapSphere(transform.position, 1);

        if (ItemID.CurrentItemId == -1)
        {
            for (int j = 0; j < hColliders.Length; j++)
            {
                for (int i = 0; i < terrain.HerbPatchObjects.Length; i++)
                {
                    if (hColliders[j].transform.name == terrain.HerbPatchObjects[i].transform.name + "(Clone)" &&
                        GatheringSkill.GatheringSkillList[2].CurrentRank >= MiscItems.Miscellaneousitems[i + MiscItems.EndlengthLogs + 1].LevelRank)
                    {
                        movement.NetworkSetHandAnimations("Gathering", 3);
                        Stats.CurrentPlayerStamina    -= GatheringSkill.GatheringSkillList[2].StaminaCost * Stats.PlayerStamina;
                        mainGUI.timeElapsedProgressBar = 3 + Time.time;
                        StartCoroutine("CheckMovement");                                                               // do this for all gathering animations, make a load bar for gathering ( 3 seconds)
                        mainGUI.StartCoroutine(mainGUI.ActivateProgressBar(0.075f, terrain.HerbPatchObjects[i].name)); // 1 / 0.075 * 0.2 = 2.66 seconds
                        yield return(new WaitForSeconds(3));                                                           // change color of herb leaves to different colors, crafting/herbloring = no weapons/tools in hand, instantiate at start knife/hammer for crafting, make animations for em, put the resource for crafting item on the bench

                        GatheringSkill.GatheringSkillList[2].CurrentExp += MiscItems.Miscellaneousitems[i].MiscellaneousItemExp;
                        GameObjectHerbIndex = i + MiscItems.EndlengthLogs + 1;
                        GameObject HerbInstantiate = PhotonNetwork.Instantiate(MiscItems.MiscellaneousGameObjects[GameObjectHerbIndex].name, transform.position + transform.forward * 2 + transform.up,
                                                                               transform.rotation, 0) as GameObject;
                        TextMesh ExpPrefabText = Instantiate(ExpPrefab, transform.position,
                                                             transform.rotation) as TextMesh;
                        ExpPrefabText.text                    = ("+" + MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].MiscellaneousItemExp);
                        ExpPrefabText.characterSize           = 0.04f;
                        ExpPrefabText.fontSize                = 275;
                        ExpPrefabText.color                   = new Color32(34, 96, 34, 255);
                        ExpPrefabText.transform.parent        = transform;
                        ExpPrefabText.transform.localPosition = Vector3.zero;
                        characterInventory.photonView.RPC("AddandRemoveDropList", PhotonTargets.AllBufferedViaServer, MiscItems.MiscellaneousGameObjects[GameObjectHerbIndex].name, "Common", HerbInstantiate.GetPhotonView().viewID,
                                                          0f, 0f, 0f, 0f, 0f, 0f, 0f, -1, 1, 1, 1, characterInventory.DroppedItemList.Count);

                        photonView.RPC("HerbPatchScale", PhotonTargets.All, hColliders[j].transform.gameObject.GetPhotonView().viewID);
                        mainGUI.timeElapsedProgressBar = Time.time + 1;
                        movement.NetworkSetHandAnimations("Gathering", 0);
                        mainGUI.CheckMovementProgressBar = false;

                        yield break;
                    }
                }
            }
        }
    }
コード例 #2
0
ファイル: ChopTrees.cs プロジェクト: Bush-Lam/Artifacts
    public IEnumerator ChoppingAnimation() // only chop down trees that are not environmental physics
    {
        for (int i = 0; i < terrain.TreeGameObjects.Length; i++)
        {
            Forward = transform.TransformDirection(Vector3.forward);

            if (Physics.Raycast(transform.position + new Vector3(0, 3, 0), Forward, out hit, 11))
            {
                if (hit.transform.name == terrain.TreeGameObjects[i].transform.name + "(Clone)" &&
                    GatheringSkill.GatheringSkillList[0].CurrentRank >= MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].LevelRank &&
                    ((ItemID.CurrentItemId >= 750 && ItemID.CurrentItemId < 800) || ItemID.CurrentItemId == -1)) // correct woodcutting level and axe needs to be considered
                {
                    Stats.CurrentPlayerStamina -= GatheringSkill.GatheringSkillList[0].StaminaCost * Stats.PlayerStamina;

                    if (ItemID.CurrentItemId == -1) // punch
                    {
                        movement.NetworkSetHandAnimations("Gathering", 4);
                        mainGUI.timeElapsedProgressBar = 5.1f + Time.time;
                        StartCoroutine("CheckMovement"); // do this for all gathering animations, make a load bar for gathering ( 3 seconds)
                        mainGUI.StartCoroutine(mainGUI.ActivateProgressBar(0.067f, terrain.TreeGameObjects[i].name));
                        yield return(new WaitForSeconds(3.4f));

                        if (Random.Range(0, 100) > 80 - (((MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].LevelRank + 5) / 5) * 30) - (MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].LevelRank / 5)) // base no tool chance == 80%
                        {
                            mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Failed to gather " + MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].MiscellaneousItemName + "."));
                            mainGUI.CheckMovementProgressBar = false;
                            yield return(new WaitForSeconds(0.7f));

                            movement.NetworkSetHandAnimations("Gathering", 0);
                            yield break;
                        }
                    }
                    else
                    {
                        movement.NetworkSetHandAnimations("Gathering", 1);
                        mainGUI.timeElapsedProgressBar = 5.1f + Time.time;
                        StartCoroutine("CheckMovement");                                                              // do this for all gathering animations, make a load bar for gathering ( 3 seconds)
                        mainGUI.StartCoroutine(mainGUI.ActivateProgressBar(0.067f, terrain.TreeGameObjects[i].name)); // 1 / 0.067f * 0.2 = 3 seconds
                        yield return(new WaitForSeconds(3.4f));

                        if (Random.Range(0, 100) > ToolID.ToolList[(ItemID.CurrentItemId - 750)].ChanceToGather - (((MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].LevelRank + 5) / 5) * 30) - (MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].LevelRank / 5)) // ex : level 0 tree(maple) = -30% , level 1 axe = 115% chance to cut down, level 1 tree(oak) = -60%, -30% every level for trees, +30% for every level axe, -1% as difficulty(woodcutting) increases
                        {
                            mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Failed to gather " + MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].MiscellaneousItemName + "."));
                            mainGUI.CheckMovementProgressBar = false;
                            yield return(new WaitForSeconds(0.7f));

                            movement.NetworkSetHandAnimations("Gathering", 0);
                            yield break;
                        }
                    }

                    GatheringSkill.GatheringSkillList[0].CurrentExp += MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].MiscellaneousItemExp;
                    GameObjectLogIndex = i + MiscItems.EndlengthBars + 1;
                    GameObject LogInstantiate = PhotonNetwork.Instantiate(MiscItems.MiscellaneousGameObjects[GameObjectLogIndex].name, new Vector3(transform.position.x, transform.position.y + 3, transform.position.z),
                                                                          MiscItems.MiscellaneousGameObjects[GameObjectLogIndex].transform.rotation, 0) as GameObject;
                    TextMesh ExpPrefabText = Instantiate(ExpPrefab, transform.position,
                                                         transform.rotation) as TextMesh;
                    ExpPrefabText.text                    = ("+" + MiscItems.Miscellaneousitems[i + MiscItems.EndlengthBars + 1].MiscellaneousItemExp);
                    ExpPrefabText.characterSize           = 0.04f;
                    ExpPrefabText.fontSize                = 275;
                    ExpPrefabText.color                   = new Color32(34, 96, 34, 255);
                    ExpPrefabText.transform.parent        = transform;
                    ExpPrefabText.transform.localPosition = Vector3.zero;
                    characterInventory.photonView.RPC("AddandRemoveDropList", PhotonTargets.AllBufferedViaServer, MiscItems.MiscellaneousGameObjects[GameObjectLogIndex].name, "Common", LogInstantiate.GetPhotonView().viewID,
                                                      0f, 0f, 0f, 0f, 0f, 0f, 0f, -1, 1, 1, 1, characterInventory.DroppedItemList.Count);

                    photonView.RPC("tScaleSize", PhotonTargets.All, hit.transform.gameObject.GetPhotonView().viewID, i);

                    mainGUI.CheckMovementProgressBar = false;
                    yield return(new WaitForSeconds(0.7f));

                    movement.NetworkSetHandAnimations("Gathering", 0);

                    yield break;
                }
            }
        }
    }
コード例 #3
0
ファイル: MineRocks.cs プロジェクト: Bush-Lam/Artifacts
    IEnumerator MiningAnimation()
    {
        for (int i = 0; i < terrain.RockGameObjects.Length; i++)
        {
            if (Physics.Raycast(new Ray(transform.position + new Vector3(0, 0.2f, 0), transform.forward), out hit, 5, 1 << 0))
            {
                if (hit.transform.name == terrain.RockGameObjects[i].transform.name + "(Clone)" &&
                    GatheringSkill.GatheringSkillList[1].CurrentRank >= MiscItems.Miscellaneousitems[i].LevelRank &&
                    (ItemID.CurrentItemId >= 800 || ItemID.CurrentItemId == -1))
                {
                    Stats.CurrentPlayerStamina -= GatheringSkill.GatheringSkillList[1].StaminaCost * Stats.PlayerStamina;

                    if (ItemID.CurrentItemId == -1) // punching - which can only be used for lvl 1 stuff.
                    {
                        movement.NetworkSetHandAnimations("Gathering", 4);
                        mainGUI.timeElapsedProgressBar = 5.1f + Time.time;
                        StartCoroutine("CheckMovement"); // do this for all gathering animations, make a load bar for gathering ( 3 seconds)
                        mainGUI.StartCoroutine(mainGUI.ActivateProgressBar(0.067f, terrain.RockGameObjects[i].name));
                        yield return(new WaitForSeconds(3.4f));

                        if (Random.Range(0, 100) > 80 - (((MiscItems.Miscellaneousitems[i].LevelRank + 5) / 5) * 30) - (MiscItems.Miscellaneousitems[i].LevelRank / 5)) // base no tool chance == 80%
                        {
                            mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Failed to gather " + MiscItems.Miscellaneousitems[i].MiscellaneousItemName + "."));
                            mainGUI.CheckMovementProgressBar = false;
                            yield return(new WaitForSeconds(0.7f));

                            movement.NetworkSetHandAnimations("Gathering", 0);
                            yield break;
                        }
                    }
                    else
                    {
                        movement.NetworkSetHandAnimations("Gathering", 2);
                        mainGUI.timeElapsedProgressBar = 5.1f + Time.time;
                        StartCoroutine("CheckMovement");                                                              // do this for all gathering animations, make a load bar for gathering ( 3 seconds)
                        mainGUI.StartCoroutine(mainGUI.ActivateProgressBar(0.067f, terrain.RockGameObjects[i].name)); // 1 / 0.067f * 0.2 = 3 seconds
                        yield return(new WaitForSeconds(3.4f));

                        if (Random.Range(0, 100) > ToolID.ToolList[(ItemID.CurrentItemId - 800 + ToolID.EndofAxeList)].ChanceToGather - (((MiscItems.Miscellaneousitems[i].LevelRank + 5) / 5) * 30) - (MiscItems.Miscellaneousitems[i].LevelRank / 5))  // ex : level 0 rock(stone) = -30% , level 1 axe = 115% chance to mine down, level 1 rock(stone) = -60%, -30% every level for trees, +30% for every level axe, -1% as difficulty(mining) increases
                        {
                            mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Failed to gather " + MiscItems.Miscellaneousitems[i].MiscellaneousItemName + "."));
                            mainGUI.CheckMovementProgressBar = false;
                            yield return(new WaitForSeconds(0.7f));

                            movement.NetworkSetHandAnimations("Gathering", 0);
                            yield break;
                        }
                    }

                    GameObjectOreIndex = i;
                    GameObject OreInstantiate = PhotonNetwork.Instantiate(MiscItems.MiscellaneousGameObjects[GameObjectOreIndex].name, new Vector3(transform.position.x, transform.position.y + 2, transform.position.z),
                                                                          MiscItems.MiscellaneousGameObjects[GameObjectOreIndex].transform.rotation, 0) as GameObject;
                    GatheringSkill.GatheringSkillList[1].CurrentExp += MiscItems.Miscellaneousitems[i].MiscellaneousItemExp;
                    TextMesh ExpPrefabText = Instantiate(ExpPrefab, transform.position,
                                                         transform.rotation) as TextMesh;
                    ExpPrefabText.text                    = ("+" + MiscItems.Miscellaneousitems[i].MiscellaneousItemExp.ToString());
                    ExpPrefabText.characterSize           = 0.04f;
                    ExpPrefabText.fontSize                = 275;
                    ExpPrefabText.color                   = new Color32(34, 96, 34, 255);
                    ExpPrefabText.transform.parent        = transform;
                    ExpPrefabText.transform.localPosition = Vector3.zero;
                    characterInventory.photonView.RPC("AddandRemoveDropList", PhotonTargets.AllBufferedViaServer, MiscItems.MiscellaneousGameObjects[GameObjectOreIndex].name, "Common", OreInstantiate.GetPhotonView().viewID,
                                                      0f, 0f, 0f, 0f, 0f, 0f, 0f, -1, 1, 1, 1, characterInventory.DroppedItemList.Count);
                    photonView.RPC("rScaleSize", PhotonTargets.AllBuffered, hit.transform.gameObject.GetPhotonView().viewID);

                    mainGUI.CheckMovementProgressBar = false;
                    yield return(new WaitForSeconds(0.7f));

                    movement.NetworkSetHandAnimations("Gathering", 0);

                    yield break;
                }
            }
        }
    }
コード例 #4
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());
        }
    }