void Die() { YouWinText.SetActive(true); MainMenuButton.SetActive(true); gameObject.SetActive(false); DefeatBoss.Play(); }
// Use this for initialization void Start() { fireRate = 2f; nextFire = Time.time; //for Enemy health EnCurrentHealth = EnMaxHealth; //You win text YouWinText.SetActive(false); MainMenuButton.SetActive(false); //Enemy Detection enemyRB = GetComponent <Rigidbody2D> (); StartCoroutine("Patrol"); }
// Use this for initialization void Start() { AudioPlayer = GetComponent <AudioSource>(); PlayerScoreText = GameObject.FindWithTag("ScoreText"); TimerText = GameObject.FindWithTag("TimerText"); GameOverText = GameObject.FindWithTag("GameOverText"); GameOverText.SetActive(false); PlayAgainButton = GameObject.FindWithTag("PlayAgainButton"); PlayAgainButton.SetActive(false); MainMenuButton = GameObject.FindWithTag("MainMenuButton"); MainMenuButton.SetActive(false); GoalObject = new GameObject[SHAPES_COLOURS] { GameObject.FindWithTag("GoalCube"), GameObject.FindWithTag("GoalSphere"), GameObject.FindWithTag("GoalTriangle") }; GoalSpawner = new Transform[TOTAL_GOAL_SPAWNER]; for (i = 0; i < TOTAL_GOAL_SPAWNER; i++) { GoalSpawner[i] = transform.GetChild(i).transform; } GoalColour = new Color[SHAPES_COLOURS] { Color.red, Color.green, Color.blue }; goalAlive = false; gameOver = false; chooseShape = Random.Range(MIN_CHOICE, MAX_CHOICE); chooseColour = Random.Range(MIN_CHOICE, MAX_CHOICE); chooseSpawner = Random.Range(MIN_CHOICE, TOTAL_GOAL_SPAWNER); timer = 60; highScore = PlayerPrefs.GetInt(PlayerPrefsKey, 0); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; }
void GameOver() { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; gameOver = true; Destroy(SpawnedGoalObject); if (playerScore > highScore) { highScore = playerScore; GameOverText.GetComponent <Text>().text = string.Format("Game Over\n New Highscore!", highScore); PlayerPrefs.SetInt(PlayerPrefsKey, playerScore); PlayerPrefs.Save(); AudioPlayer.PlayOneShot(newHighScore, VOLUME_SCALE); } else { GameOverText.GetComponent <Text>().text = string.Format("Game Over\n Current Highscore: {0}", highScore); AudioPlayer.PlayOneShot(applause, VOLUME_SCALE); } GameOverText.SetActive(true); PlayAgainButton.SetActive(true); MainMenuButton.SetActive(true); }