StudioFilingNpcView.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. this.viewCom.Center();
  32. this.modal = true;
  33. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  34. _comSelect = new GComponent();
  35. _comSelect = UIPackage.CreateObject(UI_StudioFilingNpcUI.PACKAGE_NAME, "ComNpcItemSelect").asCom;
  36. _comSelect.touchable = false;
  37. _ui.m_list.itemRenderer = RenderListItem;
  38. _ui.m_list.onClickItem.Add(OnListItemClick);
  39. }
  40. protected override void AddEventListener()
  41. {
  42. base.AddEventListener();
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. _ui.m_list.numItems = FilingCfgArray.Instance.dataArray.Length;
  48. }
  49. protected override void OnHide()
  50. {
  51. base.OnHide();
  52. }
  53. protected override void RemoveEventListener()
  54. {
  55. base.RemoveEventListener();
  56. }
  57. private void RenderListItem(int index, GObject obj)
  58. {
  59. FilingCfg cfg = FilingCfgArray.Instance.dataArray[index];
  60. UI_ListNpcItem item = UI_ListNpcItem.Proxy(obj);
  61. bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId);
  62. string res = isPass ? cfg.res : cfg.res1;
  63. item.m_loaIcon.url = ResPathUtil.GetNpcPicSPath(res);
  64. item.m_txtName.text = cfg.name;
  65. item.target.data = cfg;
  66. if (cfg.id == StudioDataManager.Instance.filingChapterId)
  67. {
  68. item.target.AddChild(_comSelect);
  69. }
  70. UI_ListNpcItem.ProxyEnd();
  71. }
  72. private void OnListItemClick(EventContext context)
  73. {
  74. GObject obj = context.data as GObject;
  75. FilingCfg cfg = obj.data as FilingCfg;
  76. bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId);
  77. if (!isPass)
  78. {
  79. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  80. string showId = StoryUtil.GetChapterOrder(storyLevelCfg.chapterId) + "_" + storyLevelCfg.order;
  81. PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}解锁", showId));
  82. return;
  83. }
  84. StudioDataManager.Instance.filingChapterId = cfg.id;
  85. StorageSProxy.ReqSetClientValue(ConstStorageId.STUDIO_FILING_CHAPTERID, cfg.id).Coroutine();
  86. EventAgent.DispatchEvent(ConstMessage.FILLING_CHANGE_CHAPTER);
  87. UI_ListNpcItem item = UI_ListNpcItem.Proxy(obj);
  88. item.target.AddChild(_comSelect);
  89. UI_ListNpcItem.ProxyEnd();
  90. }
  91. }
  92. }