当前位置: 首页>>代码示例>>C#>>正文


C# TestEntity.Move方法代码示例

本文整理汇总了C#中TestEntity.Move方法的典型用法代码示例。如果您正苦于以下问题:C# TestEntity.Move方法的具体用法?C# TestEntity.Move怎么用?C# TestEntity.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestEntity的用法示例。


在下文中一共展示了TestEntity.Move方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InterpolateNoVelocityRecordTest

        public void InterpolateNoVelocityRecordTest()
        {
            var e = new TestEntity();
            var i = new EntityInterpolator();

            e.Position = new Vector2(0);
            i.Update(e, 1);
            Assert.AreEqual(Vector2.Zero, i.DrawPosition);

            e.Move(new Vector2(16));
            i.Update(e, 1);
            Assert.AreEqual(new Vector2(16), i.DrawPosition);

            e.Move(new Vector2(100));
            i.Update(e, 1);
            Assert.AreEqual(new Vector2(116), i.DrawPosition);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:17,代码来源:EntityInterpolatorTests.cs

示例2: MoveTest

        public void MoveTest()
        {
            var e = new TestEntity(new Vector2(10, 10), new Vector2(10, 10));
            Assert.AreEqual(10, e.Position.X);
            Assert.AreEqual(10, e.Position.Y);
            Assert.AreEqual(10, e.Size.X);
            Assert.AreEqual(10, e.Size.Y);

            e.Move(new Vector2(5, 10));
            Assert.AreEqual(15, e.Position.X);
            Assert.AreEqual(20, e.Position.Y);
            Assert.AreEqual(10, e.Size.X);
            Assert.AreEqual(10, e.Size.Y);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:EntityTests.cs

示例3: InterpolateStoppedTest

        public void InterpolateStoppedTest()
        {
            var e = new TestEntity();
            var i = new EntityInterpolator();

            e.Position = new Vector2(0);
            i.Update(e, 1);
            Assert.AreEqual(Vector2.Zero, i.DrawPosition);

            e.Move(new Vector2(16));
            e.SetVelocity(new Vector2(1));
            i.Update(e, 1);
            Assert.AreNotEqual(new Vector2(0), i.DrawPosition);

            e.Move(new Vector2(100));
            e.SetVelocity(new Vector2(0));
            i.Update(e, 1);
            Assert.AreNotEqual(new Vector2(16), i.DrawPosition);

            var last = i.DrawPosition;
            e.Move(new Vector2(50));
            i.Update(e, 10);
            Assert.AreNotEqual(last, i.DrawPosition);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:24,代码来源:EntityInterpolatorTests.cs

示例4: MovementTest01

        public void MovementTest01()
        {
            var moveSize = (int)(Math.Min(SpatialSize.X, SpatialSize.Y) / 4);
            var halfMoveSize = new Vector2(moveSize) / 2f;

            var r = new Random(654987645);
            foreach (var spatial in GetSpatials())
            {
                var entities = new List<TestEntity>();
                for (var i = 0; i < 20; i++)
                {
                    var e = new TestEntity
                    { Position = new Vector2(r.Next((int)SpatialSize.X), r.Next((int)SpatialSize.Y)), Size = new Vector2(32) };
                    entities.Add(e);
                    spatial.Add(e);

                    Assert.IsTrue(spatial.CollectionContains(e), "Spatial: {0}, i: {1}", spatial.GetType().Name, i);
                    Assert.IsTrue(spatial.Contains(e.Position, x => x == e));
                }

                for (var i = 0; i < 40; i++)
                {
                    foreach (var e in entities)
                    {
                        var v = new Vector2(r.Next(moveSize), r.Next(moveSize)) - halfMoveSize;
                        var newPos = v + e.Position;
                        if (newPos.X < 0 || newPos.X >= SpatialSize.X - e.Size.X)
                            v.X = 0;
                        if (newPos.Y < 0 || newPos.Y >= SpatialSize.Y - e.Size.Y)
                            v.Y = 0;

                        e.Move(v);

                        Assert.IsTrue(spatial.CollectionContains(e), "Spatial: {0}, i: {1}", spatial.GetType().Name, i);
                        Assert.IsTrue(spatial.Contains(e.Position, x => x == e), "Spatial: {0}, i: {1}", spatial.GetType().Name, i);
                    }
                }
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:39,代码来源:SpatialTests.cs


注:本文中的TestEntity.Move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。