/// <summary>
        /// 跟随传入路径移动
        /// </summary>
        /// <param name="me">要移动的角色</param>
        /// <param name="goal">移动到的目的地</param>
        public void SimpleMoveToLocation(CController me, CTilePathResult wayPoint, CPawnPathFollowingComp.OnPathFinished onComplete = null)
        {
            if (me.Pawn.IsFollowingPath)
            {
                me.Pawn.StopMovement();
            }

            CPawnPathFollowingComp follower = me.Pawn.Follower;
            //如果我已经到了目的地, 那么就直接达到
            bool alreadyAtGoal = follower.HasReached(wayPoint.EndPos.GetVector3(), 0.5f);

            if (alreadyAtGoal)
            {
                follower.RequestMoveWithImmediateFinish(FinishPathResultType.Success);
                onComplete?.Invoke(FinishPathResultType.Success);
                return;
            }

            //或者我们走过去
            follower.RequestMove(wayPoint, onComplete);
        }
        /// <summary>
        /// 简单的移动到位置
        /// </summary>
        /// <param name="me">要移动的角色</param>
        /// <param name="goal">移动到的目的地</param>
        public void SimpleMoveToLocation(CController me, Vector3 goal, CPawnPathFollowingComp.OnPathFinished onComplete = null)
        {
            if (me.Pawn.IsFollowingPath)
            {
                me.Pawn.StopMovement();
            }

            CPawnPathFollowingComp follower = me.Pawn.Follower;
            //如果我已经到了目的地, 那么就直接达到
            bool alreadyAtGoal = follower.HasReached(goal, 0.5f);

            if (alreadyAtGoal)
            {
                follower.RequestMoveWithImmediateFinish(FinishPathResultType.Success);
                onComplete?.Invoke(FinishPathResultType.Success);
                return;
            }

            //或者我们走过去
            CTilePathResult data = GetWayPointBetween(me.LocalPosition.GetVector2Int(), goal.GetVector2Int());

            follower.RequestMove(data, onComplete);
        }
Exemple #3
0
 public virtual void MoveToLocation(CTilePathResult waypoints, CPawnPathFollowingComp.OnPathFinished onComplete = null)
 {
     CTileNavigationSystem.Instance.SimpleMoveToLocation(this, waypoints, onComplete);
 }
Exemple #4
0
 /// <summary>
 /// 通过导航系统移动到某个地点
 /// IMPORTANT, 本方法会打断之前的运动. 导致会有一帧的停顿
 /// 之前遇到bug, 有单位使用他的速度进行更新. 但因为这一帧的停顿.导致位移有累计差错
 /// </summary>
 /// <param name="goal"></param>
 public virtual void MoveToLocation(Vector3 goal, CPawnPathFollowingComp.OnPathFinished onComplete = null)
 {
     CTileNavigationSystem.Instance.SimpleMoveToLocation(this, goal, onComplete);
 }