public void Attack(CanBeAttacked obj) { Debug.Log("I'm gonna attack you"); if (Vector2.Distance(transform.position, obj.transform.position) > 1.5f) { moveComponent.Move(obj.transform.position, 1f); Reset(); target = obj; moveComponent.OnDone += StartAttack; moveComponent.OnChangeTarget += Reset; } else { target = obj; StartAttack(); } }
public void Action(SimpleObject obj) { if (target == obj && animator.GetInteger("State") == (int)state) { return; } Reset(); target = obj; if (Vector2.Distance(transform.position, obj.transform.position) > 1f) { moveComponent.Move(obj.transform.position, 1f); moveComponent.OnDone += StartAction; moveComponent.OnChangeTarget += Reset; } else { StartAction(); } }