StudioFilingNpcView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using ET;
  2. using FairyGUI;
  3. using UI.Studio;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class StudioFilingNpcView : BaseWindow
  8. {
  9. private UI_StudioFilingNpcUI _ui;
  10. private GComponent _comSelect;
  11. public override void Dispose()
  12. {
  13. if (_comSelect != null)
  14. {
  15. _comSelect.RemoveFromParent();
  16. _comSelect.Dispose();
  17. }
  18. if (_ui != null)
  19. {
  20. _ui.Dispose();
  21. _ui = null;
  22. }
  23. base.Dispose();
  24. }
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. packageName = UI_StudioFilingNpcUI.PACKAGE_NAME;
  29. _ui = UI_StudioFilingNpcUI.Create();
  30. this.viewCom = _ui.target;
  31. isfullScreen = true;
  32. // this.viewCom.Center();
  33. this.modal = true;
  34. viewAnimationType = EnumViewAnimationType.None;
  35. this.clickBlankToClose = false;
  36. _comSelect = new GComponent();
  37. _comSelect = UIPackage.CreateObject(UI_StudioFilingNpcUI.PACKAGE_NAME, "ComNpcItemSelect").asCom;
  38. _comSelect.touchable = false;
  39. _ui.m_list.itemRenderer = RenderListItem;
  40. _ui.m_list.onClickItem.Add(OnListItemClick);
  41. _ui.m_btnback.onClick.Add(this.Hide);
  42. }
  43. protected override void AddEventListener()
  44. {
  45. base.AddEventListener();
  46. }
  47. protected override void OnShown()
  48. {
  49. base.OnShown();
  50. _ui.m_list.numItems = StudioDataManager.Instance.FilingDatas.Count;
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. }
  56. protected override void RemoveEventListener()
  57. {
  58. base.RemoveEventListener();
  59. }
  60. private void RenderListItem(int index, GObject obj)
  61. {
  62. StudioCfg cfg = StudioDataManager.Instance.FilingDatas[index];
  63. UI_ListNpcItem item = UI_ListNpcItem.Proxy(obj);
  64. bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId);
  65. item.m_ComIcon.m_loaIcon.url = ResPathUtil.GetNpcPicFPath(cfg.res);
  66. // item.m_ComIcon.m_loaIcon.width = item.m_ComIcon.m_loaIcon.image.width;
  67. item.m_imgLock.visible = !isPass;
  68. item.m_txtName.text = cfg.name;
  69. item.target.data = cfg;
  70. if (cfg.id == StudioDataManager.Instance.filingChapterId)
  71. {
  72. item.target.AddChild(_comSelect);
  73. }
  74. UI_ListNpcItem.ProxyEnd();
  75. }
  76. private void OnListItemClick(EventContext context)
  77. {
  78. GObject obj = context.data as GObject;
  79. StudioCfg cfg = obj.data as StudioCfg;
  80. bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId);
  81. if (!isPass)
  82. {
  83. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  84. string showId = StoryUtil.GetChapterOrder(storyLevelCfg.chapterId) + "_" + storyLevelCfg.order;
  85. PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}解锁", showId));
  86. return;
  87. }
  88. StudioDataManager.Instance.filingChapterId = cfg.id;
  89. StorageSProxy.ReqSetClientValue(ConstStorageId.STUDIO_FILING_CHAPTERID, cfg.id).Coroutine();
  90. EventAgent.DispatchEvent(ConstMessage.FILLING_CHANGE_CHAPTER);
  91. UI_ListNpcItem item = UI_ListNpcItem.Proxy(obj);
  92. item.target.AddChild(_comSelect);
  93. UI_ListNpcItem.ProxyEnd();
  94. }
  95. }
  96. }