StoryFightSingleView.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. NTexture nTexture = this.viewData as NTexture;
  41. if (_sceneObject == null)
  42. {
  43. _sceneObject = GameObject.Instantiate(_scenePrefab);
  44. }
  45. SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);
  46. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  47. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  48. if (!string.IsNullOrEmpty(fightCfg.music))
  49. {
  50. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(fightCfg.music, "mp3"));
  51. }
  52. _ui.m_roleName.m_txtName.text = RoleDataManager.roleName;
  53. Timers.inst.Add(0.9f, 1, (object param) =>
  54. {
  55. this.Hide();
  56. ViewManager.Show(ViewName.STORY_FIGHT_SINGLE_SCORE_VIEW, nTexture);
  57. });
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. if (_sceneObject != null)
  63. {
  64. GameObject.Destroy(_sceneObject);
  65. _sceneObject = null;
  66. }
  67. }
  68. }
  69. }