public void ChangeLevel(int levelInt) { levelSelected = levelInt; switch (levelSelected) { case -4: //buy menu //Debug.Log("Buy Menu forced"); ResetLevelState(); defensesStore.enabled = true; if (defensesStore.purchasableSupports.Count < 3) { defenseSupportBought.transform.localScale = new Vector3(defenseSupportBought.transform.localScale.x, defenseSupportBought.transform.localScale.y, 0.66f); } else if (defensesStore.purchasableSupports.Count < 2) { defenseSupportBought.transform.localScale = new Vector3(defenseSupportBought.transform.localScale.x, defenseSupportBought.transform.localScale.y, 1f); } moveViewPos = buyViewPos; moveViewRot = buyViewRot; isCameraToMove = true; break; case -3: //lose menu //Debug.Log("Lose Menu selected"); ResetLevelState(); printingMenu.gameObject.SetActive(false); loseMenu.gameObject.SetActive(true); loseSFX.Play(); moveViewPos = menuViewPos; moveViewRot = menuViewRot; isCameraToMove = true; break; case -2: //quit menu //Debug.Log("Quit Menu selected"); moveViewPos = menuViewPos; moveViewRot = menuViewRot; isCameraToMove = true; break; case -1: //win menu //Debug.Log("Win Menu selected"); printingMenu.gameObject.SetActive(false); quitMenu.gameObject.SetActive(false); winMenu.gameObject.SetActive(true); currentLevel = GameObject.FindGameObjectWithTag("Level"); // has to happen before level object is disabled PlayerHealth playerHealth = currentLevel.GetComponentInChildren <PlayerHealth>(); int currentLevelScore = playerHealth.playerHealth; for (int i = 0; i < currentLevelScore; i++) { winChipDisplays[i].SetActive(true); } winChipsAnim.SetTrigger("MoveChips"); if (currentLevelScore > levelScores[lastLoadedLevel - 1]) { winPointCounter.AddWinPoints(currentLevelScore - levelScores[lastLoadedLevel - 1]); levelScores[lastLoadedLevel - 1] = currentLevelScore; } trophies[lastLoadedLevel - 1].GetComponent <PlayTrophyAnim>().WinAnimStart(); break; case 0: //main menu //Debug.Log("Main Menu selected"); foreach (GameObject winChipDisplay in winChipDisplays) { winChipDisplay.SetActive(false); } winPointCounter.UpdateWinTrackers(); moveViewPos = menuViewPos; moveViewRot = menuViewRot; isCameraToMove = true; ResetLevelState(); foreach (TowerMover towerMover in towers) { towerMover.ResetTowerToStart(); towerMover.enabled = false; } foreach (DefenseSupportMover supportMover in supports) { supportMover.ResetSupportToStart(); supportMover.enabled = false; } foreach (SlowEffect slowArea in slowEffects) { slowArea.ResetSlowEffect(); } slowSticks.ResetStickToStart(); slowSticks.enabled = false; // for win scenario we turn on level1, ChangeLevel(1). and switch menus break; case 1: //level 1 enemySpawner.ChangeEnemySpawnAmount(1); SetUpGenericLevel(); break; case 2: //level 2 enemySpawner.ChangeEnemySpawnAmount(1); SetUpGenericLevel(); break; case 3: //level 3 enemySpawner.ChangeEnemySpawnAmount(1); SetUpGenericLevel(); break; case 4: //level 4 enemySpawner.ChangeEnemySpawnAmount(1); SetUpGenericLevel(); break; case 5: //level 5 enemySpawner.ChangeEnemySpawnAmount(3); SetUpGenericLevel(); break; case 6: //level 6 enemySpawner.ChangeEnemySpawnAmount(4); SetUpGenericLevel(); break; case 7: //level 7 enemySpawner.ChangeEnemySpawnAmount(4); SetUpGenericLevel(); break; case 8: //level 8 enemySpawner.ChangeEnemySpawnAmount(4); SetUpGenericLevel(); break; case 9: //level 9 enemySpawner.ChangeEnemySpawnAmount(6); SetUpGenericLevel(); break; case 10: //level 10 enemySpawner.ChangeEnemySpawnAmount(8); SetUpGenericLevel(); break; case 11: //level 11 enemySpawner.ChangeEnemySpawnAmount(8); SetUpGenericLevel(); break; case 12: //level 12 enemySpawner.ChangeEnemySpawnAmount(9); SetUpGenericLevel(); break; case 13: //level 13 enemySpawner.ChangeEnemySpawnAmount(8); SetUpGenericLevel(); break; case 14: //level 14 enemySpawner.ChangeEnemySpawnAmount(9); SetUpGenericLevel(); break; case 15: //level 15 enemySpawner.ChangeEnemySpawnAmount(10); SetUpGenericLevel(); break; case 16: //level 16 enemySpawner.ChangeEnemySpawnAmount(11); SetUpGenericLevel(); break; case 17: //level 17 enemySpawner.ChangeEnemySpawnAmount(11); SetUpGenericLevel(); break; case 18: //level 18 enemySpawner.ChangeEnemySpawnAmount(11); SetUpGenericLevel(); break; case 19: //level 19 enemySpawner.ChangeEnemySpawnAmount(12); SetUpGenericLevel(); break; case 20: //level 20 enemySpawner.ChangeEnemySpawnAmount(12); SetUpGenericLevel(); break; case 21: //level 21 enemySpawner.ChangeEnemySpawnAmount(10); SetUpGenericLevel(); break; case 22: //level 22 enemySpawner.ChangeEnemySpawnAmount(11); SetUpGenericLevel(); break; case 23: //level 23 enemySpawner.ChangeEnemySpawnAmount(15); SetUpGenericLevel(); break; case 24: //level 24 enemySpawner.ChangeEnemySpawnAmount(14); SetUpGenericLevel(); break; case 25: //level 25 enemySpawner.ChangeEnemySpawnAmount(15); SetUpGenericLevel(); break; case 26: //level 26 enemySpawner.ChangeEnemySpawnAmount(15); SetUpGenericLevel(); break; case 27: //level 27 enemySpawner.ChangeEnemySpawnAmount(19); SetUpGenericLevel(); break; case 28: //level 28 enemySpawner.ChangeEnemySpawnAmount(21); SetUpGenericLevel(); break; default: // no level selected, switch to main menu Debug.Log("no level selected switching to main menu"); break; } }