示例#1
0
        private static Traveler SetupWorld()
        {
            var          world    = ExampleWorld.Sample();
            const string start    = "A";
            var          walker   = new Walker(Vector3.Zero);
            var          traveler = new Traveler(start, world, walker);

            return(traveler);
        }
        private static Traveler SetupTraveler(string start)
        {
            var world    = ExampleWorld.Sample();
            var walker   = new Walker(Vector3.Zero);
            var traveler = new Traveler(start, world, walker);
            var zoner    = new Zoner(traveler, world);

            return(traveler);
        }
示例#3
0
        public void GetZoneBorderFromPointCanGetBorder()
        {
            const string targetZoneName = "B";
            var          want           = ExampleWorld.ZoneA().Boundaries.Find(b => b.ToZone == targetZoneName);
            var          fromPosition   = want.FromPosition;
            var          targetPosition = want.ToPosition;
            var          traveler       = new Traveler
            {
                CurrentZone = ExampleWorld.ZoneA(),
                Position    = Vector3.Zero,
                World       = ExampleWorld.Sample()
            };
            var got = traveler.GetZoneBorderToNameFromPoint(fromPosition);

            Assert.Equal(want, got);
        }
示例#4
0
        public void WalkThroughZonesTravelsThroughZones()
        {
            const string start = "A";
            const string end   = "D";

            // setup the world
            var world    = ExampleWorld.Sample();
            var walker   = new Walker(Vector3.Zero);
            var traveler = new Traveler(start, world, walker);
            var zoner    = new Zoner(traveler, world);

            var zones = new List <Zone>
            {
                world.GetZoneByName("A"),
                world.GetZoneByName("C"),
                world.GetZoneByName("D")
            };

            traveler.WalkToZone(end, true);

            Assert.Equal(end, traveler.CurrentZone.Name);
        }
示例#5
0
        public void GoToZoneWillActuallyZoneTheTraveler()
        {
            const string targetZoneName = "B";
            var          targetPosition = ExampleWorld.ZoneA().Boundaries.Find(b => b.ToZone == targetZoneName).ToPosition;
            var          traveler       = new Traveler
            {
                CurrentZone = ExampleWorld.ZoneA(),
                Position    = Vector3.Zero,
                World       = ExampleWorld.Sample()
            };

            traveler.PathMaker = new GridPathMaker {
                ZoneMap = traveler.CurrentZone.Map
            };

            var zoner = new Zoner(traveler, ExampleWorld.Sample());

            traveler.WalkToZone(targetZoneName);


            Assert.Equal(targetZoneName, traveler.CurrentZone.Name);
            Assert.Equal(targetPosition, traveler.Walker.CurrentPosition);
        }
示例#6
0
        public void CanPathFromWorldList()
        {
            var start = "A";
            var end   = "D";

            var world    = ExampleWorld.Sample();
            var traveler = new Traveler();

            var got = WorldPathfinder.FindWorldPathToZone(world, start, end);

            var want = new List <Zone>
            {
                world.GetZoneByName("A"),
                world.GetZoneByName("C"),
                world.GetZoneByName("D")
            };

            Assert.Equal(want.Count, got.Count);
            for (var i = 0; i < want.Count; i++)
            {
                Assert.Equal(want[i].Name, got[i].Name);
            }
        }