123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- using Core.AssetLoadTool.Asset;
- using Core.Audio;
- using Core.Language;
- using Fort23.Core;
- using Fort23.Mono;
- using Fort23.Mono.UpdateAsset;
- using Fort23.UTool;
- using GameLogic.Combat;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Combat.CombatType;
- using GameLogic.CombatScenesTool;
- using GameLogic.NetworkClient;
- using GameUI;
- using NetCore.Protocol.MemoryPack;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- using UnityEngine;
- using UnityEngine.UI;
- using Utility.CTween;
- using Utility.UITool;
- public class GameApplction : IGameStart
- {
- public ShaderVariantCollection ShaderVariantCollection;
- public BundleLoadType BundleLoadType;
- public string h5Url;
- private Entity _root;
- private Entity _scene;
- // public bool isTest;
- public int levelBattleId = 1;
- private GameStartUIPanel gameStartUIPanel;
- public async void StartGame(LoadType LoadType, string h5Url, GameStartUIPanel gameStartUIPanel,
- System.Action LoadFinish)
- {
- Debug.Log("开始游戏逻辑");
- // UnityEngine.Screen.SetResolution(Screen.width);
- GameUpdateAsset.Instance.Init(h5Url);
- this.gameStartUIPanel = gameStartUIPanel;
- gameStartUIPanel.ShowMassge("开始加载资源");
- gameStartUIPanel.SetSlider(0);
- this.h5Url = h5Url;
- BundleLoadType = (BundleLoadType)LoadType;
- GameObject gameObject = new GameObject("app");
- gameObject.AddComponent<GameApplctionMono>();
- await InitGameApplication();
- LoadFinish?.Invoke();
- UIManager.Instance.Canvas.gameObject.SetActive(true);
-
- Debug.Log("初始化完成");
- }
- private async CTask InitGameApplication()
- {
- _scene = new Scene();
- _root = new Entity();
- _root.Parent = _scene;
- _root.AddComponent<TimerComponent>();
- _root.AddComponent<CoroutineLockComponent>();
- gameStartUIPanel.ShowMassge("loadBundle");
- gameStartUIPanel.SetSlider(0.15f);
- AssetBundleLoadManager.Instance.BundleLoadType = BundleLoadType;
- AssetBundleLoadManager.Instance.h5Url = h5Url;
- await AssetBundleLoadManager.Instance.InitAssetsManager(null);
- #if !UNITY_EDITOR
- AssetBundleLoadManager.Instance.AddBundleTask("fb010shader", delegate(BundleLoadBasic basic, object o)
- {
- if (basic.currBundle != null)
- {
- basic.currBundle.LoadAllAssets<Shader>();
- Shader.WarmupAllShadersWait();
- }
- }, null);
- #endif
- gameStartUIPanel.ShowMassge("loadConfig");
- gameStartUIPanel.SetSlider(0.25f);
- await ConfigComponent.Instance.Preload();
- await AnimationCurveManager.Instance.Init();
- UGUIPackLoad uguiPackLoad = new UGUIPackLoad();
- UGUIPackManager.Instance.SetIUGUIPackLoad(uguiPackLoad);
- await uguiPackLoad.InitPack();
- gameStartUIPanel.ShowMassge("loadLanguage");
- gameStartUIPanel.SetSlider(0.45f);
- await LanguageManager.Instance.InitManager();
- _root.AddComponent<StaticUpdater>();
- _root.AddComponent<UIManager, Transform>(null);
- gameStartUIPanel.ShowMassge("loadUI");
- gameStartUIPanel.SetSlider(0.55f);
- await AudioManager.Instance.InitMainAudio();
- await UIManager.Instance.InitUI();
- CustomTweenManager.Init();
- // await GameNetworkClient.Instance.Connect("127.0.0.1", 1000);
- await Login();
- }
- private async CTask Login()
- {
- // MemoryResponse memoryResponse = await GameNetworkSendAssemble.SendLogin("123", "123");
- // if (memoryResponse == null)
- // {
- // LogTool.Error("登陆失败");
- // return;
- // }
- PlayerManager.Instance.Init();
- // PlayerManager.Instance.InitTestHero();
- await CombatDrive.Instance.Init();
- StartCombatInfo startCombatInfo = new StartCombatInfo();
- startCombatInfo.CombatType = CombatType.LevelBattle;
- #if UNITY_EDITOR
- TestCombatHeroConfig testCombatHeroConfig = GameObject.FindObjectOfType<TestCombatHeroConfig>();
- if (testCombatHeroConfig != null)
- {
- startCombatInfo.CombatType = CombatType.TestCombat;
- }
- #endif
- startCombatInfo.levelBattleId = AccountFileInfo.Instance.playerData.levelBattle;
- CombatDrive.Instance.AddCombatController(new CombatController());
- gameStartUIPanel.ShowMassge("loadCombat");
- gameStartUIPanel.SetSlider(0.95f);
- await CombatDrive.Instance.StartCombat(startCombatInfo);
- gameStartUIPanel.ShowMassge("loadFinish");
- gameStartUIPanel.SetSlider(1f);
- }
- }
|