예제 #1
0
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag != "Player")
        {
            return;
        }

        SlimeJumpManual player = other.gameObject.GetComponent <SlimeJumpManual>();

        if (!stunned && !player.jumping)
        {
            player.health -= 1;
            if (player.health <= 0)
            {
                SceneManager.LoadScene("Outro", LoadSceneMode.Single);
            }
            return;
        }

        health -= 1;
        if (health <= 0)
        {
            Destroy(this.gameObject);
        }

        stunned         = true;
        stunnedCooldown = STUN_DURATION;
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        SlimeJumpManual jumper = GameObject.FindWithTag("Player").GetComponent <SlimeJumpManual>();

        int n_hearts  = jumper.health;
        int n_flowers = jumper.flowers;

        for (int i = 0; i < 3; i++)
        {
            if (i < n_hearts)
            {
                hearts[i].enabled = true;
            }
            else
            {
                hearts[i].enabled = false;
            }

            if (i < n_flowers)
            {
                flowers[i].enabled = true;
            }
            else
            {
                flowers[i].enabled = false;
            }
        }
    }