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;

namespace FredriksdalAssault2
{
    /// <summary>
    /// This class represent a weapon.
    /// </summary>
    public class Weapon
    {
        #region Instance variables

        // A weapon model
        Model weapon;

        #endregion

        #region Constructors

        /// <summary>
        /// Create a new weapon.
        /// </summary>
        /// <param name="content"></param>
        public Weapon(ContentManager content)
        {
            // Load the weapon.
            this.weapon = content.Load<Model>("Models/SoldierResources/weapon");
        }

        #endregion

        #region Methods

        /// <summary>
        /// Draw the weapon
        /// </summary>
        /// <param name="view"></param>
        /// <param name="projection"></param>
        public void DrawWeapon(Matrix view, Matrix projection)
        {
            // Set the world variable for the weapon.
            Matrix cameraWorld = Matrix.Invert(view);
            Matrix weaponWorld = Matrix.CreateScale(0.4f) * Matrix.CreateWorld(cameraWorld.Translation, cameraWorld.Right, cameraWorld.Up) * Matrix.CreateTranslation(1f, -7f, 2f);

            // Loop through each mesh in the model and draw it.
            foreach (ModelMesh mesh in this.weapon.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = weaponWorld;
                    effect.View = view;
                    effect.Projection = projection;

                    effect.EnableDefaultLighting();
                }

                mesh.Draw();
            }

        } // End of the draw weapon method.

        #endregion

    } // End of class

} // End of namespace
