void CheckCompletion() { bool Completed = true; foreach (GameObject Button in Buttons) { var bscript = Button.GetComponent <ButtonScript>(); if (bscript.getComplete() == false && bscript.IsPastaBomb == false) { Completed = false; break; } } if (Completed == true) { foreach (GameObject Button in Buttons) { Button.GetComponent <RectTransform>().sizeDelta = new Vector2(120, 120); Button.GetComponent <ButtonScript>().setComplete(true); Button.GetComponent <ButtonScript>().Reveal(true); } audioSource.PlayOneShot(CompletedSound); EndScreen.SetActive(true); EndScreen.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = GetScore().ToString(); EndScreen.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = "Fails: " + Fails.ToString(); var result = PlayerPrefManager.GetAndOrUpdateHighscore("MatchTwo", GetScore()); EndScreen.transform.GetChild(3).GetComponent <TextMeshProUGUI>().text = result.Item1 ? "New highscore!" : ("Highscore: " + result.Item2); var hackeronis = 10 + 19 * Mathf.Max(10 - Fails, 0); PlayerPrefManager.AddEarnedHackeronis(hackeronis); EndScreen.transform.GetChild(4).GetComponent <TextMeshProUGUI>().text = "Hackeronis: " + hackeronis; } }
private void died() // Run when dead { powerupAudioSource.Stop(); int score = kills - 10; hackeronies = score; // Should be optimized. PlayerPrefManager.AddEarnedHackeronis(score); dead = true; activePowerup = -1; for (int k = enemyPool.active_object_count - 1; k >= 0; k--) { if (enemyPool.metadata[k].hasRona == true) { enemyPool.gameObjects[k].GetComponent <SpriteRenderer>().sprite = angryTomat; enemyPool.gameObjects[k].transform.GetChild(0).gameObject.SetActive(false); } } var high = PlayerPrefManager.GetAndOrUpdateHighscore("FuckingGyroskop", score); if (!high.Item1) { finalScoreTMP.text = "Final Score: " + score.ToString() + "\nHighscore: " + high.Item2; } else { finalScoreTMP.text = "New highscore: " + high.Item2 + "!!"; } hackeronisTMP.text = "Hackeronies acquired: " + hackeronies.ToString(); restartTMP.gameObject.SetActive(true); gameOverTMP.gameObject.SetActive(true); finalScoreTMP.gameObject.SetActive(true); hackeronisTMP.gameObject.SetActive(true); foreach (var i in powerups) { Destroy(i); } powerups.Clear(); foreach (var i in powerupObjects) { Destroy(i); } transform.rotation = Quaternion.identity; // Save Hackeronies and stuff }
private void CongratulatePlayer() { Time.timeScale = 0; hooraySoundEffect.Play(); endScreenCanvas.enabled = true; gameoverText.gameObject.SetActive(false); congratulationsText.gameObject.SetActive(true); statisticsText.transform.parent.gameObject.SetActive(true); statisticsText.enabled = true; var result = PlayerPrefManager.GetAndOrUpdateHighscore("BeatPasta", score); var hackeronis = Mathf.RoundToInt(score / 10); PlayerPrefManager.AddEarnedHackeronis(hackeronis); statisticsText.text = string.Format("{0}\n{1} {2}\n{3}", score, result.Item1 ? "(NEW!)" : null, result.Item2, hackeronis); }
void EndScreenCountDown() { if (EndScreenTimer > 0) { EndScreenTimer -= Time.deltaTime; } else if (EndScreenTimer < 0) { EndScreen.SetActive(true); var score = ScoreCalculation(); var hackeronis = Mathf.RoundToInt(score * 3.1415f); ScoreText.text = string.Format("Score: {0}\n\n Hackeronis: {1}", score, hackeronis); PlayerPrefManager.AddEarnedHackeronis(hackeronis); EndScreenTimer = 0; } }
public IEnumerator GameOverCoroutine() { NextButton.gameObject.SetActive(false); EndGameScreenCanvas.SetActive(true); var result = PlayerPrefManager.GetAndOrUpdateHighscore("TrickyTrumpTest", RightAmount); var adjustedValue = Mathf.Max(RightAmount - 2, 0); var hackeronisEarned = adjustedValue * adjustedValue + (result.Item1 ? 10 : 0); PlayerPrefManager.AddEarnedHackeronis(hackeronisEarned); EndGameScreenCanvas.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = string.Format("{0}\n\n{1}\n\n{2}", RightAmount, result.Item2, hackeronisEarned); EndGameScreenCanvas.transform.GetChild(2).GetComponent <TextMeshProUGUI>().text = string.Format("Score\n\nHighscore {0}\n\nHackeronis", result.Item1 ? "(NEW!)" : ""); var buttons = EndGameScreenCanvas.GetComponentsInChildren <Button>(); foreach (var button in buttons) { button.interactable = false; } var canvasGroup = EndGameScreenCanvas.GetComponent <CanvasGroup>(); const float fade_time = 0.5f; var tick = 0f; while (tick <= fade_time) { tick += Time.deltaTime; canvasGroup.alpha = Mathf.Lerp(0, 1, Mathf.Pow(tick / fade_time, 1.5f)); yield return(null); } foreach (var button in buttons) { button.interactable = true; } }
// Update is called once per frame void Update() { if (gameIsOn) { if (mainCountdown > 0) { mainCountdown -= Time.deltaTime; } else { instantiator(); mainCountdown = Random.Range(0.5f, 1.5f); } backgroundColorManager(); globalTimer += Time.deltaTime; } if (lives == 0) { score_text.gameObject.SetActive(false); life_text.gameObject.SetActive(false); final_score_txt.text = "Your score: " + score; var highscore = PlayerPrefManager.GetAndOrUpdateHighscore("Soup_falls", score).Item2; highscore_txt.text = "Highscore: " + highscore; var hackeronis = Mathf.RoundToInt(score / 20f); PlayerPrefManager.AddEarnedHackeronis(hackeronis); hackeronies_earned_txt.text = hackeronis.ToString(); GameObject.Find("Music").GetComponent <AudioSource>().Stop(); end_screen_canvas.SetActive(true); gameIsOn = false; Time.timeScale = 0; lives = -1; } if (globalTimer > 30 && trigger == 0) { trigger = 1; foreach (GameObject Object in fallingObjects) { Object.GetComponent <Rigidbody2D>().gravityScale += 0.5f; } } else if (globalTimer > 60 && trigger == 1) { trigger = 2; foreach (GameObject Object in fallingObjects) { Object.GetComponent <Rigidbody2D>().gravityScale += 0.5f; } } else if (globalTimer > 120 && trigger == 2) { trigger = 3; foreach (GameObject Object in fallingObjects) { Object.GetComponent <Rigidbody2D>().gravityScale += 0.5f; } } }