/// <summary>
        /// Does the movement.
        /// </summary>
        override public bool DoMove()
        {
            // Early out don't move if not enabled
            if (!enabled)
            {
                return(true);
            }

            // Early out if we have reached the last way point
            if (!loop && currentWayPoint >= wayPoints.Count)
            {
                return(true);
            }

            // Loop
            if (loop && currentWayPoint >= wayPoints.Count)
            {
                currentWayPoint = 0;
            }


            if (!tweenStarted)
            {
                // Special case We use speed like a delay if the mode is set to SNAP
                if (tweenMode == TweenMode.SNAP)
                {
                    StartCoroutine(SnapAfterDelay(wayPoints[currentWayPoint]));
                }
                else
                {
                    Vector2 targetPosition = wayPoints[currentWayPoint];
                    tweener = GetComponent <IMobPositionTweener> ();
                    if (tweener == null)
                    {
                        tweener             = gameObject.AddComponent <IMobPositionTweener> ();
                        tweener.UseGameTime = true;
                    }
                    tweener.TweenWithRate(tweenMode, enemy, targetPosition, moveSpeed, MoveComplete);
                    tweenStarted = true;
                }
            }
            return(true);
        }
예제 #2
0
 /// <summary>
 /// Does the movement.
 /// </summary>
 override public bool DoMove()
 {
     if (!tweenStarted)
     {
         tweener = GetComponent <IMobPositionTweener> ();
         if (tweener == null)
         {
             tweener             = gameObject.AddComponent <IMobPositionTweener> ();
             tweener.UseGameTime = true;
         }
         tweener.TweenWithRate(tweenMode, enemy, targetPosition, moveSpeed, MoveComplete);
         tweenStarted = true;
     }
     return(true);
 }