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

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

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

    public void Refill(int index, int flavor)
    {
        popcornPositions[index].ChangeSkin(flavor);
        popcornPositions[index].gameObject.SetActive(true);
    }

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