using System;
using DG.Tweening;
using HotScripts.GameLauncher;
using HotScripts.GameScripts.FGui;
using HotScripts.GameScripts.FGui.Scripts;
using HotScripts.GameScripts.FGui.Scripts.Hall;
using JNGame.Runtime;
using SHFrame;
using UnityEngine;
using EventArgs = SHFrame.EventArgs;

namespace HotScripts.GameScripts
{
    public class HotGameMain : MonoBehaviour
    {
        private async void Awake()
        {

            AddListener();
            
            //初始化系统
            await JNetGame.Instance.Init(App.AllSystem());
            
            //初始化成功
            App.EventLauncher.DispatchEvent(HotLauncherEvent.InitSuccess);
            
        }

        private void OnDestroy()
        {
            RemoveListener();
        }


        private void AddListener()
        {
            App.EventLauncher.AddListener(HotLauncherEvent.GoGameMain,OnGoGameMain);
        }

        private void RemoveListener()
        {
            App.EventLauncher.RemoveListener(HotLauncherEvent.GoGameMain,OnGoGameMain);
        }

        private async void OnGoGameMain(EventArgs eventargs)
        {
            Log.Debug($"进入游戏");
            await App.UI.Open<HallUI>(UIID.Hall);
        }
    }
}