using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Graphics;
using SFML.Window;
using YourBeatingHeart.Main.Helper;
using YourBeatingHeart.Main.Entities;

namespace YourBeatingHeart.Main.States.Play.Entities
{
    class MoonEntity : Entity
    {
        protected Sprite moonSprite;
        protected PlayState PlayState;
        protected static readonly Vector2f moonFrom = new Vector2f(-200, Constants.TARGET_HEIGHT / 2);
        protected static readonly Vector2f moonTo = new Vector2f(Constants.TARGET_WIDTH / 2 - 10, 200);
        protected static readonly Vector2f moonDelta = moonTo - moonFrom;

        public MoonEntity(PlayState playState)
            : base(playState.Game, new Vector2f())
        {
            moonSprite = new Sprite(playState.Game.LoadTexture("Moon.png"));
            moonSprite.Origin = new Vector2f(moonSprite.Texture.Size.X / 2, moonSprite.Texture.Size.Y / 2);
            PlayState = playState;
            Layer = PlayState.Layers.Moon;
        }

        public override void Update(float elapsedTime)
        {
            float percent = 1 - MathHelper.Clamp((float)PlayState.TimeRemaining / Constants.ROUND_LENGTH, 0, 1);
            moonSprite.Position = moonFrom + moonDelta * percent;
        }

        public override void Draw(RenderTarget renderTarget)
        {
            renderTarget.Draw(moonSprite);
        }
    }
}
