void Start() { // Set level text levelText.text = "Level " + GamePersistence.gameData.level; // Did we win the level ? if (GameController.hasWon) { // Change texts resultText.text = "PASS!"; hintText.text = "NEXT LEVEL ..."; // Change text colors resultText.color = hintText.color = GameController.WIN_COLOR; // Hide skip level button skipLevelButton.gameObject.SetActive(false); } else { // Check if we need to show the skip level button bool visible = GameController.levelAttempts >= SKIP_LEVEL_ATTEMPS && GamePersistence.gameData.level == GamePersistence.gameData.highestLevel && AdsController.IsRewardedVideoAdLoaded(); skipLevelButton.gameObject.SetActive(visible); } // Increase the games played count gamesPlayedSinceStart++; // Show ads if (gamesPlayedSinceStart % GAMES_TO_SHOW_INTERSTITIAL_AD == 0) { AdsController.ShowInterstitialAd(); } // Show banner ad AdsController.ShowBannerAd(); }
public void LoseGame() { // Show second chance UI if (!secondChanceShowing && !hasPlayedSecondChance && AdsController.IsRewardedVideoAdLoaded()) { // Set second chance showing secondChanceShowing = true; gameOver = true; // Show second chance UI secondChanceLayer.SetActive(true); secondChanceLayer.transform.SetAsLastSibling(); // Reset second chance counter secondChanceTimer = 0; } else { // Set game over flag gameOver = true; won = false; hasWon = false; secondChanceShowing = false; // Hide second chance UI secondChanceLayer.SetActive(false); // Change connectors count text connectorsCountText.text = "Level Failed!"; connectorsCountText.color = LOSE_COLOR; // Hide color and speed ui speedProgressBar.gameObject.SetActive(false); speedText.gameObject.SetActive(false); colorProgressBar.gameObject.SetActive(false); colorText.gameObject.SetActive(false); connectorsLeftText.gameObject.SetActive(false); // Increase the level attempts levelAttempts++; } }