using System;
using UniRx;
using UnityEngine;
using UnityEngine.UI;

namespace MyGame.Scenes.Cooking.Scripts
{
    public class ResultCoinView : MonoBehaviour
    {
        private static readonly float startDelay = .5f;
        private static readonly float interval = 2f;
        private static readonly int Add = Animator.StringToHash("Add");
        [SerializeField] private Animator coinAnimator;
        [SerializeField] private Text basePriceText;
        [SerializeField] private Text perfectPriceText;

        private void Start()
        {
            Observable.Timer(TimeSpan.FromSeconds(startDelay), TimeSpan.FromSeconds(interval)).Subscribe(_ =>
            {
                coinAnimator.ResetTrigger(Add);
                coinAnimator.SetTrigger(Add);
            }).AddTo(this);
        }

        public void SetPrice(int baseValue, int perfectValue)
        {
            basePriceText.text = baseValue.ToString();
            perfectPriceText.text = perfectValue.ToString();
        }
    }
}