// Use this for initialization void Start() { //PlayerPrefs.DeleteAll(); deepThroat = GameObject.FindObjectOfType<DeepThroat>(); inputManager = GameObject.FindObjectOfType<InputManager>(); operandMap = new Dictionary<string,DoMath>() { {"+", (x,y) => { return x + y; }}, {"-", (x,y) => { return x - y; }}, {"*", (x,y) => { return x * y; }}, {"/", (x,y) => { return x / y; }} }; operandList = new List<string>(); foreach (KeyValuePair<string,DoMath> kvp in operandMap) { operandList.Add(kvp.Key); } if (GameSingleton.Instance.highScore > 0) { highScoreText.text = "high " + GameSingleton.Instance.highScore.ToString().PadLeft(5, '0'); } else { highScoreText.text = ""; } gameCanvas.alpha = 0; titleCanvas.gameObject.SetActive(true); audioSource = GetComponent<AudioSource>(); }
IEnumerator GameOver() { if (invincible) { yield return null; } else { gameOvering = true; if (!playingPunkMusic) { music.Stop(); } audioSource.PlayOneShot(gameOverSound); HandleOperand(""); gameStarted = false; deepThroat.dead = true; spawner.StopGame(); deepThroat.GetComponent<Rigidbody2D>().AddForce(new Vector2(300, -500)); deepThroat.GetComponent<Rigidbody2D>().AddTorque(-30); yield return new WaitForSeconds(1.5f); Destroy (deepThroat); deepThroat = Instantiate(deepThroatPrefab).GetComponent<DeepThroat>(); deepThroat.transform.position = new Vector2(-10, 0); inputManager.deepThroat = deepThroat; yield return StartCoroutine(FadeInFadeOutCanvas(titleCanvas, gameCanvas)); titleCanvas.blocksRaycasts = true; GameSingleton.Instance.RecordScore(); highScoreText.text = "high " + GameSingleton.Instance.highScore.ToString().PadLeft(5, '0'); gameOvering = false; yield return null; } }