예제 #1
0
 private void DrawPathfindingQueryResult(IDebugCanvas debugCanvas, double agentRadius, DoubleVector3 source, DoubleVector3 dest)
 {
     if (Game.PathfinderCalculator.TryFindPath(agentRadius, source, dest, out var roadmap))
     {
         Console.WriteLine("Yippee ");
         debugCanvas.DrawRoadmap(roadmap);
     }
     else
     {
         Console.WriteLine("Nope");
         debugCanvas.Transform = Matrix4x4.Identity;
         debugCanvas.DrawLine(source, dest, NoPathStroke);
     }
 }
예제 #2
0
        private void DrawTestPathfindingQueries(IDebugCanvas debugCanvas, double agentRadius)
        {
            Console.WriteLine("!@#@!#!@#!@#!");
            var pathfinderResultContext = Game.PathfinderCalculator.UniformCostSearch(
                agentRadius,
                new DoubleVector3(-800, 300, 0),
                new[] {
                new DoubleVector3(-1200, 300, 0),
                new DoubleVector3(-1250, 0, 0),
                new DoubleVector3(1250, -80, 0),
                new DoubleVector3(1250, -280, 0)
            },
                true,
                null,
                debugCanvas);

            Console.WriteLine("!@!@#!#@#!@#!@!@!@!@#!#@!#!@#!@#!");

//         var prc2 = Game.PathfinderCalculator.UniformCostSearch(
//            agentRadius,
//            new DoubleVector3(-800, 300, 0),
//            new[] {
//               new DoubleVector3(-1220, 330, 0),
//               new DoubleVector3(-1250, -300, 0),
//               new DoubleVector3(1290, -80, 0),
//               new DoubleVector3(1250, -380, 0)
//            },
//            true,
//            pathfinderResultContext);
            Console.WriteLine("!@#@");

            for (var i = 0; i < 4; i++)
            {
                if (pathfinderResultContext.TryComputeRoadmap(i, out var roadmap))
                {
                    debugCanvas.DrawRoadmap(roadmap);
                }

//            if (prc2.TryComputeRoadmap(i, out roadmap)) {
//               DrawRoadmap(debugCanvas, roadmap);
//            }
            }
            return;

            var testPathFindingQueries = new[] {
                //            Tuple.Create(new DoubleVector3(-600, 300, 0), new DoubleVector3(950, 950, 0)),
//            Tuple.Create(new DoubleVector3(900, 750, 0), new DoubleVector3(2100, 800, 0))
                Tuple.Create(new DoubleVector3(1250, -80, 0), new DoubleVector3(-800, 300, 0)),
//            Tuple.Create(new DoubleVector3(-800, 300, 0), new DoubleVector3(1250, -80, 0))
//            Tuple.Create(new DoubleVector3(200, 700, 0), new DoubleVector3(2200, 200, 0))
                //            Tuple.Create(new DoubleVector3(60, 40, 0), new DoubleVector3(930, 300, 0)),
                //            Tuple.Create(new DoubleVector3(675, 175, 0), new DoubleVector3(825, 300, 0)),
                //            Tuple.Create(new DoubleVector3(50, 900, 0), new DoubleVector3(950, 475, 0)),
                //            Tuple.Create(new DoubleVector3(50, 500, 0), new DoubleVector3(80, 720, 0))
            };

            foreach (var query in testPathFindingQueries)
            {
                DrawPathfindingQueryResult(debugCanvas, agentRadius, query.Item1, query.Item2);
            }
        }