public void MoveTest() { Tank tank = new Tank(new Vector2(-20, 0), null, new Random()); tank.Move(); PrivateObject tankObject = new PrivateObject(tank); Assert.IsTrue(((Vector2)tankObject.GetField("speed")).X > 0); }
public void CollisionTest() { Cow cow = new Cow(new Vector2(0, 100), 0, null, new Random()); Tank tank = new Tank(new Vector2(0, 420), null, new Random()); Assert.IsFalse(cow.IsCollided(tank)); cow.Position = new Vector2(0, 400); Assert.IsTrue(cow.IsCollided(tank)); }
public void RotateGunTest() { Tank tank = new Tank(new Vector2(0, 400), null, new Random()); PrivateObject tankObject = new PrivateObject(tank); tank.RotateGun(new Vector2(300, 0), 100, 100); Assert.IsTrue((float)tankObject.GetField("gunRotation") < 0); tank.RotateGun(new Vector2(-300, 0), 100, 100); Assert.IsTrue((float)tankObject.GetField("gunRotation") > 0); }
// Add random tank off screen public void AddRandomTank() { Vector2 position = new Vector2(random.Next(0, 600), random.Next(360, 400)); if (random.Next(2) == 0) position.X -= 1440; // Object appears on previous screen else position.X += 1440; // Object appears on next screen Tank tank = new Tank(position, this, random); AddObject(tank); }