/// <summary> /// Assigns the current prefab obstacle type. /// </summary> private void AssignPrefabType() { if (typeCount <= 0) { int r = UnityEngine.Random.Range(0, 5); typeCount = UnityEngine.Random.Range(0, 5); if (r == 0) { currentPrefab = Pooler.PooledName.MiddleWall; } else if (r == 1) { currentPrefab = Pooler.PooledName.SideWall; } else if (r == 2 || r == 3) { currentPrefab = Pooler.PooledName.Obstacle; } else { currentPrefab = Pooler.PooledName.Coin; } } // alternate between middle and side walls regardless else if (currentPrefab == Pooler.PooledName.MiddleWall && UnityEngine.Random.Range(0, 2) == 0) { currentPrefab = Pooler.PooledName.SideWall; } else if (currentPrefab == Pooler.PooledName.SideWall && UnityEngine.Random.Range(0, 2) == 0) { currentPrefab = Pooler.PooledName.MiddleWall; } }
/// <summary> /// Controls the tutorial sequence. /// </summary> private IEnumerator Tutorial() { yield return(new WaitForSeconds(1f)); while (UIManager.getTutorialIndex() < 5) { yield return(UIManager.tutorialText()); int i = UIManager.getTutorialIndex(); if (i == 2) { currentPrefab = Pooler.PooledName.MiddleWall; Pooler.getPooledEvent(currentPrefab); currentPrefab = Pooler.PooledName.SideWall; yield return(new WaitForSeconds(2.5f)); Pooler.getPooledEvent(currentPrefab); yield return(new WaitForSeconds(2.5f)); Pooler.getPooledEvent(currentPrefab).transform.localScale = new Vector3(-1, 1, 1); yield return(new WaitForSeconds(6)); } else if (i == 4) { currentPrefab = Pooler.PooledName.Obstacle; for (int j = -2; j < 3; ++j) { Pooler.getPooledEvent(currentPrefab, j).GetComponent <Obstacle>().RotateRight = true; } yield return(new WaitForSeconds(2.5f)); for (int j = -2; j < 3; ++j) { Pooler.getPooledEvent(currentPrefab, j).GetComponent <Obstacle>().RotateRight = false; } yield return(new WaitForSeconds(2.5f)); for (int j = -2; j < 3; ++j) { Pooler.getPooledEvent(currentPrefab, j).GetComponent <Obstacle>().RotateRight = true; } yield return(new WaitForSeconds(6)); } else if (i == 5) { currentPrefab = Pooler.PooledName.Coin; for (int j = -2; j < 1; ++j) { Pooler.getPooledEvent(currentPrefab, j).GetComponent <Obstacle>().RotateRight = false; } yield return(new WaitForSeconds(2.5f)); for (int j = 0; j < 3; ++j) { Pooler.getPooledEvent(currentPrefab, j).GetComponent <Obstacle>().RotateRight = true; } yield return(new WaitForSeconds(2.5f)); for (int j = -1; j < 2; ++j) { Pooler.getPooledEvent(currentPrefab, j).GetComponent <Obstacle>().RotateRight = false; } yield return(new WaitForSeconds(6)); } else { yield return(new WaitForSeconds(0.3f)); } } Utils.Tutorial = false; Utils.Save(); StartCoroutine(IncrementSpeed()); StartCoroutine(IncrementScore()); StartCoroutine(SpawnObstacles()); }