void Awake() { HightScoceOrange.SetActive(false); HightScoceYellow.SetActive(false); HightScoceWhite.SetActive(false); iss = true; rig = GetComponent <Rigidbody2D>(); Anima = GetComponent <Animator>(); Instance(); newpipe = GameObject.Find("NewPipe"); }
private void OnCollisionEnter2D(Collision2D target) { if (target.gameObject.tag == "pipe" || target.gameObject.tag == "pipe2" || target.gameObject.tag == "background") { flag = 1; Destroy(newpipe.gameObject); iss = false; audio.PlayOneShot(dead); Gameplay.instance.ManagementScore.SetActive(true); hightscore.text = text.text; result = int.Parse(hightscore.text); int a = PlayerPrefs.GetInt("sp"); int b = PlayerPrefs.GetInt("sp1"); int c = PlayerPrefs.GetInt("sp2"); if (result > a) { PlayerPrefs.SetInt("sp", result); } if (result < a && result > b) { PlayerPrefs.SetInt("sp1", result); } if (result < b && result > 0) { PlayerPrefs.SetInt("sp2", result); } if (result > 10) { HightScoceWhite.SetActive(true); } if (result > 50) { HightScoceYellow.SetActive(true); } if (result > 100) { HightScoceOrange.SetActive(true); } Time.timeScale = 0; //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);//Tự động load lại game khi chết } }