示例#1
0
 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);
        }
示例#3
0
 private void ResetTarget()
 {
     targetBehaviour = null;
     target          = null;
 }
 public void OnTargetReached(GeneratorShipTarget target)
 {
     target.DeactivateTarget();
 }