示例#1
0
    /// <summary>
    /// 判断路径是否有效
    /// </summary>
    /// <param name="startPosition"></param>
    /// <param name="endPosition"></param>
    /// <returns></returns>
    public static bool CheckPath(Vector3 startPosition, Vector3 endPosition)
    {
        ABPath path = ABPath.Construct(startPosition, endPosition);

        path.calculatePartial = true;
        AstarPath.StartPath(path);
        AstarPath.BlockUntilCalculated(path);
        if (path.originalEndPoint == path.endPoint)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    // Token: 0x0600004B RID: 75 RVA: 0x00002F38 File Offset: 0x00001138
    public static void StartPath(Path path, bool pushToFront = false)
    {
        AstarPath astarPath = AstarPath.active;

        if (astarPath == null)
        {
            UnityEngine.Debug.LogError("There is no AstarPath object in the scene or it has not been initialized yet");
            return;
        }
        if (path.PipelineState != PathState.Created)
        {
            throw new Exception(string.Concat(new object[]
            {
                "The path has an invalid state. Expected ",
                PathState.Created,
                " found ",
                path.PipelineState,
                "\nMake sure you are not requesting the same path twice"
            }));
        }
        if (astarPath.pathProcessor.queue.IsTerminating)
        {
            path.FailWithError("No new paths are accepted");
            return;
        }
        if (astarPath.graphs == null || astarPath.graphs.Length == 0)
        {
            UnityEngine.Debug.LogError("There are no graphs in the scene");
            path.FailWithError("There are no graphs in the scene");
            UnityEngine.Debug.LogError(path.errorLog);
            return;
        }
        path.Claim(astarPath);
        ((IPathInternals)path).AdvanceState(PathState.PathQueue);
        if (pushToFront)
        {
            astarPath.pathProcessor.queue.PushFront(path);
        }
        else
        {
            astarPath.pathProcessor.queue.Push(path);
        }
        if (!Application.isPlaying)
        {
            AstarPath.BlockUntilCalculated(path);
        }
    }
示例#3
0
        public void PreviewPath(Vector3 pos)
        {
            ABPath ABPath;

            if (pos.IsInv())
            {
                return;
            }
            if (pos == SelfBaseUnit.Pos)
            {
                return;
            }
            pos    = OnModifyFinalPos(pos);
            ABPath = ABPath.Construct(SelfBaseUnit.Pos, pos);
            ABPath.traversalProvider = Traversal;
            Seeker.StartPath(ABPath);
            AstarPath.BlockUntilCalculated(ABPath);
            if (ABPath.error)
            {
                CLog.Error(ABPath.errorLog);
            }
        }
示例#4
0
 public static void WaitForPath(Path p)
 {
     AstarPath.BlockUntilCalculated(p);
 }