コード例 #1
0
 public void Hurt(Role enemy)
 {
     if (enemy.attackSelector == selector && selector != -1 && CheckFaceEnemy(enemy.transform))
     {
         shield.transform.position = arrows[selector].transform.position;
         shield.gameObject.SetActive(true);
         this.AbleToDo(0.75f, () => shield.gameObject.SetActive(false));
         Vector2 force = (Vector2)(transform.position - enemy.transform.position) * 1;
         rb.AddForce(
             force,
             ForceMode2D.Impulse
             );
         enemy.GetDefend(this);
     }
     else
     {
         if (isDamaging)
         {
             return;
         }
         isDamaging = true;
         animator.SetTrigger("hurt");
         WaitForAnimationFinish("hurt", () => isDamaging = false);
         hp -= enemy.str;
         if (hp <= 0)
         {
             Destroy(this.gameObject);
         }
         isControled = true;
         Vector2 force = (Vector2)(transform.position - enemy.transform.position + Vector3.up * 2) * 5;
         this.AbleToDo(0.1f, () => isControled = false);
         rb.AddForce(
             force,
             ForceMode2D.Impulse
             );
     }
 }