Actor player; // Actor which this health bar is attached to #endregion Fields #region Constructors /// <summary> /// Constructs the healthbar and attaced it to the player /// </summary> /// <param name="thePlayer"></param> /// <param name="max"></param> public LifeBar(Actor thePlayer, int max = 75) { player = thePlayer; current = player.Score; maximum = max; Position = player.Position; OffsetPos = new Vector2(-50, -30); Scale = new Vector2(1.0f, 0.5f); }
/// <summary> /// The main collisions we care about are with the player. This method /// returns if they have collided with the given actor or not /// </summary> /// <param name="p2"></param> /// <returns></returns> public bool CheckPlayersCollision(Actor p2) { bool trueCollisionDetected = false; // First check if the texture bounding boxes intersect Rectangle overlap = Rectangle.Intersect(Bound, p2.Bound); // If collision exists, check pixels for real collision if (!overlap.IsEmpty) { trueCollisionDetected = TexturesCollide(TextureArray, Position, p2.TextureArray, p2.Position); } return !overlap.IsEmpty; }
private bool imminentDanger(Actor enemy) { int accuracy = 150; if (Math.Abs(data.currentPlayer.GetPosition().X - enemy.GetPosition().X) < accuracy) { return true; } if (Math.Abs(data.currentPlayer.GetPosition().X - enemy.GetPosition().X) < accuracy) { return true; } return false; }