Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Projectile"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="hit">The hit.</param>
 /// <param name="target">The target.</param>
 public Projectile(int type, Hit hit, Vector2 target)
 {
     this.type = type;
     this.target = target;
     Hit = hit;
     setLocation(new Vector2(Program.INSTANCE.player.Weapon.getX(), Program.INSTANCE.player.Weapon.getY() + Program.INSTANCE.player.Weapon.definition.mainTexture.Height + (definition.mainTexture.Height / 2)));
     Rotation = (float)Math.Atan2(getY() - target.Y, getX() - target.X);
     Vector2 direction = target - getLocation();
     direction.Normalize();
     velocity = Vector2.Multiply(direction, speed);
 }
Esempio n. 2
0
 /// <summary>
 /// Hits the specified hit.
 /// </summary>
 /// <param name="hit">The hit.</param>
 public void hit(Hit hit)
 {
     lock (receivedHits)
     {
         receivedHits.Enqueue(hit);
         hitted = 25;
         if (this is NPC)
         {
             ((NPC)this).attacking = false;
             //setX(getX() * 0.95f);
         }
     }
 }