예제 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == "Player")
        {
            AddNewPoint();
            explosion.transform.position = transform.position;
            explosion.Play();
            if (core.FullHP())
            {
                bedHp.ChangeHp(2);
            }
            else
            {
                core.ChangeHp(2);
            }
            Destroy(gameObject);

            Debug.Log("Health picked up");
        }
    }
예제 #2
0
 public void Attack()
 {
     if (distanceToBed <= attackDistance + 2)
     {
         if (bedScript == null)
         {
             bedScript = bed.GetComponent <BedHp>();
         }
         bedScript.ChangeHp(-damage);
     }
     else
     {
         if (playerScript == null)
         {
             playerScript = player.GetComponent <PlayerCore>();
         }
         Collider[] collider;
         collider = Physics.OverlapSphere(transform.position, attackDistance, 8);
         playerScript.ChangeHp(-damage);
     }
 }