void Update() { Vector2 playerposition = player.position; Vector2 detectplayerposition = detectplayer.position; float distance = (playerposition - detectplayerposition).magnitude; if (Input.GetKeyDown(KeyCode.E) && distance < 1f && !frog) { enterDialog.SetActive(true); GameObject.Find("player").GetComponent <AudioSource>().enabled = false; GameObject.Find("player").GetComponent <Rigidbody2D>().gravityScale = 0; GameObject.Find("player").GetComponent <Rigidbody2D>().velocity = new Vector2(0, 2f); GameObject.Find("BulletGenerator").GetComponent <bulletgenerator>().enabled = false; FindObjectOfType <PlayerController>().hightlighttrue(); // GameObject.Find("BulletGenerator").SetActive(false); GameObject.Find("Canvas").SetActive(false); FindObjectOfType <PlayerController>().jumpmax(); Endhighlight.SetActive(true); Invoke("enterDialogclose", 2f); } else if (Input.GetKeyDown(KeyCode.E) && distance < 1f) { CollectDialog.SetActive(true); Invoke("CollectDialogclose", 2f); } }
void Update() { cherrynum = int.Parse(Cherry.text); Vector2 playerposition = player.position; Vector2 detectplayerposition = detectplayer.position; float distance = (playerposition - detectplayerposition).magnitude; if (Input.GetKeyDown(KeyCode.E) && distance < 3f && cherrynum == 6) { // enterDialog.SetActive(true); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); // Invoke("enterDialogclose",3f); } else if (Input.GetKeyDown(KeyCode.E) && distance < 1f) { CollectDialog.SetActive(true); Invoke("CollectDialogclose", 2f); } }
void CollectDialogclose() { CollectDialog.SetActive(false); }