using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using StrategicCombat.CombatUnits;

namespace StrategicCombat.PowerUps
{
    /// <summary>
    /// This class represent a power up that increases the health.
    /// </summary>
    public class HealthPowerUp : PowerUp
    {
        #region Constructors

        /// <summary>
        /// Create a new health power up.
        /// </summary>
        /// <param name="position"></param>
        public HealthPowerUp(Vector2 position, int powerUpValue, Texture2D powerUpTexture)
            : base(position, powerUpValue, powerUpTexture)
        {
            // Set duration variables
            this.isDurationInfinite = true;
            this.durationFrames = 0;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Check for a collision with a combat unit
        /// </summary>
        /// <param name="combatUnit"></param>
        /// <returns></returns>
        public override bool CheckForCollision(CombatUnit combatUnit)
        {
            // A flag to mark if there is a collision.
            bool collision = false;

            if (this.collisionRectangle.Intersects(combatUnit.combatCollisionRectangle))
            {
                // Increase the health value.
                combatUnit.health += this.powerUpValue;

                // Check that the health not exceeds the maximum limit.
                if (combatUnit.health >= 580)
                    combatUnit.health = 580;

                // There is a collision
                collision = true;
            }

            // Return the collision variable.
            return collision;

        } // End of the CheckForCollision method.

        /// <summary>
        /// This method will reset the state to the state before the power up.
        /// </summary>
        /// <param name="combatUnit"></param>
        public override void ResetPowerUp(CombatUnit combatUnit)
        {
            // We do not need to reset this power up.

        } // End of the ResetPowerUp method.

        #endregion

    } // End of class

} // End of namespace
