public void GetRegionsExcept() { var topLeftCorner = new Vector { X = 1, Y = 1 }; var bottomRightCorner = new Vector { X = 100, Y = 100 }; var tileDimensions = new Vector { X = 10, Y = 10 }; var world = new GridWorld(topLeftCorner, bottomRightCorner, tileDimensions, new MmoItemCache()); var a = new BoundingBox { Min = new Vector { X = 5, Y = 5 }, Max = new Vector { X = 15, Y = 15 } }; a = world.GetRegionAlignedBoundingBox(a); Assert.AreEqual(topLeftCorner, a.Min); Assert.AreEqual(tileDimensions * 2, a.Max); var b = new BoundingBox { Min = new Vector { X = 12, Y = 12 }, Max = new Vector { X = 22, Y = 22 } }; b = world.GetRegionAlignedBoundingBox(b); Assert.AreEqual(tileDimensions + topLeftCorner, b.Min); Assert.AreEqual(tileDimensions * 3, b.Max); HashSet<Region> regionsA = world.GetRegions(a); Assert.AreEqual(4, regionsA.Count); HashSet<Region> regionsB = world.GetRegions(b); Assert.AreEqual(4, regionsB.Count); HashSet<Region> regions = world.GetRegionsExcept(a, b); Assert.AreEqual(3, regions.Count); Region region = world.GetRegion(topLeftCorner); Assert.IsTrue(regions.Contains(region)); region = world.GetRegion(topLeftCorner + new Vector { X = world.TileDimensions.X }); Assert.IsTrue(regions.Contains(region)); region = world.GetRegion(topLeftCorner + new Vector { Y = world.TileDimensions.Y }); Assert.IsTrue(regions.Contains(region)); region = world.GetRegion(topLeftCorner + world.TileDimensions); Assert.IsFalse(regions.Contains(region)); b = new BoundingBox { Min = new Vector { X = 30, Y = 30 }, Max = new Vector { X = 40, Y = 40 } }; b = world.GetRegionAlignedBoundingBox(b); regions = world.GetRegionsExcept(a, b); Assert.AreEqual(4, regions.Count); }
public void GetRegionsExcept() { var topLeftCorner = new Vector { X = 1, Y = 1 }; var bottomRightCorner = new Vector { X = 100, Y = 100 }; var tileDimensions = new Vector { X = 10, Y = 10 }; var world = new GridWorld(topLeftCorner, bottomRightCorner, tileDimensions, new MmoItemCache()); var a = new BoundingBox { Min = new Vector { X = 5, Y = 5 }, Max = new Vector { X = 15, Y = 15 } }; a = world.GetRegionAlignedBoundingBox(a); Assert.AreEqual(topLeftCorner, a.Min); Assert.AreEqual(tileDimensions * 2, a.Max); var b = new BoundingBox { Min = new Vector { X = 12, Y = 12 }, Max = new Vector { X = 22, Y = 22 } }; b = world.GetRegionAlignedBoundingBox(b); Assert.AreEqual(tileDimensions + topLeftCorner, b.Min); Assert.AreEqual(tileDimensions * 3, b.Max); HashSet <Region> regionsA = world.GetRegions(a); Assert.AreEqual(4, regionsA.Count); HashSet <Region> regionsB = world.GetRegions(b); Assert.AreEqual(4, regionsB.Count); HashSet <Region> regions = world.GetRegionsExcept(a, b); Assert.AreEqual(3, regions.Count); Region region = world.GetRegion(topLeftCorner); Assert.IsTrue(regions.Contains(region)); region = world.GetRegion(topLeftCorner + new Vector { X = world.TileDimensions.X }); Assert.IsTrue(regions.Contains(region)); region = world.GetRegion(topLeftCorner + new Vector { Y = world.TileDimensions.Y }); Assert.IsTrue(regions.Contains(region)); region = world.GetRegion(topLeftCorner + world.TileDimensions); Assert.IsFalse(regions.Contains(region)); b = new BoundingBox { Min = new Vector { X = 30, Y = 30 }, Max = new Vector { X = 40, Y = 40 } }; b = world.GetRegionAlignedBoundingBox(b); regions = world.GetRegionsExcept(a, b); Assert.AreEqual(4, regions.Count); }