StoryFightSingleView.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using FairyGUI;
  2. using UnityEngine;
  3. using UI.Main;
  4. namespace GFGGame
  5. {
  6. public class StoryFightSingleView : BaseView
  7. {
  8. private UI_StoryFightSingleUI _ui;
  9. private GameObject _sceneObject;
  10. private GameObject _scenePrefab;
  11. public override void Dispose()
  12. {
  13. if (_scenePrefab != null)
  14. {
  15. GameObject.Destroy(_scenePrefab);
  16. _scenePrefab = null;
  17. }
  18. base.Dispose();
  19. }
  20. protected override void Init()
  21. {
  22. base.Init();
  23. _ui = UI_StoryFightSingleUI.Create();
  24. viewCom = _ui.target;
  25. isfullScreen = true;
  26. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightSingle"));
  27. }
  28. protected override void OnInit()
  29. {
  30. base.OnInit();
  31. }
  32. protected override void OnShown()
  33. {
  34. base.OnShown();
  35. if (_sceneObject == null)
  36. {
  37. _sceneObject = GameObject.Instantiate(_scenePrefab);
  38. }
  39. SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);
  40. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  41. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  42. if (!string.IsNullOrEmpty(fightCfg.music))
  43. {
  44. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(fightCfg.music, "mp3"));
  45. }
  46. _ui.m_roleName.m_txtName.text = RoleDataManager.roleName;
  47. Timers.inst.Add(0.9f, 1, (object param) =>
  48. {
  49. this.Hide();
  50. ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_SCORE_VIEW);
  51. });
  52. }
  53. protected override void OnHide()
  54. {
  55. base.OnHide();
  56. if (_sceneObject != null)
  57. {
  58. GameObject.Destroy(_sceneObject);
  59. _sceneObject = null;
  60. }
  61. }
  62. }
  63. }