using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IntroTitleScript : MonoBehaviour
{
    public GameObject title;
    public GameObject subTitle;
    public GameObject background;

    public float duration;

    public float cpt;

    // Start is called before the first frame update
    void Start()
    {
        cpt = 0;
        background.SetActive(true);
    }

    // Update is called once per frame
    void Update()
    {
        cpt += Time.deltaTime;
        if(cpt <= duration/2f)
        {
            title.transform.position = Vector3.Lerp(Vector3.right*-15+Vector3.up*4f, Vector3.right * -6f + Vector3.up * 4f, cpt / (duration / 2f));
        }
        else if(cpt <= duration)
        {
            subTitle.transform.position = Vector3.Lerp(Vector3.right * -15 + Vector3.up * 2f, Vector3.right * -3f + Vector3.up * 2f, (cpt / duration));
        }
        else if(cpt >= duration*2f)
        {
            title.transform.position = Vector3.Lerp(Vector3.right * -6f + Vector3.up * 4f, Vector3.right * -20f, cpt-(duration*2f));
            subTitle.transform.position = Vector3.Lerp(Vector3.right * -3f + Vector3.up * 4f, Vector3.right * -25f, cpt-(duration*2f));
            background.SetActive(false);
        }        
    }
}
