StoryFightTargetView.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. base.Dispose();
  24. }
  25. protected override void Init()
  26. {
  27. base.Init();
  28. _ui = UI_StoryFightTargetUI.Create();
  29. viewCom = _ui.target;
  30. isfullScreen = true;
  31. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightTarget"));
  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. SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject, true);
  45. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  46. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  47. SceneController.UpdateFightTarget(fightCfg.targetRes, _sceneObject);
  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. _ui.m_targetName.m_txtName.text = fightCfg.targetName;
  54. Timers.inst.Add(1.1f, 1, (object param) =>
  55. {
  56. this.Hide();
  57. ViewManager.Show(ViewName.STORY_FIGHT_TARGET_SCORE_VIEW);
  58. });
  59. }
  60. protected override void OnHide()
  61. {
  62. base.OnHide();
  63. if (_sceneObject != null)
  64. {
  65. GameObject.Destroy(_sceneObject);
  66. _sceneObject = null;
  67. }
  68. }
  69. }
  70. }