IEnumerator lookForInput(int cost) { do { if (chosen == optionChosen.norevive) { gameObject.GetComponent <Animator>().Play("Notification_Out"); yield return(new WaitForSeconds(0.3f)); chosen = optionChosen.nothing; MainGameManager.Game_Over(); yield break; } else if (chosen == optionChosen.revive) { chosen = optionChosen.nothing; gameObject.GetComponent <Animator>().Play("Notification_Out"); if (MainGameManager.player.GetComponentInChildren <Animator> ().GetBool("RotatedUp") == false) { MainGameManager.player.GetComponentInChildren <Animator> ().SetBool("RotatedUp", true); MainGameManager.player.GetComponentInChildren <Animator> ().Play("ToDown"); } MainGameManager.coins -= cost; MainGameManager.coinReadout.GetComponentInChildren <TextMesh>().text = MainGameManager.coins.ToString(); SaveManager.SetCoins(MainGameManager.coins); yield return(new WaitForSeconds(0.5f)); MainGameManager.current_game_state = MainGameManager.game_state.Playing; MainGameManager.Revive(); yield break; } yield return(null); } while(true); }
void OnCollisionEnter2D(Collision2D coll) { ContactPoint2D contact = coll.contacts[0]; contact.collider.GetComponentInParent <MainGameObstacleHandler> ().forceDestroy = true; Instantiate(MainGameManager.destroyed_particle, contact.collider.gameObject.transform.position, new Quaternion(0f, 0f, 0f, 1f)); //MainGameManager.Game_Over (); if (MainGameManager.coins >= Mathf.RoundToInt(Mathf.Sqrt(MainGameManager.score) * (Mathf.Sqrt(MainGameManager.score)) / 5) && MainGameManager.score >= 25) { GameObject revive_notification = Resources.Load("Sprites/Ui/Prefabs/Notification_Revive") as GameObject; revive_notification = Instantiate(revive_notification) as GameObject; revive_notification.GetComponentInChildren <TextMesh> ().text = Mathf.RoundToInt(Mathf.Sqrt(MainGameManager.score) * (Mathf.Sqrt(MainGameManager.score)) / 5).ToString(); revive_notification.GetComponent <NotificationManager> ().revivePlayer(Mathf.RoundToInt(Mathf.Sqrt(MainGameManager.score) * (Mathf.Sqrt(MainGameManager.score)) / 5)); //start the prompt process } else { MainGameManager.Game_Over(); } }