private void OnTriggerEnter2D(Collider2D collision) { if (collision.name == "Player" && !monster.isDead) { monster.Attack(); } }
public override void Act(MonsterController npc) { if (npc.isDie) { return; } npc.Attack(); }
void Attack(MonsterController controller) { Collider2D[] colliders; colliders = Physics2D.OverlapCircleAll(controller.transform.position, controller.stats.attackRange); foreach (Collider2D collider in colliders) { if (collider.tag == "Player") { RaycastHit2D hitPlayer = Physics2D.Raycast(controller.transform.position, collider.transform.position - controller.transform.position, Mathf.Infinity, ~(1 << LayerMask.NameToLayer("Monster"))); if (hitPlayer.collider.tag == "Player") { Debug.DrawRay(controller.transform.position, collider.transform.position - controller.transform.position, Color.green); if (controller.CheckIfCountDownElapsed(controller.stats.attackRate)) { controller.Attack(controller.stats.attackPoint); } } } } }
public override bool Invoke() { //Debug.Log("Attack true"); monController.Attack(); return(true); }