public IEnumerator AnimateSelectedTiles(float freq, long score) { // animate different congratulatory messages based on score TextFaderScript textFader = GameObject.Find("SuccessMessage").GetComponent <TextFaderScript>(); TextFaderScript scoreTextFader = GameObject.Find("SuccessScorePanel").GetComponent <TextFaderScript>(); if (freq >= FreqCutoffs[0]) { // Unbelievable textFader.FadeText(0.7f, "Unbelievable!"); } else if (freq >= FreqCutoffs[1]) { // Ultra rare textFader.FadeText(0.7f, "Ultra Rare!"); } else if (freq >= FreqCutoffs[2]) { // Super rare textFader.FadeText(0.7f, "Super Rare!"); } else if (freq >= FreqCutoffs[3]) { // Rare textFader.FadeText(0.7f, "Rare!"); } else if (freq >= FreqCutoffs[4]) { // Great textFader.FadeText(0.7f, "Great!"); } else if (freq >= FreqCutoffs[5]) { // Good textFader.FadeText(0.7f, "Good!"); } // Animate the obtained score scoreTextFader.FadeText(0.7f, "+" + score + " points"); // animate each selected tile foreach (Vector2 v in currentSelection) { GameObject gameObject = grid[(int)v.x, (int)v.y].gameObject; gameObject.GetComponent <BoxScript>().AnimateSuccess(); } // brief pause for the color to change before removing them from screen yield return(new WaitForSeconds(.4f)); // Delete all tiles DeleteAllSelectedTiles(); }
// Update is called once per frame void Update() { // Android back button should go back to main menu if (Application.platform == RuntimePlatform.Android) { if (Input.GetKey(KeyCode.Escape)) { if (audioSettingsPanel.activeInHierarchy) { Logger.LogAudioSettings(); audioSettingsPanel.SetActive(false); } else { // Change scenes back to main menu menuScript.GoToNextScene(0); return; } } } // if submit prompt panel is open, update the timer if (submitPromptOn) { submitPromptTimer += Time.deltaTime; } // Every 1/5 of a second, update the timer progress bar if (gameHasBegun) { timer += Time.deltaTime; } if (timer >= waitTime) { // adjust remaining time remainingTime -= timer; float scale = remainingTime / maxTime; if (scale < 0) { scale = 0; } // update progress bar progressBarFg.transform.localScale = new Vector3(scale, 1.0f, 1.0f); // reset timer timer -= waitTime; // Countdown timer displays seconds remaining near the end. if (counter > 0 && remainingTime > counter - 1 && remainingTime <= counter) { TextFaderScript textFader = GameObject.Find("CountdownMessage").GetComponent <TextFaderScript>(); textFader.FadeText(0.1f, counter.ToString()); counter--; } // check to see if it's time to start playing the timer bomb audio // FEATURE: ONLY IF JUICINESS IS ON if ((juiceProductive || juiceUnproductive) && remainingTime <= 5.275f && !isBombAudioPlaying) { isBombAudioPlaying = true; AudioManager.instance.Play("TimeBomb"); } // check if game is over if (remainingTime <= 0.0f) { GameOver(); } } //=============FEATURE: Random Pew Pew effects========================= // Unproductive Juice: every once in a while, do a random particle // animation along with pew pew sfx. //===================================================================== if (juiceUnproductive) { if (gameHasBegun) { juicyTimer += Time.deltaTime; } if (juicyTimer >= juicyWaitTime) { juicyRemainingTime -= juicyTimer; // reset timer juicyTimer -= juicyWaitTime; // check if it's time to do juicy effects if (juicyRemainingTime <= 0.0f) { PlayJuicyEffects(); // reset juicyRemainingTime = UnityEngine.Random.Range(10f, 30f); } } } // Log the keyframe (game state) after all the boxes have stopped falling if (areBoxesFalling) { if (!CheckIfBoxesAreFalling()) { areBoxesFalling = false; if (!initialLog) { // enable input again after all boxes have fallen TouchInputHandler.inputEnabled = true; Logger.LogKeyFrame("post"); } else { Logger.LogKeyFrame("gameStart"); // display the instructions/start game panel instructionsPanel.SetActive(true); initialLog = false; } } } else if (CheckIfBoxesAreFalling()) { areBoxesFalling = true; } }