StudioFilingNpcView.cs 4.1 KB

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