Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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;
     }
 }