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 base house, a big house.
    /// </summary>
    public class BaseHouse : Building
    {
        #region Instance variables

        // No variables here yet.

        #endregion

        #region Constructors

        /// <summary>
        /// Create a new base house.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="rotation"></param>
        /// <param name="scale"></param>
        public BaseHouse(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 house.
        /// </summary>
        public override void CreateBoundingBoxes()
        {
            // Create a new list of bounding boxes.
            this.boundingBoxesList = new List<CustomBoundingBox>(17);

            // 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(-310, -150, -310), world), Vector3.Transform(new Vector3(320, 200, 425), world))));

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

            // Front right wall.
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(250, -80, 290), world), Vector3.Transform(new Vector3(310, 150, 310), world))));

            // Right solid wall.
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(290, -80, -290), world), Vector3.Transform(new Vector3(310, 150, 290), world))));

            // Left solid wall.
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-310, -80, -290), world), Vector3.Transform(new Vector3(-290, 150, 290), world))));

            // Front left wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-310, -80, -310), world), Vector3.Transform(new Vector3(-150, 150, -290), world))));

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

            // Front middle wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-50, 40, -310), world), Vector3.Transform(new Vector3(50, 120, -290), world))));

            // Front upper wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-150, 120, -310), world), Vector3.Transform(new Vector3(150, 150, -290), world))));

            // Front right wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(150, -80, -310), world), Vector3.Transform(new Vector3(310, 150, -290), world))));

            // Roof
            boundingBoxesList.Add(new CustomBoundingBox("roof", new BoundingBox(Vector3.Transform(new Vector3(-320, 150, -320), world), Vector3.Transform(new Vector3(320, 200, 320), world))));

            // Floor
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(-300, -150, -300), world), Vector3.Transform(new Vector3(300, 0, 300), world))));

            // Fifth stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(110, -50, 300), world), Vector3.Transform(new Vector3(250, -25, 325), world))));

            // Fourth stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(110, -75, 300), world), Vector3.Transform(new Vector3(250, -50, 350), world))));

            // Third stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(110, -100, 300), world), Vector3.Transform(new Vector3(250, -75, 375), world))));

            // Second stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(110, -125, 300), world), Vector3.Transform(new Vector3(250, -100, 400), world))));

            // First stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(110, -150, 300), world), Vector3.Transform(new Vector3(250, -125, 425), world))));

        } // End of the CreateBoundingBoxes method

        /// <summary>
        /// Get a list of cube primitives that represent a base house.
        /// </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>(16);

            float texCoordScale = 1f;

            // Floor
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-300, -150, -300), new Vector3(300, 0, 300), texCoordScale));

            // First stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(110, -150, 300), new Vector3(250, -125, 425), texCoordScale));

            // Second stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(110, -125, 300), new Vector3(250, -100, 400), texCoordScale));

            // Third stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(110, -100, 300), new Vector3(250, -75, 375), texCoordScale));

            // Fourth stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(110, -75, 300), new Vector3(250, -50, 350), texCoordScale));

            // Fifth stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(110, -50, 300), new Vector3(250, -25, 325), texCoordScale));

            // Roof
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-320, 150, -320), new Vector3(320, 200, 320), texCoordScale));

            // Front left wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-310, -60, 290), new Vector3(110, 150, 310), texCoordScale));

            // Front right wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(250, -60, 290), new Vector3(310, 150, 310), texCoordScale));

            // Right solid wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(290, -60, -290), new Vector3(310, 150, 290), texCoordScale));

            // Left solid wall.
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-310, -60, -290), new Vector3(-290, 150, 290), texCoordScale));

            // Front left wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-310, -60, -310), new Vector3(-150, 150, -290), texCoordScale));

            // Front lower wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-150, -60, -310), new Vector3(150, 40, -290), texCoordScale));

            // Front middle wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-50, 40, -310), new Vector3(50, 120, -290), texCoordScale));

            // Front upper wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-150, 120, -310), new Vector3(150, 150, -290), texCoordScale));

            // Front right wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(150, -60, -310), new Vector3(310, 150, -290), texCoordScale));

            // Return the list with cubes.
            return boxPrimitivesList;

        } // End of the CreateCubes method.

        #endregion


    } // End of class

} // End of namespace
