StoryFightTargetView.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 (_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_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. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, true);
  45. MyDressUpHelper.dressUpObj.UpdateRoleView();
  46. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  47. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  48. SceneController.UpdateFightTarget(fightCfg.targetRes, _sceneObject);
  49. if (!string.IsNullOrEmpty(fightCfg.music))
  50. {
  51. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(fightCfg.music, "mp3"));
  52. }
  53. _ui.m_roleName.m_txtName.text = RoleDataManager.roleName;
  54. _ui.m_targetName.m_txtName.text = fightCfg.targetName;
  55. Timers.inst.Add(1.1f, 1, (object param) =>
  56. {
  57. this.Hide();
  58. ViewManager.Show(ViewName.STORY_FIGHT_TARGET_SCORE_VIEW);
  59. });
  60. }
  61. protected override void OnHide()
  62. {
  63. base.OnHide();
  64. if (_sceneObject != null)
  65. {
  66. GameObject.Destroy(_sceneObject);
  67. _sceneObject = null;
  68. }
  69. }
  70. }
  71. }