using System;
using System.Collections;
using System.Collections.Generic;
using MPStudio;
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;

namespace MPStudio
{
    public class RunLightText : MonoBehaviour
    {
        public float cd = 0.3f;
        public string colorStr = "red";

        private Text _text;


        private List<string> cList;

        private int fSize;
        public int fSizeAdd=6;


        private int idx=0;
        public bool isRotate = false;
        private void Awake()
        {
            _text = GetComponent<Text>();
            fSize = _text.fontSize;

            string c = _text.text;
            cList = new List<string>()
            {
                $"{CharColorLabel(c)}{c}{c}",
                $"{c}{CharColorLabel(c)}{c}",
                $"{c}{c}{CharColorLabel(c)}",
            };
        }


        // Start is called before the first frame update
        void Start()
        {
            if (isRotate)
            {
                transform.localRotation=Quaternion.Euler(0,0,-180f);
            }
            StartCoroutine(Animal());
        }

        IEnumerator Animal()
        {
            while (true)
            {
                string res = ToolCollect.GetRuleItem(cList, ref idx);
                _text.text = res;
                    yield return new WaitForSeconds(this.cd);
                
            }
        }

        public string CharColorLabel(string c)
        {
            string cStr = c.ToString();

            return $"<size={fSize+fSizeAdd}>{LogNote.ColorLabel(cStr, this.colorStr)}</size>";
        }

    }
}