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



public class DrinkRenderer : MonoBehaviour
{
    public Drink Drink = null;

    [SerializeField]
    private GameObject BubbleSubObject = null;

    [SerializeField]
    private GameObject ProgressSubObject = null;

    [SerializeField]
    private GameObject FilledProgressBG = null;

    [SerializeField]
    private GameObject FilledProgressSwipe = null;

    [SerializeField]
    private GameObject BobaSubObject = null;

    [SerializeField]
    private GameObject BlackTeaSubObject = null;

    [SerializeField]
    private GameObject LightIceSubObject = null;

    [SerializeField]
    private GameObject RegularIceSubObject  = null;

    [SerializeField]
    private GameObject SealedSubObject = null;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        UpdateAppearance();
    }

    void UpdateAppearance()
    {
        BubbleSubObject.SetActive(Drink.drinkOrigination == DrinkRenderMode.Order);
        ProgressSubObject.SetActive(Drink.drinkOrigination == DrinkRenderMode.Physical);
        FilledProgressBG.SetActive(Drink.drinkOrigination == DrinkRenderMode.Progress);
        FilledProgressSwipe.SetActive(Drink.drinkOrigination == DrinkRenderMode.Progress);

        if (Drink.drinkOrigination == DrinkRenderMode.Progress)
        {
            float timeRemaining = Drink.progressFillTime - Time.time;
            if (timeRemaining < 0.0f)
                timeRemaining = 0.0f;

            float timeElapsed = Drink.progressFillDuration - timeRemaining;

            if (timeElapsed > Drink.progressStopAt)
                timeElapsed = Drink.progressStopAt;

            FilledProgressSwipe.GetComponent<UnityEngine.UI.Image>().fillAmount = timeElapsed / Drink.progressFillDuration;
        }

        BobaSubObject.SetActive(Drink.HasBoba);
        BlackTeaSubObject.SetActive(Drink.TeaType == TeaType.Black);
        LightIceSubObject.SetActive(Drink.IceLevel == 1);
        RegularIceSubObject.SetActive(Drink.IceLevel == 2);
        SealedSubObject.SetActive(Drink.Sealed);
    }


}
