StudioFilingNpcView.cs 4.1 KB

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