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

public class LaughBar : MonoBehaviour
{
    public float initial_score;
    public float total_score;
    public float target_length;
    public RectTransform bar_rect;
    public float change_speed;
    // Start is called before the first frame update
    void Start()
    {
        bar_rect.offsetMax = new Vector2((total_score - initial_score) / total_score * -1920, bar_rect.offsetMax.y);
        calculateLength(initial_score);
        //Debug.Log(target_length);

    }

    // Update is called once per frame
    void Update()
    {
        if (bar_rect.offsetMax.x != target_length)
        {
            bar_rect.offsetMax += new Vector2(target_length - bar_rect.offsetMax.x, 0) * change_speed * Time.deltaTime;
        }
    }

    public void calculateLength(float curr_score)
    {
        target_length = (total_score - curr_score) / total_score * -1920;
    }
}
