コード例 #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag.Equals("Player"))
        {
            GameObject hit       = collision.gameObject;
            Darah      healthbar = hit.GetComponent <Darah>();

            if (healthbar != null)
            {
                healthbar.TakeDamage(35);
            }
            Destroy(gameObject);
            //SceneManager.LoadScene("Lose");
        }

        if (collision.gameObject.tag.Equals("Finish"))
        {
            Destroy(gameObject);
        }
    }
コード例 #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        int randomBang = Random.Range(0, bangs.Length);

        if (collision.gameObject.tag.Equals("Player"))
        {
            GameObject hit       = collision.gameObject;
            Darah      healthbar = hit.GetComponent <Darah>();

            if (healthbar != null && healthbar.healthbar != null)
            {
                healthbar.TakeDamage(35);
            }
            Instantiate(bangs[randomBang], collision.gameObject.transform.position, Quaternion.identity);
            Destroy(gameObject);
            //SceneManager.LoadScene("Lose");
        }

        if (collision.gameObject.tag.Equals("Finish"))
        {
            Destroy(gameObject);
        }
    }