using Framework.Entities;
using Project.Actors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
using Framework.Extensions;

namespace Assets.Project.Scripts.View
{
    public class DialogDisplay : CoreBehaviour
    {
        public Text element;
        public Text hint;
        public DialogSpeaker speaker;

        // Use this for initialization
        protected override void InnerAwake()
        {
            if (this.hint == null)
            {
                this.hint = this.transform.RecursivelyFindChild("HintText").GetComponent<Text>();
            }
        }

        // Update is called once per frame
        protected override void InnerUpdate()
        {
            if (this.speaker != null)
            {
                this.element.text = this.speaker.currentLine;
                if (Input.GetButtonDown("Submit"))
                {
                    this.speaker.AdvanceDialog();
                }
                if (this.speaker.currentLine != "")
                {
                    this.hint.enabled = true;
                }
                else
                {
                    this.hint.enabled = false;
                }
            }
            else
            {
                this.element.text = "";
                this.hint.enabled = false;
            }
        }
    }
}
