예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }