Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("ItemBullet"))
        {
            Debug.Log("アイテム取得");
            ItemScript itemScript = collision.gameObject.GetComponent <ItemScript>();
            bullets += itemScript.GetBulletsInItem();

            if (_bulletCapacity < bullets)
            {
                itemScript.SetBulletsInItem(bullets - _bulletCapacity);
                bullets = _bulletCapacity;
            }
            else
            {
                itemScript.SetBulletsInItem(0);
                Destroy(collision.gameObject);
            }

            _bulletsRemain.text = " ∞ ";
        }
        else if (collision.CompareTag("PutGun"))
        {
            _bulletsRemain.enabled = true;
            isGetGun = true;
            if (state != State.Shot2)
            {
                SetState(State.Shot2);
            }
            Destroy(collision.gameObject);
            SoundManagerV2.Instance.PlaySE(12);
        }
    }