using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using static System.Net.Mime.MediaTypeNames;

namespace ET.Client
{
	[FriendOf(typeof(UIRuleComponent))]
	public static class UIRuleComponentSystem
    {
		[ObjectSystem]
		public class UIRuleComponentAwakeSystem : AwakeSystem<UIRuleComponent>
		{
			protected override void Awake(UIRuleComponent self, params object[] param)
			{
                ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
                self.noStatsTxt = rc.Get<GameObject>("noStatsTxt");
                self.closeBtn = rc.Get<GameObject>("closeBtn");
                self.closeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnCloseBtn(); });
                self.Init();
            }
        }

        private static void Init(this UIRuleComponent self)
        {
            self.noStatsTxt.SetActive(true);
        }

        public static void OnNextTimeBtn(this UIRuleComponent self)
        {
            
        }
        

        public static async void OnCloseBtn(this UIRuleComponent self)
        {
            await SoundManager.Instance.PlaySound("clickbtnsound");
            self.OnCloseAsync();
        }

        public static async void OnCloseAsync(this UIRuleComponent self)
        {
            await UIHelper.Remove(self.ClientScene(),UIType.UIRule);
        }
    }
}