StoryFightTargetView.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using FairyGUI;
  2. using UnityEngine;
  3. using UI.Main;
  4. namespace GFGGame
  5. {
  6. public class StoryFightTargetView : BaseView
  7. {
  8. private UI_StoryFightTargetUI _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("SceneFightTarget"));
  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_StoryFightTargetUI.Create();
  34. viewCom = _ui.target;
  35. isfullScreen = true;
  36. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightTarget"));
  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, true);
  50. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  51. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  52. SceneController.UpdateFightTarget(fightCfg.targetRes, _sceneObject);
  53. if (!string.IsNullOrEmpty(fightCfg.music))
  54. {
  55. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(fightCfg.music, "mp3"));
  56. }
  57. _ui.m_roleName.m_txtName.text = RoleDataManager.roleName;
  58. _ui.m_targetName.m_txtName.text = fightCfg.targetName;
  59. Timers.inst.Add(1.1f, 1, (object param) =>
  60. {
  61. this.Hide();
  62. ViewManager.Show(ViewName.STORY_FIGHT_TARGET_SCORE_VIEW);
  63. });
  64. }
  65. protected override void OnHide()
  66. {
  67. base.OnHide();
  68. if (_sceneObject != null)
  69. {
  70. GameObject.Destroy(_sceneObject);
  71. _sceneObject = null;
  72. }
  73. }
  74. }
  75. }