private void RequestTarget() { targetBehaviour = manager.GetTargetForFollower(myTransform); if (targetBehaviour != null) { target = targetBehaviour.GetComponent <RectTransform>(); } else { target = null; } }
public GeneratorShipTarget GetTargetForFollower(RectTransform follower) { float maxDistance = float.MaxValue; GeneratorShipTarget target = null; foreach (var t in targets) { if (t.IsActive) { var trs = t.GetComponent <RectTransform>(); float distance = Vector2.Distance(trs.anchoredPosition, follower.anchoredPosition); if (distance < maxDistance) { maxDistance = distance; target = t; } } } return(target); }
private void ResetTarget() { targetBehaviour = null; target = null; }
public void OnTargetReached(GeneratorShipTarget target) { target.DeactivateTarget(); }