2025-01-08 17:05:35 +08:00

76 lines
2.0 KiB
C#

using FlappyBird;
using QAssetBundle;
using QFramework;
using QFramework.Example;
using System.Collections;
using UnityEngine;
using XMLTool;
public class Launch : MonoBehaviour
{
ResLoader loader;
private void Awake()
{
loader = ResLoader.Allocate();
StartCoroutine(StartApp());
}
IEnumerator StartApp()
{
yield return ResKit.InitAsync();
bool isLoadFinished = false;
loader.Add2Load(Global.appXmlPath.ToLocalTextResName(), (success, res) =>
{
if (success)
{
Global.Instance.appData = XmlParser.ParseXml(res.As<LocalTextRes>().text);
}
});
loader.LoadAsync(() =>
{
isLoadFinished = true;
ActionKit.Delay(2f, () =>
{
loader.Recycle2Cache();
loader = null;
});
});
yield return UIKit.OpenPanelAsync<UILoading>();
yield return new WaitUntil(() => isLoadFinished == true);
if (Global.Instance.appData.preLoad != null && Global.Instance.appData.preLoad.action != null)
{
yield return ActionHelper.GetActionAndSub(Global.Instance.appData.preLoad.action).Start(this);
}
// 暂时放在这里
if (Global.moduleDict.Count > 0)
{
for (int i = 0; i < Global.moduleDict.Count; i++)
{
string index = (i + 1).ToString();
if (Global.moduleDict.ContainsKey(index))
{
XmlParser.LoadModule(Global.moduleDict[index], Global.Instance.appData);
}
}
}
yield return UIKit.OpenPanelAsync<UIModeSelect>();
UIKit.HidePanel<UILoading>();
// 暂时不用
//foreach (var item in Global.Instance.appData.ActionDict)
//{
// var act = ActionHelper.GetAction(item.Value);
// act.Start(this, () => Debug.LogError("完成。。。"));
//}
}
}