using UnityEngine;

public class SmoothMovement : Render
{

    private Transform mover;
    private Vector2 startPoint;
    private Vector2 endPoint;
    private float height;

    public SmoothMovement(Transform toMove, Vector2 start, Vector2 end, float time = 0.25f, float height = 0)
    {
        renderDuration = time;
        mover = toMove;
        startPoint = start;
        endPoint = end;
        this.height = height;

        mover.position = startPoint;
    }

    override public void RenderProgress(float progressFactor)
    {
        if (mover == null)
            return;

        // y = -(2x - 1)^2 + 1
        Vector2 vert = new Vector2(0, height * (-Mathf.Pow(2 * progressFactor - 1, 2) + 1));

        mover.position = vert + startPoint + (endPoint - startPoint) * progressFactor;
    }
	
}
