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

public class TextCard : MonoBehaviour {

    public Text textUI;

    [HideInInspector]
    public int currentChar = 0;
    [HideInInspector]
    public string text;
	[HideInInspector]
	public GameObject Recipient;


    public void SetText(string t)
    {
        text = t;
        UpdateTextUI();
    }


    public bool ShouldRemove()
    {
        if(currentChar == text.Length)
        {
            return true;
        }
        else
        {
            return false;
        }
    }


    public char GetCurrentCharacter()
    {
        return text[currentChar];
    }


    public void UpdateTextUI()
    {
        string richText = "";

        for(int i = 0; i < text.Length; i++)
        {
            if(i < currentChar)
            {
                richText += "<color=#000000ff>" + text[i].ToString() + "</color>";
            }
            else
            {
                richText += text[i];
            }
        }

        textUI.text = richText;
    }

}
