Esempio n. 1
0
        public void CircleCoverTiles(float x, float y, float radius)
        {
            var             circle     = new CircleShape(new Vector2(x, y), radius);
            List <Vector2I> coverTiles = circle.CoverTiles();

            if (TestUtils.FloatEq(x, 0.7f) && TestUtils.FloatEq(y, 0.7f) && TestUtils.FloatEq(radius, 0.1f))
            {
                Assert.True(coverTiles.Count == 1);
                Assert.Contains(Vector2I.Zero, coverTiles);
            }

            if (TestUtils.FloatEq(x, 1.2f) && TestUtils.FloatEq(y, 1.2f) && TestUtils.FloatEq(radius, 0.7f))
            {
                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, 1f) && TestUtils.FloatEq(y, 1f) && TestUtils.FloatEq(y, 0.8f))
            {
                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, 1f) && TestUtils.FloatEq(y, 1f) && TestUtils.FloatEq(radius, 1f))
            {
                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, 1.1f) && TestUtils.FloatEq(y, 1.1f) && TestUtils.FloatEq(radius, 0.8f))
            {
                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, 2f) && TestUtils.FloatEq(y, 2f) && TestUtils.FloatEq(radius, 1.2f))
            {
                Assert.True(coverTiles.Count == 12);
                Assert.True(!coverTiles.Exists(a => a == new Vector2I(0, 0)));
                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, 1.5f) && TestUtils.FloatEq(y, 2f) && TestUtils.FloatEq(radius, 1.05f))
            {
                Assert.True(coverTiles.Count == 8);
                Assert.True(!coverTiles.Exists(a => a == new Vector2I(0, 0)));
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
            }
        }
Esempio n. 2
0
        public void CircleCoverTiles(float x, float y, float radius)
        {
            var circle = new CircleShape(new Vector2(x, y), radius);
            List<Vector2I> coverTiles = circle.CoverTiles();

            if (TestUtils.FloatEq(x, 0.7f) && TestUtils.FloatEq(y, 0.7f) && TestUtils.FloatEq(radius, 0.1f))
            {
                Assert.True(coverTiles.Count == 1);
                Assert.Contains(Vector2I.Zero, coverTiles);
            }

            if (TestUtils.FloatEq(x, 1.2f) && TestUtils.FloatEq(y, 1.2f) && TestUtils.FloatEq(radius, 0.7f))
            {
                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, 1f) && TestUtils.FloatEq(y, 1f) && TestUtils.FloatEq(y, 0.8f))
            {
                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, 1f) && TestUtils.FloatEq(y, 1f) && TestUtils.FloatEq(radius, 1f))
            {
                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, 1.1f) && TestUtils.FloatEq(y, 1.1f) && TestUtils.FloatEq(radius, 0.8f))
            {
                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, 2f) && TestUtils.FloatEq(y, 2f) && TestUtils.FloatEq(radius, 1.2f))
            {
                Assert.True(coverTiles.Count == 12);
                Assert.True(!coverTiles.Exists(a => a == new Vector2I(0, 0)));
                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, 1.5f) && TestUtils.FloatEq(y, 2f) && TestUtils.FloatEq(radius, 1.05f))
            {
                Assert.True(coverTiles.Count == 8);
                Assert.True(!coverTiles.Exists(a => a == new Vector2I(0, 0)));
                Assert.Contains(new Vector2I(0, 1), coverTiles);
                Assert.Contains(new Vector2I(1, 0), coverTiles);
                Assert.Contains(new Vector2I(1, 1), coverTiles);
            }
        }