Exemple #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.CompareTag("star"))
        {
            GamePlayAudio.playSound("starCollect");
            col.gameObject.SetActive(false);
            ScoreManager.score += 1;
            return;
        }


        if (col.tag == "ColorChanger")
        {
            GamePlayAudio.playSound("changerSound");
            col.gameObject.SetActive(false);
            SetRandomColor();
            return;
        }

        if (col.tag != currentColor && col.tag != "star")
        {
            isAlive = false;

            GamePlayAudio.playSound("gameOver");

            Time.timeScale = 0;


            Debug.Log("GAME OVER!");
            GameEnded.SetActive(true);
        }
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Jump") || Input.GetMouseButtonDown(0))
     {
         GamePlayAudio.playSound("tap");
         rb.velocity = Vector2.up * jumpForce;
     }
 }