StudioFilingNpcView.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 = isPass ? ResPathUtil.GetNpcPicSPath(cfg.res) : ResPathUtil.GetNpcPicSPath(cfg.inRes);
  66. item.m_imgLock.visible = !isPass;
  67. item.m_txtName.text = cfg.name;
  68. item.m_txtName.visible = isPass;
  69. item.m_txtNone.visible = !isPass;
  70. item.target.data = cfg;
  71. if (cfg.id == StudioDataManager.Instance.filingChapterId)
  72. {
  73. item.target.AddChild(_comSelect);
  74. }
  75. RedDotController.Instance.SetComRedDot(item.target, StudioDataManager.Instance.GetFilingRewardState(cfg.id), "", -38, 116);
  76. UI_ListNpcItem.ProxyEnd();
  77. }
  78. private void OnListItemClick(EventContext context)
  79. {
  80. GObject obj = context.data as GObject;
  81. StudioCfg cfg = obj.data as StudioCfg;
  82. bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId);
  83. if (!isPass)
  84. {
  85. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  86. string showId = StoryUtil.GetChapterOrder(storyLevelCfg.chapterId) + "_" + storyLevelCfg.order;
  87. PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}解锁", showId));
  88. return;
  89. }
  90. StudioDataManager.Instance.filingChapterId = cfg.id;
  91. StorageSProxy.ReqSetClientValue(ConstStorageId.STUDIO_FILING_CHAPTERID, cfg.id).Coroutine();
  92. EventAgent.DispatchEvent(ConstMessage.FILLING_CHANGE_CHAPTER);
  93. UI_ListNpcItem item = UI_ListNpcItem.Proxy(obj);
  94. item.target.AddChild(_comSelect);
  95. UI_ListNpcItem.ProxyEnd();
  96. }
  97. }
  98. }