Esempio n. 1
0
 public Projectile(Entity owner, Texture2D texture, int velocity, int cooldown, float rotationSpeed, SoundEffect sound)
 {
     this.owner = owner;
     this.texture = texture;
     this.velocity = velocity;
     this.cooldown = cooldown;
     this.rotationSpeed = rotationSpeed;
     this.sound = sound;
     this.origin = new Vector2(texture.Width / 2.0F, texture.Height / 2.0F);
     this.location = new Vector2(owner.getLocation().X + (owner.getTexture().Width - texture.Width) / 2.0F, owner.getLocation().Y + (owner.getTexture().Height - texture.Height) / 2.0F);
     this.direction = Direction.None;
     this.bounds = new Rectangle((int) location.X, (int) location.Y, texture.Width, texture.Height);
     this.rotation = 0.0F;
     this.active = true;
 }
Esempio n. 2
0
 public Projectile(Entity owner, Texture2D texture, int velocity, int cooldown, SoundEffect sound)
     : this(owner, texture, velocity, cooldown, 0f, sound)
 {
 }
Esempio n. 3
0
 /// <summary>
 /// Updates the projectile's direction, position, bounds, and active status
 /// </summary>
 /// <param name="game">The game instance</param>
 /// <param name="entity">The entity to inherit direction from</param>
 public void update(Game1 game, Entity entity)
 {
     if (direction == Direction.None) {
         direction = entity.getDirection();
         rotate();
     }
     if (direction == Direction.North) {
         deriveY(-velocity);
     } else if (direction == Direction.South) {
         deriveY(velocity);
     } else if (direction == Direction.West) {
         deriveX(-velocity);
     } else if (direction == Direction.East) {
         deriveX(velocity);
     }
     rotation += rotationSpeed;
     active = isOnScreen(game);
 }