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

namespace SFramework
{
    public class SUIPanelUpdate : SUIObjectBase 
    {
        private GameObject _textInfo;
        private GameObject _imageProgress;
        public override void UI_Awake()
        {
            Debug.Log("SUIPanelUpdate -> Awake()");

            GameObject rootCanvas = GameObject.Find("Canvas_Update(Clone)");
            Debug.Assert(rootCanvas != null);

            _rootPanel = rootCanvas.transform.Find("Panel_Update").gameObject;
            Debug.Assert(_rootPanel != null);

            _textInfo = _rootPanel.transform.Find("Text_Info").gameObject;
            Debug.Assert(_textInfo != null);

            _imageProgress = _rootPanel.transform.Find("Image_Progress").gameObject;
            Debug.Assert(_imageProgress != null);
        }

        public override void UI_Start()
        {
            Debug.Log("SUIPanelUpdate -> Start()");
        }

        public void SetProgressPercent(float percent)
        {
            if (percent <= 0.0f) percent = 0.0f;
            if (percent >= 1.0f) percent = 1.0f;

            _imageProgress.GetComponent<UnityEngine.UI.Image>().fillAmount = percent;
        }

        public void SetUpdateInfo(string information)
        {
            _textInfo.GetComponent<UnityEngine.UI.Text>().text = information;
        }
    }
}
