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; } } } } }
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; } } } }
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; } } } }
public void CreateRarity() { int RandomNumber = Random.Range(0, 101); for (int i = 0; i < characterInventory.InventoryManage.Count; i++) { if (CurrentUpgradeIndex == characterInventory.InventoryManage[i].CurrentInventorySlot) { CurrentItemLocationIndex = i; } } if (CurrentItemLocationIndex == -1) { return; } switch (characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity) { case "Common": if (RandomNumber <= 40) { characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity = "Rare"; RarityCoeff = 1.04f; mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Successful upgrade.")); } else { RandomNumber = Random.Range(0, 101); if (RandomNumber <= 15) //destroyed { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText(characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName + " is destroyed in the process.")); characterInventory.InventoryManage.RemoveAt(CurrentItemLocationIndex); characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].sprite = characterInventory.DefaultSprite; characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].transform.GetComponentInChildren <Mask>().showMaskGraphic = false; characterInventory.InventoryButtonRects[CurrentUpgradeIndex].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); CurrentItemLocationIndex = -1; CurrentUpgradeIndex = -1; PreviousUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; PreviousUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; AfterUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; AfterUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; } else { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("That didn't seem to do anything.")); } } break; case "Rare": if (RandomNumber <= 25) { characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity = "Epic"; RarityCoeff = 1.08f; mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Successful upgrade.")); } else { RandomNumber = Random.Range(0, 101); if (RandomNumber <= 20) //destroyed { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText(characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName + " is destroyed in the process.")); characterInventory.InventoryManage.RemoveAt(CurrentItemLocationIndex); characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].sprite = characterInventory.DefaultSprite; characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].transform.GetComponentInChildren <Mask>().showMaskGraphic = false; characterInventory.InventoryButtonRects[CurrentUpgradeIndex].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); CurrentItemLocationIndex = -1; CurrentUpgradeIndex = -1; PreviousUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; PreviousUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; AfterUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; AfterUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; } else { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("That didn't seem to do anything.")); } } break; case "Epic": if (RandomNumber <= 20) { characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity = "Unique"; RarityCoeff = 1.12f; mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Successful upgrade.")); } else { RandomNumber = Random.Range(0, 101); if (RandomNumber <= 25) //destroyed { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText(characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName + " is destroyed in the process.")); characterInventory.InventoryManage.RemoveAt(CurrentItemLocationIndex); characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].sprite = characterInventory.DefaultSprite; characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].transform.GetComponentInChildren <Mask>().showMaskGraphic = false; characterInventory.InventoryButtonRects[CurrentUpgradeIndex].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); CurrentItemLocationIndex = -1; CurrentUpgradeIndex = -1; PreviousUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; PreviousUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; AfterUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; AfterUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; } else { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("That didn't seem to do anything.")); } } break; case "Unique": if (RandomNumber <= 15) { characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity = "Legendary"; RarityCoeff = 1.16f; mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Successful upgrade.")); } else { RandomNumber = Random.Range(0, 101); if (RandomNumber <= 30) //destroyed { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText(characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName + " is destroyed in the process.")); characterInventory.InventoryManage.RemoveAt(CurrentItemLocationIndex); characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].sprite = characterInventory.DefaultSprite; characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].transform.GetComponentInChildren <Mask>().showMaskGraphic = false; characterInventory.InventoryButtonRects[CurrentUpgradeIndex].transform.GetComponent <Image>().color = new Color(1, 1, 1, 0.66f); CurrentItemLocationIndex = -1; CurrentUpgradeIndex = -1; PreviousUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; PreviousUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; AfterUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; AfterUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; } else { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("That didn't seem to do anything.")); } } break; case "Legendary": if (RandomNumber <= 10) { characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity = "Mythic"; RarityCoeff = 1.20f; mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("Successful upgrade.")); } else { RandomNumber = Random.Range(0, 101); if (RandomNumber <= 30) //destroyed { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText(characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName + " is destroyed in the process.")); characterInventory.InventoryManage.RemoveAt(CurrentItemLocationIndex); characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].sprite = characterInventory.DefaultSprite; characterInventory.InventoryButtonsIcons[CurrentUpgradeIndex].transform.GetComponentInChildren <Mask>().showMaskGraphic = false; CurrentItemLocationIndex = -1; CurrentUpgradeIndex = -1; PreviousUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; PreviousUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; AfterUpgradedIcon.transform.GetComponent <Image>().sprite = characterInventory.DefaultSprite; AfterUpgradedIcon.transform.GetComponent <Mask>().showMaskGraphic = true; } else { mainGUI.StartCoroutine(mainGUI.ActivateGeneralText("That didn't seem to do anything.")); } } break; default: // mythic RarityCoeff = 1.20f; break; } if (CurrentItemLocationIndex != -1 && characterInventory.InventoryManage[CurrentItemLocationIndex].CritRate > 0) // upgrade weapon { for (int i = 0; i < Weapons.WeaponList.Count; i++) { if (characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName == Weapons.WeaponList[i].WeaponName) { characterInventory.InventoryManage[CurrentItemLocationIndex].DamageOrValue = Mathf.Round(Weapons.WeaponList[i].WeaponDamage * RarityCoeff); characterInventory.InventoryManage[CurrentItemLocationIndex].WeaponAttackSpeed = Mathf.Round(Weapons.WeaponList[i].WeaponAttackSpeed * RarityCoeff); characterInventory.InventoryManage[CurrentItemLocationIndex].CritRate = Mathf.Round(Weapons.WeaponList[i].CritRate * RarityCoeff); characterInventory.InventoryManage[CurrentItemLocationIndex].ArmorPenetration = Mathf.Round(Weapons.WeaponList[i].ArmorPenetration * RarityCoeff); } } HoverRarity(characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity, "Weapon"); transform.Find("UpgradeChance").GetComponentInChildren <Text>().text = "Success: " + CurrentSuccessRate.ToString() + "% \n" + "Destroy(Failure): " + CurrentDestroyRate.ToString() + "% "; } else if (CurrentItemLocationIndex != -1 && characterInventory.InventoryManage[CurrentItemLocationIndex].Defense > 0) // upgrade armor { for (int i = 0; i < Armors.ArmorList.Count; i++) { if (characterInventory.InventoryManage[CurrentItemLocationIndex].SlotName == Armors.ArmorList[i].ArmorName) { characterInventory.InventoryManage[CurrentItemLocationIndex].Health = Armors.ArmorList[i].BonusHealth * RarityCoeff; characterInventory.InventoryManage[CurrentItemLocationIndex].Stamina = Armors.ArmorList[i].BonusStamina * RarityCoeff; characterInventory.InventoryManage[CurrentItemLocationIndex].Defense = Mathf.Round(Armors.ArmorList[i].DefenseValues * RarityCoeff); } } HoverRarity(characterInventory.InventoryManage[CurrentItemLocationIndex].Rarity, "Armor"); transform.Find("UpgradeChance").GetComponentInChildren <Text>().text = "Success: " + CurrentSuccessRate.ToString() + "% \n" + "Destroy(Failure): " + CurrentDestroyRate.ToString() + "% "; } }