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

public class MarketCartView : MonoBehaviour
{
    [SerializeField] private List<MarketPopcornView> popcornPositions;
    
    private void ResetDisplay()
    {
        foreach (var popcorn in popcornPositions)
        {
            popcorn.gameObject.SetActive(false);
        }
    }

    public void SetStock(List<int> shopStock)
    {
        ResetDisplay();
        // 陳列
        var i = 0;
        foreach (var flavor in shopStock)
        {
            var popcorn = popcornPositions[i];
            popcorn.ChangeSkin(flavor);
            this.CallWaitForSeconds(.05f * i, () =>
            {
                popcorn.gameObject.SetActive(true);
            });
            i++;
        }
    }

    public void SellStock()
    {
        popcornPositions[0].gameObject.SetActive(false);
    }
}
