// Increase the bounce count public void increaseBounceCount() { // If the colour switch count is less than 2 if (colourSwitchCount < 2) { // Add 2 to the player's score setBounceCount(getBounceCount() + 2); // Spawn the alert text hudLayerController.getGameplayHUDLayer().printAlertText("Switch Bonus"); } // Otherwise else { // Add 1 to the player's score setBounceCount(getBounceCount() + 1); } colourSwitchCount = 0; hudLayerController.getGameplayHUDLayer().updateHUDElements(); // If the bounce count is equal to the target if (bounceCount >= ScoreTargetController.getScoreTarget()) { // End the game ScoreTargetController.setCanGenerateScoreTarget(true); PlayerStatsContainer.setWins(PlayerStatsContainer.getWins() + 1); StartCoroutine(GameStateController.endGame()); } }
// On Collision void OnCollisionEnter(Collision collision) { // If the colliding object is the player // and the player's colour state is the same as this one if (collision.gameObject.CompareTag("Player")) { if (currentColourState == player.getCurrentColourState()) { player.reverseMovement(); if (opositePaddle) { collisionAudioSource.playSound(); spawnParticleEffect(); disablePaddle(); opositePaddle.selectNewColourState(); } } else { ScoreTargetController.setCanGenerateScoreTarget(false); StartCoroutine(GameStateController.endGame()); } } }
// Start the game public static IEnumerator startGame() { hudLayerController.showStartingHUDLayer(); yield return(new WaitForSeconds(3.0f)); hudLayerController.hideStartingHUDLayer(); hudLayerController.showGameplayHUDLayer(); ScoreTargetController.generateScoreTarget(); player.enable(); hudLayerController.getGameplayHUDLayer().updateHUDElements(); }
// When this HUD layer is shown public void show() { Cursor.visible = true; tooltipText.text = string.Empty; continueButton.onClick.AddListener(delegate { // If the player is not on the last stage // Increase the stage count if (StageSystemManager.isOnFinalStage() == false) { StageSystemManager.setCurrentStage(StageSystemManager.getCurrentStage() + 1); } musicPlayer.fadeOut(); StartCoroutine(reloadLevel()); }); quitButton.onClick.AddListener(delegate { musicPlayer.fadeOut(); StartCoroutine(goToMainMenu()); }); // Set the content of the title based on whether the player // reached the score target if (player.getBounceCount() >= ScoreTargetController.getScoreTarget()) { titleText.text = "You Win"; } else { titleText.text = "You Lose"; } scoreGoalText.text = ScoreTargetController.getScoreTarget().ToString(); playerBounceResultText.text = player.getBounceCount().ToString(); animComp.SetBool("isShowing", true); animComp.SetBool("isHiding", false); }
// Start the game private IEnumerator startGame() { float startDelay = 2.5f; welcomeScreen_hide(); currentScreenIndicator.gameObject.SetActive(false); loadingText.gameObject.SetActive(true); background.enabled = false; StageSystemManager.resetValues(); ScoreTargetController.resetValues(); PlayerStatsContainer.resetValues(); yield return(new WaitForSeconds(1.0f)); fadeImageAnimator.SetBool("isShowing", true); yield return(new WaitForSeconds(startDelay)); SceneManager.LoadSceneAsync("Scene_GameArea_Sanctuary"); }
// Start the game private IEnumerator startGame() { float delay = 2.0f; hide(); PlayerStatsContainer.resetValues(); StageSystemManager.resetValues(); ScoreTargetController.resetValues(); Cursor.visible = false; loadingText.gameObject.SetActive(true); yield return(new WaitForSeconds(delay)); fadeImage.SetBool("isShowing", true); yield return(new WaitForSeconds(2.5f)); SceneManager.LoadSceneAsync("Scene_GameArea_Sanctuary"); }
// Update HUD elements public void updateHUDElements() { bounceCountText.text = player.getBounceCount().ToString(); targetText.text = ScoreTargetController.getScoreTarget().ToString(); }