Esempio n. 1
0
        public void bounce(Projectile pro, Mob mob = null)
        {
            pro.physobj.pos = Vector2.Subtract(pro.physobj.pos, pro.physobj.vel);
            if (mob == null)
            {
                pro.physobj.vel = Vector2.Negate(pro.physobj.vel);
            }
            else if (mob.physobj.shape == CollideMode.circle)
            {
                pro.physobj.vel = Vector2.Reflect(pro.physobj.vel, Vector2.Normalize(Vector2.Subtract(pro.physobj.pos, mob.physobj.pos)));
            }
            else if (mob.physobj.shape == CollideMode.box)
            {
                float relx = Math.Abs(pro.physobj.pos.X - mob.physobj.pos.X);
                float rely = Math.Abs(pro.physobj.pos.Y - mob.physobj.pos.Y);
                if (relx > rely)
                {
                    //Console.WriteLine("x > y");
                    pro.physobj.vel = Vector2.Reflect(pro.physobj.vel, new Vector2(1, 0));
                }
                else
                {
                    //Console.WriteLine("y > x");
                    pro.physobj.vel = Vector2.Reflect(pro.physobj.vel, new Vector2(0, 1));
                }
            }
            else pro.physobj.vel = Vector2.Negate(pro.physobj.vel);

            pro.physobj.move();
            pro.angle = Physics.VectorToAngle(pro.physobj.vel);
        }
Esempio n. 2
0
 public void fire(List<Projectile> shots, Vector2 origin, Vector2 target)
 {
     if (curcooldown <= 0)
     {
         for (int i = 0; i < projcount; i++)
         {
             Projectile pro = new Projectile(this, new PhysicsObject(origin), target);
             Vector2 tvel;
             if (projcount > 1 && spread > 0)
             {
                 //give spreads the velocity for the appropriate angle
                 float thisang = Physics.VectorToAngle(Vector2.Subtract(target, origin)) + (i + 0.5f) * (spread / projcount) - (spread / 2);
                 tvel = Physics.AngleToVector(thisang);
             }
             else
             {
                 //standard trajectory
                 tvel = Vector2.Normalize(Vector2.Subtract(target, origin));
             }
             if (inaccuracy != 0)
             {
                 //add some inaccuracy
                 double thisdeviation = random.NextSample(0, inaccuracy);
                 tvel = Vector2.Transform(tvel, Matrix.CreateRotationZ((float)thisdeviation));
             }
             pro.physobj.vel = Vector2.Multiply(tvel, speed);
             pro.physobj.pos = Vector2.Subtract(pro.physobj.pos, pro.physobj.vel);
             pro.drawshot = drawshot;
             pro.duration = duration;
             pro.angle = Physics.VectorToAngle(pro.physobj.vel);
             shots.Add(pro);
         }
         curcooldown = cooldown;
     }
 }
Esempio n. 3
0
 public void burst(Projectile pro, Mob mob = null)
 {
     for (float i = 0; i < Physics.twopi; i += 0.3f)
     {
         Projectile newpro = new Projectile(GameLogic.blankattack, new PhysicsObject(pro.physobj.pos), new Vector2());
         newpro.physobj.vel = Vector2.Multiply(Physics.AngleToVector(i), 10);
         newpro.angle = i;
         newpro.drawshot = 5;
         newpro.duration = 10;
         GameLogic.particles.Add(newpro);
     }
 }
Esempio n. 4
0
 public void seek(Projectile pro)
 {
     if (pro.tarmob == null)
     {
         float neardist = 99999;
         foreach (Enemy enemy in GameLogic.enemies)
         {
             float thisdist = Vector2.Subtract(pro.physobj.pos, enemy.physobj.pos).Length();
             if ( thisdist < neardist)
             {
                 neardist = thisdist;
                 pro.tarmob = enemy;
             }
         }
     }
     Vector2 seekvec = Vector2.Multiply(Vector2.Normalize(Vector2.Subtract(pro.tarmob.physobj.pos, pro.physobj.pos)), 1.5f);
     pro.physobj.vel = Vector2.Add(pro.physobj.vel, seekvec);
     pro.angle = Physics.VectorToAngle(pro.physobj.vel);
     pro.physobj.chokespeed(10, 20);
 }
Esempio n. 5
0
 public void testhit(Projectile pro, Mob mob = null)
 {
     Console.WriteLine("BOOM!");
 }
Esempio n. 6
0
 public void fizzle(Projectile pro, Mob mob = null)
 {
     pro.duration = -1;
 }
Esempio n. 7
0
 public void whirl(Projectile pro)
 {
     float angle = (pro.duration / 3.0f) % Physics.twopi;
     pro.physobj.vel = Vector2.Add(pro.physobj.vel, Physics.AngleToVector(angle));
 }
Esempio n. 8
0
 public void testtick(Projectile pro)
 {
     Console.WriteLine("TICK");
 }
Esempio n. 9
0
 public void spinfast(Projectile pro)
 {
     pro.angle += 0.3f;
 }
Esempio n. 10
0
 public void spin(Projectile pro)
 {
     pro.angle += 0.1f;
 }
Esempio n. 11
0
 public void speedup(Projectile pro)
 {
     pro.physobj.vel = Vector2.Multiply(pro.physobj.vel, 1.04f);
 }
Esempio n. 12
0
 public void slow(Projectile pro)
 {
     pro.physobj.vel = Vector2.Multiply(pro.physobj.vel, 0.97f);
 }
Esempio n. 13
0
 public void ontick(Projectile pro)
 {
     handletick(pro);
 }
Esempio n. 14
0
 public void onexpire(Projectile pro)
 {
     handleexpire(pro, null);
 }
Esempio n. 15
0
 public void oncollide(Projectile pro, Mob mob)
 {
     handlecollide(pro, mob);
 }