Пример #1
0
        public void PolygonCollider()
        {
            var tc = new TestCore();

            tc.Init();

            var collider1 = new PolygonCollider();

            collider1.Position = new Vector2F(30f, 30f);
            collider1.Rotation = MathHelper.DegreeToRadian(10.0f);

            Span <Vector2F> array = stackalloc Vector2F[]
            {
                new Vector2F(10f, 10f),
                new Vector2F(20f, 20f),
                new Vector2F(30f, 30f),
            };

            collider1.SetVertexes(array);

            const string path = "Serialization/PolygonCollider.bin";

            Serialize(path, collider1);

            var collider2 = Deserialize <PolygonCollider>(path);

            Assert.NotNull(collider2);

            Assert.AreEqual(collider1.Position, collider2.Position);
            Assert.AreEqual(collider1.Rotation, collider2.Rotation);
            Assert.True(Enumerable.SequenceEqual(collider1.Vertexes, collider2.Vertexes));

            tc.End();
        }