public void TestProjectileMethod() { world world1 = new world(); projectile p = new projectile(0, new Vector2D(0, 0), new Vector2D(0, 0), true, 1); star s = new star(0, new Vector2D(0, 0), 1); world1.addStar(s); String A = p.ToString(); projectile s1 = JsonConvert.DeserializeObject <projectile>(A); world1.setFrame(50); world1.setRespawn(300); world1.setSize(750); world1.update(); Assert.AreEqual(p.getID(), 0); Assert.AreEqual(new Vector2D(0, 0), p.getloc()); Assert.AreEqual(new Vector2D(0, 0), p.getdir()); Assert.AreEqual(p.checkAlive(), true); Assert.AreEqual(p.getOwner(), 1); p = new projectile(0, new Vector2D(0, 0), new Vector2D(0, 0), true, 1); p.update(750, world1.getStar().Values); p.die(); projectile p1 = new projectile(1, new Vector2D(0, 376), new Vector2D(0, 0), true, 2); p1.update(750, world1.getStar().Values); }
/// <summary> /// drawing the projectile /// </summary> /// <param name="o"></param> /// <param name="e"></param> private void drawProjectile(object o, PaintEventArgs e) { int projWidth = 20; projectile s = o as projectile; Image image = arrays2[s.getOwner() % arrays2.Length]; e.Graphics.DrawImage(image, 0 - (projWidth / 2), 0 - (projWidth / 2), projWidth, projWidth); }