123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using YLBattle;
- using UnityEngine.SceneManagement;
- /// <summary>
- ///
- /// </summary>
- public class Entrance_YLBattle : MonoBehaviour
- {
- /// <summary>
- /// 预加载资源
- /// </summary>
- private List<string> mPreloadRes = new List<string>();
- /// <summary>
- ///
- /// </summary>
- void Start()
- {
- AudioManager.Instance.ChangeGameBackMusic(AudioManager.BattleBackMusic, 3);
- // 清除所有角色
- RoleManager.Instance.ClearRoleRes();
- // 战斗界面
- PanelHelper.Instance.ShowPanel("UI_BaseMainWindow", (uiObj) =>
- {
- GameObject spawnerObj = null;
- sm_gate gateMo = sm_gate.GetMoById(GameDateManager.Instance.GateID);
- GameObject[] gos = SceneManager.GetActiveScene().GetRootGameObjects();
- string spawnerName = "";
- if (int.Parse(gateMo.battleType) == (int)BattleDefine.EBattleSceneType.EBattleType_Duplicate)
- {
- spawnerName = "Spawners_" + GameDateManager.Instance.GateID.ToString();
- }
- else
- {
- spawnerName = "Spawners";
- }
- foreach (var item in gos)
- {
- if (item.gameObject.name == spawnerName)
- {
- spawnerObj = item;
- spawnerObj.SetActive(true);
- break;
- }
- }
- ZoneSpawner[] szList = spawnerObj.GetComponentsInChildren<YLBattle.ZoneSpawner>();
- foreach (var item in szList)
- {
- item.gameObject.AddComponent<YLBattle.ZoneSpawnerLogic>();
- }
- BulletMessage.catSkillFun = X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkillDelegateFun;
- Invoke("EnterYLBattle", 0.25f);
- });
- }
- /// <summary>
- /// 预加载资源
- /// </summary>
- /// <param name="index"></param>
- private void PreloadRes(int index, Action ac)
- {
- if (index >= 0 && index < mPreloadRes.Count)
- {
- ResourceHelper.Instance.LoadAssetBundle(mPreloadRes[index], (ab) =>
- {
- PreloadRes(index + 1, ac);
- });
- }
- else
- {
- if (ac != null)
- {
- ac();
- }
- }
- }
- private void EnterYLBattle()
- {
- GameObject cmameraManager = GameObject.Find("CMCamera");
- if (cmameraManager)
- {
- cmameraManager.AddComponent<CMCameraManager>();
- }
- UI_LoadingWindow.Instance().Hide();
- PanelHelper.Instance.ClosePanel("UI_LoadingWindow");
- GameBattleManager.Instance().Go();
- // 弹出剧情
- StarBattle.BattleInfo info = BattleMediator.Instance.getBattleInfo();
- if (info != null && sm_plot.CheckHasGateDialog(info.BP.levelID))
- {
- DialogDataInfo dataInfo = new DialogDataInfo();
- dataInfo.sceneType = 1;
- dataInfo.gateId = info.BP.levelID;
- dataInfo.stageIndex = 0;
- dataInfo.param = info.BP.levelID + "_" + info.BP.levelID + "_" + 0;
- dataInfo.noviceIndex = 0;
- dataInfo.closeAC = null;
- PanelHelper.Instance.ShowPanel("UI_TaskDialogWindow", null, dataInfo);
- return;
- }
- }
- private void Update()
- {
- X2Battle.X2BattleManager.Instance.Update();
- }
- }
|