示例#1
0
 public void OnHit()
 {
     if (!shielded)
     {
         health--;
         audioSource.PlayOneShot(hurt);
         shield.SetActive(true);
         shielded = true;
     }
     if (health <= 0)
     {
         anim.SetTrigger("death");
         Vector2    dir   = transform.position - player.transform.position;
         float      angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg + 90;
         Quaternion rot   = Quaternion.AngleAxis(angle, Vector3.forward);
         blood.transform.rotation = rot;
         blood.Play();
         shield.SetActive(false);
         shielded = false;
         ui.SendMessage("OnVictory");
         player.SendMessage("Victory");
     }
 }