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.
    /// </summary>
    public abstract class PowerUp
    {
        #region Variables

        // Position
        public Vector2 position;

        // Collision rectangle
        public Rectangle collisionRectangle;

        // Duration
        public bool isDurationInfinite;
        public int durationFrames;
        public int durationCounter = 0;

        // Textures
        public Texture2D powerUpTexture;

        // Power up value
        public int powerUpValue;

        #endregion

        #region Constructors

        /// <summary>
        /// Create a new power up.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="powerUpTexture"></param>
        public PowerUp(Vector2 position, int powerUpValue, Texture2D powerUpTexture)
        {
            // Set values for instance variables.
            this.position = position;

            // Set the texture
            this.powerUpTexture = powerUpTexture;

            // Set the power up value
            this.powerUpValue = powerUpValue;

            // Create the collision rectangle
            this.collisionRectangle = new Rectangle((int)this.position.X - 16, (int)this.position.Y - 16, 32, 32);
        }

        #endregion

        #region Methods

        /// <summary>
        /// Check for a collision with a combat unit
        /// </summary>
        /// <param name="combatUnit"></param>
        /// <returns></returns>
        public abstract bool CheckForCollision(CombatUnit combatUnit);

        /// <summary>
        /// This method will reset the state to the state before the power up.
        /// </summary>
        /// <param name="combatUnit"></param>
        public abstract void ResetPowerUp(CombatUnit combatUnit);

        /// <summary>
        /// Draw the power up, must be called inside SpriteBatch.Begin() and SpriteBatch.End(),
        /// </summary>
        /// <param name="spriteBatch"></param>
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            // Draw the power up.
            spriteBatch.Draw(this.powerUpTexture, this.position, null, Color.White, 0, new Vector2(16, 16), 1f, SpriteEffects.None, 0);

        } // End of the draw method.

        #endregion

    } // End of class

} // End of namespace
