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.Input;

namespace LD20_Game
{
    class SpikeTrap : BaseTrap
    {
        static Vector2 alertOffset = new Vector2(70, -100);
        static Vector2 alertSize = new Vector2(5, 80);
        static Vector2 Shrinkage = new Vector2(10, 2);

        const int SpikeWidth = 63;
        const int spikeHeight = 10;

        public override BoundingBox FatalArea
        {
            get
            {
                return new BoundingBox(new Vector3(location.X + Shrinkage.X, location.Y + Shrinkage.Y, 0),
                                        new Vector3(location.X + SpikeWidth - Shrinkage.X, location.Y + spikeHeight - Shrinkage.Y, 0));
            }
        }

        public SpikeTrap(int x, int y) : this(new Vector2(x,y)) { }

        public SpikeTrap(Vector2 loc) : base(loc)
        {
            base.type = TrapType.Spike;
        }

        protected override void CreateBuddiAlerts(Vector2 pos)
        {
            int leftXLoc = (int)(pos.X - alertOffset.X);
            int leftYLoc = (int)(pos.Y + alertOffset.Y);
            buddiAlerts.Add(new BoundingBox(new Vector3(leftXLoc, leftYLoc, 0),
                                             new Vector3(leftXLoc + alertSize.X, leftYLoc + alertSize.Y, 0)));

            int rightXLoc = (int)(pos.X + SpikeWidth + alertOffset.X);
            int rightYLoc = (int)(pos.Y + alertOffset.Y);
            buddiAlerts.Add(new BoundingBox(new Vector3(rightXLoc, rightYLoc, 0),
                                            new Vector3(rightXLoc + alertSize.X, rightYLoc + alertSize.Y, 0)));
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(TextureManager.Textures["spikes"], location, Color.White);

            base.Draw(spriteBatch);
        }
    }
}
