コード例 #1
0
 public void UseObject()
 {
     hm.ApplyHeal(HealAmout);
     if (!hm.isMaximum)
     {
         if (HealSound)
         {
             AudioSource.PlayClipAtPoint(HealSound, transform.position, 1.0f);
         }
         Destroy(gameObject);
     }
 }
コード例 #2
0
    private void OnTriggerEnter(Collider other)
    {
        HealthManager healthManager = other.gameObject.GetComponent <HealthManager>();

        if (other.gameObject.tag == "Player")
        {
            switch (chooseState)
            {
            case AddState.AddHealth:
                healthManager.ApplyHeal(healthValue);
                Destroy(gameObject);
                break;

            case AddState.AddLife:
                healthManager.AddBounsLife(lifeAmount);
                Destroy(gameObject);
                break;
            }
        }
    }