Entrance_YLBattle.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5. using YLBattle;
  6. using UnityEngine.SceneManagement;
  7. /// <summary>
  8. ///
  9. /// </summary>
  10. public class Entrance_YLBattle : MonoBehaviour
  11. {
  12. /// <summary>
  13. /// 预加载资源
  14. /// </summary>
  15. private List<string> mPreloadRes = new List<string>();
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. void Start()
  20. {
  21. AudioManager.Instance.ChangeGameBackMusic(AudioManager.BattleBackMusic, 3);
  22. // 清除所有角色
  23. RoleManager.Instance.ClearRoleRes();
  24. // 战斗界面
  25. PanelHelper.Instance.ShowPanel("UI_BaseMainWindow", (uiObj) =>
  26. {
  27. GameObject spawnerObj = null;
  28. sm_gate gateMo = sm_gate.GetMoById(GameDateManager.Instance.GateID);
  29. GameObject[] gos = SceneManager.GetActiveScene().GetRootGameObjects();
  30. string spawnerName = "";
  31. if (int.Parse(gateMo.battleType) == (int)BattleDefine.EBattleSceneType.EBattleType_Duplicate)
  32. {
  33. spawnerName = "Spawners_" + GameDateManager.Instance.GateID.ToString();
  34. }
  35. else
  36. {
  37. spawnerName = "Spawners";
  38. }
  39. foreach (var item in gos)
  40. {
  41. if (item.gameObject.name == spawnerName)
  42. {
  43. spawnerObj = item;
  44. spawnerObj.SetActive(true);
  45. break;
  46. }
  47. }
  48. ZoneSpawner[] szList = spawnerObj.GetComponentsInChildren<YLBattle.ZoneSpawner>();
  49. foreach (var item in szList)
  50. {
  51. item.gameObject.AddComponent<YLBattle.ZoneSpawnerLogic>();
  52. }
  53. BulletMessage.catSkillFun = X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkillDelegateFun;
  54. Invoke("EnterYLBattle", 0.25f);
  55. });
  56. }
  57. /// <summary>
  58. /// 预加载资源
  59. /// </summary>
  60. /// <param name="index"></param>
  61. private void PreloadRes(int index, Action ac)
  62. {
  63. if (index >= 0 && index < mPreloadRes.Count)
  64. {
  65. ResourceHelper.Instance.LoadAssetBundle(mPreloadRes[index], (ab) =>
  66. {
  67. PreloadRes(index + 1, ac);
  68. });
  69. }
  70. else
  71. {
  72. if (ac != null)
  73. {
  74. ac();
  75. }
  76. }
  77. }
  78. private void EnterYLBattle()
  79. {
  80. GameObject cmameraManager = GameObject.Find("CMCamera");
  81. if (cmameraManager)
  82. {
  83. cmameraManager.AddComponent<CMCameraManager>();
  84. }
  85. UI_LoadingWindow.Instance().Hide();
  86. PanelHelper.Instance.ClosePanel("UI_LoadingWindow");
  87. GameBattleManager.Instance().Go();
  88. // 弹出剧情
  89. StarBattle.BattleInfo info = BattleMediator.Instance.getBattleInfo();
  90. if (info != null && sm_plot.CheckHasGateDialog(info.BP.levelID))
  91. {
  92. DialogDataInfo dataInfo = new DialogDataInfo();
  93. dataInfo.sceneType = 1;
  94. dataInfo.gateId = info.BP.levelID;
  95. dataInfo.stageIndex = 0;
  96. dataInfo.param = info.BP.levelID + "_" + info.BP.levelID + "_" + 0;
  97. dataInfo.noviceIndex = 0;
  98. dataInfo.closeAC = null;
  99. PanelHelper.Instance.ShowPanel("UI_TaskDialogWindow", null, dataInfo);
  100. return;
  101. }
  102. }
  103. private void Update()
  104. {
  105. X2Battle.X2BattleManager.Instance.Update();
  106. }
  107. }