public virtual void AnimationHit() { if (curTarget != null) { IGetHit target = curTarget.GetComponent <IGetHit>(); if (target != null) { target.GetHit(model.damage.Value, this.gameObject); } } }
private void Move() { Vector3 targetPos = Vector3.zero; if (curTarget == null || curTarget.activeSelf == false) { if (lastPositionTarget != Vector2.zero) { targetPos = lastPositionTarget; } } else { targetPos = curTarget.transform.position; } transform.Translate(Vector3.left * Time.deltaTime * moveSpeed); Vector3 vectorToTarget = transform.position - targetPos; float angle = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg; Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * rotationSpeed); if (Vector2.Distance(transform.position, targetPos) < 2) { if (curTarget != null) { IGetHit hit = curTarget.GetComponent <IGetHit>(); if (hit != null) { hit.GetHit(damage, initiator); } } Dispose(); } }