/// <summary> /// Returns the vertical Euclidean distance to the specified entity /// </summary> /// <param name="e"></param> /// <returns></returns> public int getVDistance(Entity e) { double eLocY = e.getLocation().Y + (e.getTexture().Height / 2); double locY = location.Y + (texture.Height / 2); return((int)Math.Sqrt(Math.Pow(eLocY - locY, 2.0D)) - (e.getTexture().Height / 2) - (texture.Height / 2)); }
/// <summary> /// Returns the horizontal Euclidean distance to the specified entity /// </summary> /// <param name="e">The entity</param> /// <returns>Returns the horizontal Euclidean distance to the specified entity</returns> public int getHDistance(Entity e) { double eLocX = e.getLocation().X + (e.getTexture().Width / 2); double locX = location.X + (texture.Width / 2); return((int)Math.Sqrt(Math.Pow(eLocX - locX, 2.0D)) - (e.getTexture().Width / 2) - (texture.Width / 2)); }
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; }
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; }
/// <summary> /// Returns the vertical Euclidean distance to the specified entity /// </summary> /// <param name="e"></param> /// <returns></returns> public int getVDistance(Entity e) { double eLocY = e.getLocation().Y + (e.getTexture().Height / 2); double locY = location.Y + (texture.Height / 2); return (int) Math.Sqrt(Math.Pow(eLocY - locY, 2.0D)) - (e.getTexture().Height / 2) - (texture.Height / 2); }
/// <summary> /// Returns the horizontal Euclidean distance to the specified entity /// </summary> /// <param name="e">The entity</param> /// <returns>Returns the horizontal Euclidean distance to the specified entity</returns> public int getHDistance(Entity e) { double eLocX = e.getLocation().X + (e.getTexture().Width / 2); double locX = location.X + (texture.Width / 2); return (int) Math.Sqrt(Math.Pow(eLocX - locX, 2.0D)) - (e.getTexture().Width / 2) - (texture.Width / 2); }