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 fortrest
    /// </summary>
    public class FortrestBuilding : 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 FortrestBuilding(Vector3 position, Vector3 rotation, float scale)
            : base(position, rotation, scale)
        {
            // Create bounding boxes for the fortrest.
            CreateBoundingBoxes();
        }

        #endregion

        #region Methods

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

            // 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(-810, 0, -810), world), Vector3.Transform(new Vector3(810, 330, 810), world))));

            // First inner wall on first floor
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(200, 50, -500), world), Vector3.Transform(new Vector3(220, 225, 500), world))));

            // Second inner wall on first floor
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-600, 50, -10), world), Vector3.Transform(new Vector3(600, 225, 10), world))));

            // Left front wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(100, 20, -810), world), Vector3.Transform(new Vector3(810, 290, -790), world))));

            // Middle front wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-100, 200, -810), world), Vector3.Transform(new Vector3(100, 290, -790), world))));

            // Right front wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 20, -810), world), Vector3.Transform(new Vector3(-100, 290, -790), world))));

            // Left wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(790, 20, -790), world), Vector3.Transform(new Vector3(810, 290, 790), world))));

            // Right wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 20, -790), world), Vector3.Transform(new Vector3(-790, 290, 790), world))));

            // Left back wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 20, 790), world), Vector3.Transform(new Vector3(-600, 290, 810), world))));

            // Middle back wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-600, 200, 790), world), Vector3.Transform(new Vector3(-500, 290, 810), world))));

            // Right back wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-500, 20, 790), world), Vector3.Transform(new Vector3(810, 290, 810), world))));

            // Front first fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(710, 290, -810), world), Vector3.Transform(new Vector3(810, 340, -790), world))));

            // Front second fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(410, 290, -810), world), Vector3.Transform(new Vector3(510, 340, -790), world))));

            // Front third fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(110, 290, -810), world), Vector3.Transform(new Vector3(210, 340, -790), world))));

            // Front fourth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-210, 290, -810), world), Vector3.Transform(new Vector3(-110, 340, -790), world))));

            // Front fifth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-510, 290, -810), world), Vector3.Transform(new Vector3(-410, 340, -790), world))));

            // Front sixth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, -810), world), Vector3.Transform(new Vector3(-710, 340, -790), world))));

            // Left first fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(790, 290, -790), world), Vector3.Transform(new Vector3(810, 340, -710), world))));

            // Left second fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(790, 290, -510), world), Vector3.Transform(new Vector3(810, 340, -410), world))));

            // Left third fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(790, 290, -210), world), Vector3.Transform(new Vector3(810, 340, -110), world))));

            // Left fourth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(790, 290, 110), world), Vector3.Transform(new Vector3(810, 340, 210), world))));

            // Left fifth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(790, 290, 410), world), Vector3.Transform(new Vector3(810, 340, 510), world))));

            // Left sixth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(790, 290, 710), world), Vector3.Transform(new Vector3(810, 340, 790), world))));

            // Right first fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, -790), world), Vector3.Transform(new Vector3(-790, 340, -710), world))));

            // Right second fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, -510), world), Vector3.Transform(new Vector3(-790, 340, -410), world))));

            // Right third fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, -210), world), Vector3.Transform(new Vector3(-790, 340, -110), world))));

            // Right fourth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, 110), world), Vector3.Transform(new Vector3(-790, 340, 210), world))));

            // Right fifth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, 410), world), Vector3.Transform(new Vector3(-790, 340, 510), world))));

            // Right sixth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, 710), world), Vector3.Transform(new Vector3(-790, 340, 790), world))));

            // Back first fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(710, 290, 790), world), Vector3.Transform(new Vector3(810, 340, 810), world))));

            // Back second fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(410, 290, 790), world), Vector3.Transform(new Vector3(510, 340, 810), world))));

            // Back third fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(110, 290, 790), world), Vector3.Transform(new Vector3(210, 340, 810), world))));

            // Back fourth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-210, 290, 790), world), Vector3.Transform(new Vector3(-110, 340, 810), world))));

            // Back fifth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-510, 290, 790), world), Vector3.Transform(new Vector3(-410, 340, 810), world))));

            // Back sixth fortrest wall
            boundingBoxesList.Add(new CustomBoundingBox("wall", new BoundingBox(Vector3.Transform(new Vector3(-810, 290, 790), world), Vector3.Transform(new Vector3(-710, 340, 810), world))));

            // Second floor
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(-800, 225, -800), world), Vector3.Transform(new Vector3(800, 250, 640), world))));

            // Seventh stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(700, 200, 640), world), Vector3.Transform(new Vector3(790, 225, 790), world))));

            // Sixth stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(650, 175, 640), world), Vector3.Transform(new Vector3(790, 200, 790), world))));

            // Fifth stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(600, 150, 640), world), Vector3.Transform(new Vector3(790, 175, 790), world))));

            // Fourth stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(550, 125, 640), world), Vector3.Transform(new Vector3(790, 150, 790), world))));

            // Third stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(500, 100, 640), world), Vector3.Transform(new Vector3(790, 125, 790), world))));

            // Second stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(450, 75, 640), world), Vector3.Transform(new Vector3(790, 100, 790), world))));

            // First stair
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(400, 50, 640), world), Vector3.Transform(new Vector3(790, 75, 790), world))));

            // First floor
            boundingBoxesList.Add(new CustomBoundingBox("floor", new BoundingBox(Vector3.Transform(new Vector3(-800, 0, -800), world), Vector3.Transform(new Vector3(800, 50, 800), world))));

        } // End of the CreateBoundingBoxes method

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

            float texCoordScale = 1f;

            // First floor
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-800, 0, -800), new Vector3(800, 50, 800), texCoordScale));

            // First stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(400, 50, 640), new Vector3(790, 75, 790), texCoordScale));

            // Second stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(450, 75, 640), new Vector3(790, 100, 790), texCoordScale));

            // Third stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(500, 100, 640), new Vector3(790, 125, 790), texCoordScale));

            // Fourth stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(550, 125, 640), new Vector3(790, 150, 790), texCoordScale));

            // Fifth stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(600, 150, 640), new Vector3(790, 175, 790), texCoordScale));

            // Sixth stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(650, 175, 640), new Vector3(790, 200, 790), texCoordScale));

            // Seventh stair
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(700, 200, 640), new Vector3(790, 225, 790), texCoordScale));

            // Second floor
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-800, 225, -800), new Vector3(800, 250, 640), texCoordScale));

            // First inner wall on first floor
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(200, 50, -500), new Vector3(220, 225, 500), texCoordScale));

            // Second inner wall on first floor
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-600, 50, -10), new Vector3(600, 225, 10), texCoordScale));

            // Left front wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(100, 20, -810), new Vector3(810, 290, -790), texCoordScale));

            // Middle front wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-100, 200, -810), new Vector3(100, 290, -790), texCoordScale));

            // Right front wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 20, -810), new Vector3(-100, 290, -790), texCoordScale));

            // Left wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(790, 20, -790), new Vector3(810, 290, 790), texCoordScale));

            // Right wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 20, -790), new Vector3(-790, 290, 790), texCoordScale));

            // Left back wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 20, 790), new Vector3(-600, 290, 810), texCoordScale));

            // Middle back wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-600, 200, 790), new Vector3(-500, 290, 810), texCoordScale));

            // Right back wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-500, 20, 790), new Vector3(810, 290, 810), texCoordScale));

            // Front first fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(710, 290, -810), new Vector3(810, 340, -790), texCoordScale));

            // Front second fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(410, 290, -810), new Vector3(510, 340, -790), texCoordScale));

            // Front third fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(110, 290, -810), new Vector3(210, 340, -790), texCoordScale));

            // Front fourth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-210, 290, -810), new Vector3(-110, 340, -790), texCoordScale));

            // Front fifth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-510, 290, -810), new Vector3(-410, 340, -790), texCoordScale));

            // Front sixth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, -810), new Vector3(-710, 340, -790), texCoordScale));

            // Left first fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(790, 290, -790), new Vector3(810, 340, -710), texCoordScale));

            // Left second fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(790, 290, -510), new Vector3(810, 340, -410), texCoordScale));

            // Left third fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(790, 290, -210), new Vector3(810, 340, -110), texCoordScale));

            // Left fourth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(790, 290, 110), new Vector3(810, 340, 210), texCoordScale));

            // Left fifth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(790, 290, 410), new Vector3(810, 340, 510), texCoordScale));

            // Left sixth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(790, 290, 710), new Vector3(810, 340, 790), texCoordScale));

            // Right first fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, -790), new Vector3(-790, 340, -710), texCoordScale));

            // Right second fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, -510), new Vector3(-790, 340, -410), texCoordScale));

            // Right third fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, -210), new Vector3(-790, 340, -110), texCoordScale));

            // Right fourth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, 110), new Vector3(-790, 340, 210), texCoordScale));

            // Right fifth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, 410), new Vector3(-790, 340, 510), texCoordScale));

            // Right sixth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, 710), new Vector3(-790, 340, 790), texCoordScale));

            // Back first fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(710, 290, 790), new Vector3(810, 340, 810), texCoordScale));

            // Back second fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(410, 290, 790), new Vector3(510, 340, 810), texCoordScale));

            // Back third fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(110, 290, 790), new Vector3(210, 340, 810), texCoordScale));

            // Back fourth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-210, 290, 790), new Vector3(-110, 340, 810), texCoordScale));

            // Back fifth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-510, 290, 790), new Vector3(-410, 340, 810), texCoordScale));

            // Back sixth fortrest wall
            boxPrimitivesList.Add(new CubePrimitive(graphicsDevice, new Vector3(-810, 290, 790), new Vector3(-710, 340, 810), texCoordScale));

            // Return the list with cubes.
            return boxPrimitivesList;

        } // End of the CreateCubes method.

        #endregion

    } // End of class

} // End of namespace
