using JetBrains.Annotations;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;

public class CreditsScript : MonoBehaviour
{

    public float scrollSpeed;
    private float maxScrollSpeed = 300f;
    [SerializeField] public float maxYPosition;
    [SerializeField] public float minYPosition;
    [SerializeField] public TMP_Text text;
    TMP_Text textfeld;

    private RectTransform rectTransform;

    void Start()
    {
        scrollSpeed = 200f;
        textfeld = this.text;

        maxYPosition = 3200;
        minYPosition = 0;
        rectTransform = GetComponent<RectTransform>();

        Credits();
    }


    void Update()
    {
        rectTransform.anchoredPosition += new Vector2(0, scrollSpeed * Time.deltaTime);


        if (transform.position.y >= maxYPosition)
        {
            //Credits wieder nach unten packen, damit sie loopen

            //this.transform.position.y = minYPosition;
            Debug.Log("The End");
        }
    }

    public void HurryUp()
    {
        //scrollSpeed = 50f;
        scrollSpeed = maxScrollSpeed;

        //if (scrollSpeed > maxScrollSpeed)
        //{
        //    scrollSpeed = maxScrollSpeed;
        //}

        //else
        //{
        //    scrollSpeed = 50f;
        //}
    }

    public void Credits()
    {
        //die Credits einfach hardcoden, dann kann ich die schneller anpassen
        //funktioniert

         textfeld.text = "Assets" +
            "Dark UI kit by kΩsmaragd on Unity Store" +
            "Clean Vector Icons by PONETI on Unity Store" +
            "UX Flat Icons [Free] by Heathen Engineering on Unity Store" +
            "Help Me Font by GGBotNet on itch.io ";
    }
}
