private IEnumerator PerformAction(int timesToPerform) { gameText.EnableText(true); playerObject.CanPlayerMove(false); int randomInt = 0; for (int i = 0; i <= timesToPerform; i++) { randomInt = Random.Range(1, 3); yield return(new WaitForSeconds(secondsBetweenMovements)); if (randomInt == 1) { if (currentIndex + 1 <= tracks.Count - 1) { currentIndex = currentIndex + 1; transform.position = new Vector3(tracks[currentIndex].transform.position.x, transform.position.y, transform.position.z); } else { currentIndex = currentIndex - 1; transform.position = new Vector3(tracks[currentIndex].transform.position.x, transform.position.y, transform.position.z); } } else if (randomInt == 2) { if (currentIndex - 1 >= 0) { currentIndex = currentIndex - 1; transform.position = new Vector3(tracks[currentIndex].transform.position.x, transform.position.y, transform.position.z); } else { currentIndex = currentIndex + 1; transform.position = new Vector3(tracks[currentIndex].transform.position.x, transform.position.y, transform.position.z); } } } playerObject.ObjectsToTouch(objectOrder); gameText.EnableText(false); playerObject.CanPlayerMove(true); currentlyPerformingAction = false; }
// Start is called before the first frame update void Start() { playerObject = FindObjectOfType <PlayerController>(); scoreManager = FindObjectOfType <ScoreManager>(); gameText = FindObjectOfType <GameText>(); pauseManager = FindObjectOfType <PauseManager>(); gameText.EnableText(true); playerObject.CanPlayerMove(false); scoreManager.ResetScore(); firstRound = true; }