void SpawnFish() { float randomValue = Random.value; float randomFishFloat = randomValue * (waterZone.fishArray.Length - 1); int randomFishInt = Mathf.RoundToInt(randomFishFloat); fishCaught = waterZone.fishArray[randomFishInt]; gameControllerScript.currentFish = fishCaught; }
IEnumerator Transition() { UIReferenceScript.fishCaught.SetActive(true); yield return(new WaitForSeconds(1f)); UIReferenceScript.fishName.SetActive(true); if (fishCaught.quality == Quality.trash) { UIReferenceScript.fishName.GetComponent <Text>().color = Color.white; } else if (fishCaught.quality == Quality.common) { UIReferenceScript.fishName.GetComponent <Text>().color = Color.green; } else if (fishCaught.quality == Quality.rare) { UIReferenceScript.fishName.GetComponent <Text>().color = Color.blue; } else if (fishCaught.quality == Quality.epic) { UIReferenceScript.fishName.GetComponent <Text>().color = Color.magenta; } else if (fishCaught.quality == Quality.legendary) { UIReferenceScript.fishName.GetComponent <Text>().color = Color.yellow; } UIReferenceScript.fishName.GetComponent <Text>().text = fishCaught.fishType; yield return(new WaitForSeconds(2)); UIReferenceScript.fishCaught.SetActive(false); UIReferenceScript.fishName.SetActive(false); UIReferenceScript.fishName.GetComponent <Text>().text = null; Vector3 moveDifference = castDestination - transform.position; int loopCount = 20; audioSource.Play(); for (int i = 0; i < loopCount; i++) { transform.position += moveDifference / loopCount; transform.LookAt(castDestination); rodModel.transform.LookAt(castDestination); caster.transform.position = castDestination; yield return(new WaitForSeconds(0.005f)); } canCast = true; canRotate = true; caster.transform.localPosition = casterStartPosition; audioSource.Stop(); //stops the casting sound transform.position = initialPosition; gameController.GetComponent <GameController>().SwitchGame(); float randomValue = Random.value; int roundedValue = Mathf.RoundToInt(randomValue * (fishCaught.patternArray.Length - 1)); GameObject chosenPattern = fishCaught.patternArray[roundedValue]; gameControllerScript.patternSpawner.GetComponent <PatternSpawnerController>().SpawnPattern(chosenPattern); fishCaught = null; //resets fish caught }