StoryFightTargetView.cs 2.2 KB

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