void Update() { // Did we finish the rewarded ad video ? if (AdsController.IsRewardedVideoAdFinished()) { // Increase highest level GamePersistence.gameData.highestLevel++; GamePersistence.gameData.level = GamePersistence.gameData.highestLevel; // Save GamePersistence.Save(); // Start the game scene SceneManager.LoadScene("Game"); } }
void Update() { // Are we seeing second chance UI ? if (secondChanceShowing) { // Did we finish the video ? if (AdsController.IsRewardedVideoAdFinished()) { // Restore hit RestoreLastHit(); return; } // Skip if we're already watching ad if (hasPlayedSecondChance) { return; } // Update timer secondChanceTimer += Time.deltaTime; // Update counter image secondChanceCounterImage.fillAmount = (SECOND_CHANCE_TIME - secondChanceTimer) / SECOND_CHANCE_TIME; // Did we finish second chance ? if (secondChanceTimer >= SECOND_CHANCE_TIME) { // Lose the game LoseGame(); } return; } // Rotate all circles if (!gameOver) { // Update connectors UpdateConnectors(); // Update circles foreach (Image circle in circles) { circle.rectTransform.Rotate(rotationVector); } } else { // Rotate if we won the game if (won) { foreach (Image circle in circles) { circle.rectTransform.Rotate(rotationVector); } } // Did we finish game over ? gameOverCounter += Time.deltaTime; if (gameOverCounter >= GAME_OVER_TIME) { // Load death scene SceneManager.LoadScene("Death"); } else if (gameOverCounter >= GAME_OVER_ANIMATION_TIME && !gameOverAnimationPlaying) { // Connectors on game over foreach (Image connector in connectors) { connector.GetComponent <Connector>().SetRotationSpeed(0f); } // Static connectors on game over foreach (Image connector in staticConnectors) { connector.GetComponent <Connector>().SetRotationSpeed(0f); } // Set game over animation flag gameOverAnimationPlaying = true; } } // Update UI UpdateUI(); }