using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace LD20_Game
{
    class HelperArrow
    {
        Vector2 location;
        bool rising = false;
        Vector2 offset;
        const float pathLength = 30;
        const float pathSpeed = 20;

        public bool Visible;


        public HelperArrow(int x, int y, bool visible)
        {
            location = new Vector2(x,y);
            offset = Vector2.Zero;
            Visible = visible;
        }

        public void Update(GameTime gameTime)
        {
            int yPos = GetYPosition(gameTime);

            if (rising)
                yPos = (int)pathLength - yPos;

            offset.Y = yPos;

            if (offset.Y >= pathLength-1)
            {
                offset.Y = pathLength;
                rising = true;
            }

            if (offset.Y <= 1)
            {
                offset.Y = 0;
                rising = false;
            }
        }

        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (Visible)
            {

                spriteBatch.Draw(TextureManager.Textures["goalone"], location + offset, Color.White);
            }
        }

        private int GetYPosition(GameTime gameTime)
        {

            double temp = gameTime.TotalGameTime.TotalMilliseconds % (pathSpeed * pathLength);

            return (int)(temp / pathSpeed);
        }
    }
}
