StudioFilingNpcView.cs 3.9 KB

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