コード例 #1
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        switch (collision.gameObject.tag)
        {
        case "Enemy":
            Debug.Log("hit");
            hpbar.ReduceHP();
            laserNum -= 2;
            if (laserNum <= 0)
            {
                laserNum = 1;
            }
            break;

        case "HPDrop":
            hpbar.IncreaseHP();
            Destroy(collision.gameObject);
            break;

        case "WeaponDrop":
            laserNum++;
            if (laserNum >= laserMaxNum)
            {
                laserNum = laserMaxNum;
            }

            Destroy(collision.gameObject);
            break;

        default:
            break;
        }
        //if (collision.gameObject.tag == "Enemy")
        //{
        //    Debug.Log("hit");
        //    hpbar.ReduceHP();
        //}

        //if
    }