Exemple #1
0
        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);
        }
Exemple #2
0
 /// <summary>
 /// fire projectile for a ship
 /// </summary>
 /// <param name="shipID"></param>
 public void Fire(int shipID)
 {
     if (shipgroup[shipID].checkFire(this.time, this.shootFrame))
     {
         projectile proj = new projectile(generatePorj(), shipgroup[shipID].getloc(), shipgroup[shipID].getdir(), true, shipID);
         this.projectileGroup[proj.getID()] = proj;
     }
 }
Exemple #3
0
 /// <summary>
 /// if the projectile disappered we need to remove it from the projectile group
 /// </summary>
 /// <param name="proj"></param>
 public void removeProjectile(projectile proj)
 {
     this.projectileGroup.Remove(proj.getID());
 }
Exemple #4
0
 /// <summary>
 /// this is the helper method used in the GController to add the current proj into the proj group
 /// </summary>
 /// <param name="proj"></param>
 public void addproj(projectile proj)
 {
     this.projectileGroup[proj.getID()] = proj;
 }