Esempio n. 1
0
        /// <summary>
        /// Only use for auto attack
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="target"></param>
        public void MoveToTarget(AttackableUnit target, Action onTargetReach, float distanceToTarget = 0)
        {
            this.TargetUnit          = target;
            this.WaypointsIndex      = 1;
            this.DistanceToTarget    = distanceToTarget;
            this.OnTargetReachAction = onTargetReach;
            Vector2 targetPosition = target.Position;

            if (distanceToTarget > 0)
            {
                targetPosition = Geo.GetPointOnCircle(target.Position, target.GetAngleBetween(Unit), distanceToTarget);
            }

            Waypoints = new List <Vector2>()
            {
                Unit.Position, targetPosition
            };                                                                 // A* right here
            End = false;
        }