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

public class Bar : MonoBehaviour
{
    private SpriteRenderer bar;
    private Vector3 maxSize;

    private void Awake()
    {
        bar = transform.GetChild(0).GetComponent<SpriteRenderer>();
        maxSize = bar.transform.localScale;
        Reset();
    }

    public void Reset()
    {
        bar.transform.localScale = new Vector3(0, maxSize.y, maxSize.z);
    }

    public void Resize(float max, float cur)
    {
        float proportion = cur / max;
        bar.transform.localScale = new Vector3(proportion * maxSize.x, maxSize.y, maxSize.z);
    }
}
