Ejemplo n.º 1
0
        public void RectangleCoverTiles(float x, float y, float size)
        {
            var             rectangle  = new RectangleShape(new Vector2(x + size / 2, y + size / 2), new Vector2(size, size));
            List <Vector2I> coverTiles = rectangle.CoverTiles();

            if (TestUtils.FloatEq(x, 0.2f) && TestUtils.FloatEq(y, 0.2f) && TestUtils.FloatEq(size, 0.5f))
            {
                Assert.True(coverTiles.Count == 1);
                Assert.Contains(Vector2I.Zero, coverTiles);
            }

            if (TestUtils.FloatEq(x, 0f) && TestUtils.FloatEq(y, 0f) && TestUtils.FloatEq(size, 1.5f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
                return;
            }

            if (TestUtils.FloatEq(x, 0f) && TestUtils.FloatEq(y, 0f) && TestUtils.FloatEq(size, 2f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
                return;
            }

            if (TestUtils.FloatEq(x, 0.1f) && TestUtils.FloatEq(y, 0.1f) && TestUtils.FloatEq(size, 1.5f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
            }
        }
Ejemplo n.º 2
0
        public void RectangleCoverTiles(float x, float y, float size)
        {
            var rectangle = new RectangleShape(new Vector2(x + size/2, y + size/2), new Vector2(size, size));
            List<Vector2I> coverTiles = rectangle.CoverTiles();

            if (TestUtils.FloatEq(x, 0.2f) && TestUtils.FloatEq(y, 0.2f) && TestUtils.FloatEq(size, 0.5f))
            {
                Assert.True(coverTiles.Count == 1);
                Assert.Contains(Vector2I.Zero, coverTiles);
            }

            if (TestUtils.FloatEq(x, 0f) && TestUtils.FloatEq(y, 0f) && TestUtils.FloatEq(size, 1.5f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
                return;
            }

            if (TestUtils.FloatEq(x, 0f) && TestUtils.FloatEq(y, 0f) && TestUtils.FloatEq(size, 2f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
                return;
            }

            if (TestUtils.FloatEq(x, 0.1f) && TestUtils.FloatEq(y, 0.1f) && TestUtils.FloatEq(size, 1.5f))
            {
                Assert.True(coverTiles.Count == 4);
                Assert.Contains(Vector2I.Zero, coverTiles);
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
            }
        }