public bool Intersects(Rectangle theRectangle) { BaseObject o = new BaseObject(theRectangle, 0.0f); o.CalculateCorners(); return(Intersects(o)); }
void checkForSledgeHammerUse(GameTime gameTime) { if (sledgeHammerInUse && (!isaac.hasPowerUp(PowerUpType.SledgeHammer) || !isaac.getActivePowerUp(PowerUpType.SledgeHammer).ActiveTimer.IsRunning)) { sledgeHammerInUse = false; } if (sledgeHammerInUse) { sledgeHammerOrigin.Rotation += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime); sledgeHammer.Rotation += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime); sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width; sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height; sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2; sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner.Y; sledgeHammerOrigin.CalculateCorners(); sledgeHammer.CalculateCorners(); } if (!sledgeHammerInUse && Keyboard.GetState().IsKeyDown(Keys.Space) && isaac.hasPowerUp(PowerUpType.SledgeHammer) && isaac.getActivePowerUp(PowerUpType.SledgeHammer).Charges > 0)// && //!isaacHurtAnimation.IsRunning) { PowerUp p = isaac.getActivePowerUp(PowerUpType.SledgeHammer); p.ActiveTimer.Restart(); soundEffectManager.Play(useHammerSound, .5f); sledgeHammerOrigin.Rotation = 0f; sledgeHammer.Rotation = 0f; sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width; sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height; sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2; sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner.Y; sledgeHammerInUse = true; } }
public bool Intersects(Rectangle theRectangle) { BaseObject o = new BaseObject(theRectangle, 0.0f); o.CalculateCorners(); return Intersects(o); }
void checkForSledgeHammerUse(GameTime gameTime) { /*if (sledgeHammerInUse) * { * if (sledgeHammerDirection == Direction.West) * { * sledgeHammerOrigin.Rotation -= SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds; * sledgeHammer.Rotation -= SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds; * //if (sledgeHammer.Rotation <= -10.99f) * if (sledgeHammer.Rotation <= -3.14f) * { * sledgeHammerInUse = false; * return; * } * } * else if (sledgeHammerDirection == Direction.East) * { * sledgeHammerOrigin.Rotation += SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds; * sledgeHammer.Rotation += SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds; * //if (sledgeHammer.Rotation >= 10.99f) * if (sledgeHammer.Rotation >= 3.14f) * { * sledgeHammerInUse = false; * return; * } * } * sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width; * sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height; * sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner().X + sledgeHammer.Width / 2; * sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner().Y; * //4.71f * } * * if (!sledgeHammerInUse && Keyboard.GetState().IsKeyDown(Keys.Q)) * { * //sledgeHammerOrigin.Rotation = 1.62f; * //sledgeHammer.Rotation = 1.62f; * sledgeHammerOrigin.Rotation = 0f; * sledgeHammer.Rotation = 0f; * sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width; * sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height; * sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner().X + sledgeHammer.Width / 2; * sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner().Y; * sledgeHammerInUse = true; * sledgeHammerDirection = Direction.West; * } * else if (!sledgeHammerInUse && Keyboard.GetState().IsKeyDown(Keys.E)) * { * //sledgeHammerOrigin.Rotation = -1.62f; * //sledgeHammer.Rotation = -1.62f; * sledgeHammerOrigin.Rotation = 0f; * sledgeHammer.Rotation = 0f; * sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width; * sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height; * sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner().X + sledgeHammer.Width / 2; * sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner().Y; * sledgeHammerInUse = true; * sledgeHammerDirection = Direction.East; * }*/ if (sledgeHammerInUse && (!isaac.hasPowerUp(PowerUpType.SledgeHammer) || !isaac.getActivePowerUp(PowerUpType.SledgeHammer).ActiveTimer.IsRunning)) { sledgeHammerInUse = false; } if (sledgeHammerInUse) { sledgeHammerOrigin.Rotation += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime); sledgeHammer.Rotation += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime); sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width; sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height; sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2; sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner.Y; sledgeHammerOrigin.CalculateCorners(); sledgeHammer.CalculateCorners(); } if (!sledgeHammerInUse && Keyboard.GetState().IsKeyDown(Keys.Space) && isaac.hasPowerUp(PowerUpType.SledgeHammer) && isaac.getActivePowerUp(PowerUpType.SledgeHammer).Charges > 0 && (DateTime.Now - timeOfLastDeath).TotalSeconds > .5) { PowerUp p = isaac.getActivePowerUp(PowerUpType.SledgeHammer); p.ActiveTimer.Restart(); soundEffectManager.Play(useHammer, .5f); sledgeHammerOrigin.Rotation = 0f; sledgeHammer.Rotation = 0f; sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width; sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height; sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2; sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner.Y; sledgeHammerInUse = true; } }