using System;
using UnityEngine;
using Random = UnityEngine.Random;

public class TankStockView : MonoBehaviour
{
    [SerializeField] private SpriteRenderer popcornImage;
    [SerializeField] private GameObject unreleaseObject;
    [SerializeField] private float maxPosision = 0.16f;
    [SerializeField] private float minPosision = -0.8f;

    public void SetTankRelease(bool released)
    {
        unreleaseObject.SetActive(!released);
    }

    public void SetStock(StorageTank tank)
    {
        var newPos = popcornImage.transform.localPosition;
        newPos.y = Mathf.Lerp(minPosision, maxPosision, (float) tank.Stock / tank.Capacity);
        popcornImage.transform.localPosition = newPos;
    }
}
