StoryFightSingleView.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 (_sceneObject != null)
  14. {
  15. GameObject.Destroy(_sceneObject);
  16. _sceneObject = null;
  17. }
  18. if (_scenePrefab != null)
  19. {
  20. GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneFightSingle"));
  21. _scenePrefab = null;
  22. }
  23. if (_ui != null)
  24. {
  25. _ui.Dispose();
  26. _ui = null;
  27. }
  28. base.Dispose();
  29. }
  30. protected override void Init()
  31. {
  32. base.Init();
  33. _ui = UI_StoryFightSingleUI.Create();
  34. viewCom = _ui.target;
  35. isfullScreen = true;
  36. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightSingle"));
  37. }
  38. protected override void OnInit()
  39. {
  40. base.OnInit();
  41. }
  42. protected override void OnShown()
  43. {
  44. base.OnShown();
  45. if (_sceneObject == null)
  46. {
  47. _sceneObject = GameObject.Instantiate(_scenePrefab);
  48. }
  49. SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);
  50. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  51. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  52. if (!string.IsNullOrEmpty(fightCfg.music))
  53. {
  54. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(fightCfg.music, "mp3"));
  55. }
  56. _ui.m_roleName.m_txtName.text = RoleDataManager.roleName;
  57. Timers.inst.Add(0.9f, 1, (object param) =>
  58. {
  59. this.Hide();
  60. ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_SCORE_VIEW);
  61. });
  62. }
  63. protected override void OnHide()
  64. {
  65. base.OnHide();
  66. if (_sceneObject != null)
  67. {
  68. GameObject.Destroy(_sceneObject);
  69. _sceneObject = null;
  70. }
  71. }
  72. }
  73. }