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

namespace FredriksdalAssault2
{
    /// <summary>
    /// This class represent a barack.
    /// </summary>
    public class Barack : Building
    {
        #region Instance variables

        // No variables here yet.

        #endregion

        #region Constructors

       /// <summary>
       /// Create a new barack.
       /// </summary>
       /// <param name="position"></param>
       /// <param name="rotation"></param>
       /// <param name="scale"></param>
        public Barack(Vector3 position, Vector3 rotation, float scale)
            : base(position, rotation, scale) 
        {
            // Create bounding boxes for the house.
            CreateBoundingBoxes();
        }

        #endregion

        #region Methods

        /// <summary>
        /// Create bounding boxes for the barack.
        /// </summary>
        public override void CreateBoundingBoxes()
        {
            // Create a new list of bounding boxes.
            this.boundingBoxesList = new List<CustomBoundingBox>(12);

            // Create the world matrix used to place bounding boxes in 2D world space.
            Matrix world = this.world;

            // The full building
            boundingBoxesList.Add(new CustomBoundingBox("building", new BoundingBox(Vector3.Transform(new Vector3(-220, -40, -110), world), Vector3.Transform(new Vector3(220, 130, 120), world))));

            // Front left wall.
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-210, -40, 90), world), Vector3.Transform(new Vector3(-140, 110, 110), world))));

            // Front right wall.
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-50, -40, 90), world), Vector3.Transform(new Vector3(210, 110, 110), world))));

            // Right solid wall.
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(190, -40, -90), world), Vector3.Transform(new Vector3(210, 110, 90), world))));

            // Left solid wall.
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-210, -40, -90), world), Vector3.Transform(new Vector3(-190, 110, 90), world))));

            // Front left wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-210, -40, -110), world), Vector3.Transform(new Vector3(-150, 110, -90), world))));

            // Front lower wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-150, -40, -110), world), Vector3.Transform(new Vector3(150, 40, -90), world))));

            // Front middle wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-20, 40, -110), world), Vector3.Transform(new Vector3(20, 80, -90), world))));

            // Front upper wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-150, 80, -110), world), Vector3.Transform(new Vector3(150, 110, -90), world))));

            // Front right wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(150, -40, -110), world), Vector3.Transform(new Vector3(210, 110, -90), world))));

            // Roof
            boundingBoxesList.Add(new CustomBoundingBox("roof", new BoundingBox(Vector3.Transform(new Vector3(-220, 110, -120), world), Vector3.Transform(new Vector3(220, 130, 120), world))));

            // Floor
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(-200, -40, -100), world), Vector3.Transform(new Vector3(200, 0, 100), world))));
    
        } // End of the CreateBoundingBoxes method

        /// <summary>
        /// Get a list of cube primitives that represent a barack.
        /// </summary>
        /// <param name="graphicsDevice"></param>
        /// <returns>A list with CubePrimitives</returns>
        public static List<CubePrimitive> CreateCubes(GraphicsDevice graphicsDevice)
        {
            //create a list of cube primitives)
            List<CubePrimitive> boxPrimitivesList = new List<CubePrimitive>(11);

            float texCoordScale = 1f;

            // Floor
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-200, -60, -100), new Vector3(200, 0, 100), texCoordScale));

            // Roof
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-220, 110, -120), new Vector3(220, 140, 120), texCoordScale));

            // Front left wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-210, -20, 90), new Vector3(-140, 110, 110), texCoordScale));

            // Front right wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-50, -20, 90), new Vector3(210, 110, 110), texCoordScale));

            // Right solid wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(190, -20, -90), new Vector3(210, 110, 90), texCoordScale));

            // Left solid wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-210, -20, -90), new Vector3(-190, 110, 90), texCoordScale));

            // Front left wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-210, -20, -110), new Vector3(-150, 110, -90), texCoordScale));

            // Front lower wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-150, -20, -110), new Vector3(150, 40, -90), texCoordScale));

            // Front middle wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-20, 40, -110), new Vector3(20, 80, -90), texCoordScale));

            // Front upper wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-150, 80, -110), new Vector3(150, 110, -90), texCoordScale));

            // Front right wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(150, -20, -110), new Vector3(210, 110, -90), texCoordScale));

            // Return the list with cubes.
            return boxPrimitivesList;

        } // End of the CreateCubes method.

        #endregion


    } // End of class

} // End of namespace
