public void CollisionInvader_Test1() { LazerGun gun = new LazerGun(5, 15); Invader[,] invaders = new Invader[1, 2]; invaders[0, 1] = new Invader(5, 5, 15, 9); invaders[0, 1].Speed = 40; IDistanceStrategy d = new DistanceStrategy(); Process p = new Process(d); while (invaders[0, 1].CanShot == 0) { invaders[0, 1].Update(208); } while (!p.isCollision(invaders[0, 1].EnemyBullet, gun)) { invaders[0, 1].Update(516); } p.CollisionInvader(invaders, 0, 1, gun); Assert.AreEqual(2, gun.NumberOfLives); }
public void TryExitTest() { IDistanceStrategy d = new DistanceStrategy(); Process p = new Process(d); PrivateObject privateobj = new PrivateObject(p); p.Init(60, 50, 5, 7); Invader[,] inv = (Invader[, ])privateobj.GetField("_invadersArray"); LazerGun gun = (LazerGun)privateobj.GetField("_gun"); for (var c = 0; c < 6; c++) { for (var i = 0; i < inv.GetLength(0); i++) { for (var j = 0; j < inv.GetLength(1); j++) { inv[i, j].Live = false; } } if (c <= 4) { p.TryChangeLevel(); } else { gun.Live = false; p.TryExitGame(); Assert.IsTrue(p.IsExit); } } }
private void RenderGun(LazerGun obj) { Console.SetCursorPosition(12, 2); Console.Write("Lives: {0}", obj.NumberOfLives); Console.SetCursorPosition(obj.PosX - 2, obj.PosY); Console.Write("XXXXX"); }
public void InvaderWineTest() { Invader inv = new Invader(5, 5, 2, 5); LazerGun l = new LazerGun(5, 5); bool t = Collision.InvaderWin(inv, l); Assert.IsTrue(t); }
public void UpdateTest() { LazerGun l = new LazerGun(5, 2); l.Update(KeyPress.Right, 10); Assert.AreEqual(6, l.PosX); l.Update(KeyPress.Left, 10); Assert.AreEqual(5, l.PosX); }
public void InvaderWin_Test() { LazerGun gun = new LazerGun(5, 5); Invader invader = new Invader(5, 6, 20, 9); IDistanceStrategy d = new DistanceStrategy(); Process p = new Process(d); bool a = p.InvaderWin(gun, invader); Assert.AreEqual(true, a); }
public void isDieTest() { LazerGun l = new LazerGun(2, 5); while (l.NumberOfLives != 0) { l.isDie(); } Assert.AreEqual(0, l.NumberOfLives); }
public void CollisionInvader(Invader[,] enemy, int i, int j, LazerGun gun) { if (InvaderWin(enemy[i, j], gun)) // when Invader win { gun.Live = false; } if (enemy[i, j].CanShot != 0) { if (isCollision(enemy[i, j].EnemyBullet, gun)) { gun.IsDie(); } } }
public void CollisionInvader_Test() { LazerGun gun = new LazerGun(5, 5); Invader[,] invaders = new Invader[1, 2]; Invader invader = new Invader(5, 6, 20, 9); invaders[0, 0] = invader; invaders[0, 1] = new Invader(5, 6, 10, 7); IDistanceStrategy d = new DistanceStrategy(); Process p = new Process(d); p.CollisionInvader(invaders, 0, 1, gun); Assert.IsFalse(gun.Live); }
// Ostap: заведи свій Exception: ApplicationException, так буде легше дебажити public void Init(int x, int y, int pos_x, int pos_y) { if ((x <= 0) || (y <= 0) || (pos_x <= 0) || (pos_y <= 0) || (pos_x >= x / 6) || (pos_y >= y / 6) || (y < (pos_y + 20))) { throw new BadInitProcessException("Game cann't be initialize with this parametrs!"); } Field Playground = new Field(x, y); //Define Size of playground LazerGun gun = new LazerGun(x / 2, y - 1); this._gun = gun; this._playground = Playground; this._enemy_posx = pos_x; this._enemy_posy = pos_y; CreateEnemyArray(x, y); SetEnemy(this._invadersArray, y - 1, 50, pos_x, pos_y); GameStatus = Status.IsRuning; this._timer.Start(); }
public void GetNameTest() { LazerGun l = new LazerGun(2, 5); Assert.AreEqual(2, l.PosX); }
public void ConstructorTest() { LazerGun l = new LazerGun(2, 5); Assert.AreEqual(2, l.PosX); }