private void Update() { if (!(_rayCaster?.HasTarget() ?? true)) { return; } PositionHelper.FaceTarget(transform, _rayCaster.Target.transform); }
private void Build() { _rayCastMover = Substitute.For <IRayCastMover>(); _rayCastInteractor = Substitute.For <IRayCastInteractor>(); _rayCastInteractor.Target.Returns(_target); _rayCastInteractor.HasTarget().Returns(_target != null); _mouseAction = new GameObject().AddComponent <MouseAction>(); _mouseAction.Init(_rayCastMover, _rayCastInteractor); }
public void DoMouseAction(Vector3 mousePosition, IAttackSkill skill) { _rayCaster.UpdateFocus(mousePosition); _mover.Move(mousePosition, _rayCaster.Target); if (!_rayCaster.HasTarget()) { return; } var target = _rayCaster.Target; if (target.IsInRange(transform.position)) { skill?.Attack(target.GetComponent <CharacterStats>()); } }