StoryFightSingleView.cs 2.2 KB

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