本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
}