コード例 #1
0
        public int extend2;               // for extension


        public PathFindingRequest(Int3 from, Int3 to, AStarMap map, AStarPathPlanner planner, int ex1 = 0, int ex2 = 0)
        {
            fromPosition = from;
            toPosition   = to;
            INavGraph graph    = map as INavGraph;
            AStarNode fromNode = graph.GetNodeAt(to);
            AStarNode toNode   = graph.GetNodeAt(from);

            if (fromNode == null)
            {
                UnityEngine.Debug.LogError("PathFindingRequest: fromNode is null.");
            }
            if (toNode == null)
            {
                UnityEngine.Debug.LogError("PathFindingRequest: toNode is null.");
            }
            SetData(fromNode, toNode, map, planner);
            extend1 = ex1;
            extend2 = ex2;
        }
コード例 #2
0
        void Start()
        {
            try
            {
                if (navgationData == null)
                {
                    Debug.LogError("Navigation data is null !");
                    return;
                }
                switch (pathMode)
                {
                case PathMode.Grid2D:
                    navgationGraph = new Grid2DGraph();
                    pathPlanner    = new Grid2DPathPlanner();
                    break;

                case PathMode.Grid3D:
                    navgationGraph = new Grid3DGraph();
                    pathPlanner    = new Grid3DPathPlanner();
                    break;

                case PathMode.NavMesh:
                    navgationGraph = new NavMeshGraph();
                    pathPlanner    = new NavMeshPathPlanner();
                    break;
                }
                navgationGraph.Init(navgationData);
                astarEngine.Context.ResizeNodes(navgationGraph.GetNodeCount());
                astarEngine.planner = pathPlanner;
                //pathPlanner.SetGraph(navgationGraph);
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
            }
        }