StudioPropertyView.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.Studio;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class StudioPropertyView : StudioBaseView
  8. {
  9. //private GList _listProperty;
  10. private GLoader _bg0;
  11. private GLoader _btnChageLine;
  12. private Controller _croProperty;
  13. private int _propertySelectIndex = 0;
  14. private int firstOpenProperty = -1;//第一个开放的副本(打开界面时,如未选择副本,则默认选中第一个开启的副本)
  15. //书画副本
  16. public override void Dispose()
  17. {
  18. base.Dispose();
  19. }
  20. protected override void OnInit()
  21. {
  22. base.OnInit();
  23. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  24. // _ui.m_listProperty.itemRenderer = ListPropertyItemRender;
  25. // _ui.m_listProperty.onClickItem.Add(OnClickListProperty);
  26. //com = UIPackage.CreateObject(UI_StudioUI.PACKAGE_NAME, "ComProperty").asCom;
  27. //AddChildCom(com, false);
  28. //list.itemRenderer = ListItemRender;
  29. }
  30. protected override void OnShown()
  31. {
  32. GComponent com = UIPackage.CreateObject(UI_StudioUI.PACKAGE_NAME, "ComProperty").asCom;
  33. AddChildCom(com);
  34. _croProperty = com.GetController("c1");
  35. _bg0 = com.GetChild("loaBg").asLoader;
  36. _btnChageLine = com.GetChild("btnChageLine").asLoader;
  37. list.itemRenderer = ListItemRender;
  38. _croProperty.onChanged.Add(OnControllerChange);
  39. _bg0.url = ResPathUtil.GetBgImgPath("bg_fhl");
  40. //_bg1.url = "ui://Studio/lm_db_chang_2";
  41. _btnChageLine.url = ResPathUtil.GetCommonGameResPath("zsx_fl");
  42. _propertySelectIndex = this.viewData == null ? 0 : (int)this.viewData;
  43. StudioDataManager.Instance.VIEW_NAME = typeof(StudioPropertyView).FullName;
  44. List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  45. firstOpenProperty = -1;
  46. for (int i = 0; i < studioCfgs.Count; i++)
  47. {
  48. GButton btn = com.GetChild("btn" + i).asButton;
  49. bool isOpen = TimeUtil.CheckDayOfWeek(studioCfgs[i].timeArr) ? true : false;
  50. btn.GetChild("icon").visible = isOpen;
  51. if (firstOpenProperty < 0 && isOpen) firstOpenProperty = i;
  52. }
  53. _propertySelectIndex = TimeUtil.CheckDayOfWeek(studioCfgs[_propertySelectIndex].timeArr) ? _propertySelectIndex : firstOpenProperty;
  54. _croProperty.selectedIndex = _propertySelectIndex;
  55. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _propertySelectIndex;
  56. this._studioCfg = studioCfgs[_propertySelectIndex];
  57. this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this._studioCfg.type, this._studioCfg.subType, this._studioCfg.id);
  58. list.numItems = this.storyLevelCfgs.Count;
  59. list.ScrollToView(curIndex);
  60. Timers.inst.AddUpdate(CheckGuide);
  61. base.OnShown();
  62. com.height = _ui.target.height;
  63. _ui.m_loaBg.visible = false;
  64. }
  65. protected override void OnHide()
  66. {
  67. base.OnHide();
  68. Timers.inst.Remove(CheckGuide);
  69. }
  70. private void OnClickBtnBack()
  71. {
  72. ViewManager.GoBackFrom(typeof(StudioPropertyView).FullName);
  73. }
  74. private void OnControllerChange()
  75. {
  76. // int index = _croProperty.selectedIndex;
  77. List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  78. StudioCfg studioCfg = studioCfgs[_croProperty.selectedIndex];
  79. if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  80. {
  81. string str = "";
  82. for (int i = 0; i < studioCfg.timeArr.Length; i++)
  83. {
  84. str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]);
  85. if (i == studioCfg.timeArr.Length - 1) break;
  86. str += "、";
  87. }
  88. PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str));
  89. _croProperty.selectedIndex = _croProperty.previsousIndex;
  90. return;
  91. }
  92. // _propertySelectIndex = index;
  93. this._studioCfg = studioCfg;
  94. this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this._studioCfg.type, this._studioCfg.subType, this._studioCfg.id);
  95. list.numItems = this.storyLevelCfgs.Count;
  96. list.ScrollToView(curIndex);
  97. UpdateView();
  98. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _croProperty.selectedIndex;
  99. }
  100. private void CheckGuide(object param)
  101. {
  102. if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_PROPERTY) <= 0)
  103. {
  104. UpdateToCheckGuide(null);
  105. }
  106. else
  107. {
  108. Timers.inst.Remove(CheckGuide);
  109. }
  110. }
  111. protected override void UpdateToCheckGuide(object param)
  112. {
  113. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  114. GuideController.TryGuide(list, ConstGuideId.STUDIO_PROPERTY, 4, "通关这个副本可以获得风系词牌的升星材料哦~", 0);
  115. GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.STUDIO_PROPERTY, 6, "挑战成功啦,让我们继续新旅程~");
  116. //GuideController.TryCompleteGuide(ConstGuideId.STUDIO_PROPERTY, 6);
  117. }
  118. protected override void TryCompleteGuide()
  119. {
  120. base.TryCompleteGuide();
  121. // GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.STUDIO_PROPERTY);
  122. //GuideController.TryCompleteGuideIndex(ConstGuideId.STUDIO_PROPERTY, 6);
  123. //GuideController.TryCompleteGuide(ConstGuideId.STUDIO_PROPERTY, 6);
  124. }
  125. protected override void ListItemRender(int index, GObject obj)
  126. {
  127. UI_PropertyItem item = UI_PropertyItem.Proxy(obj);
  128. StudioDataManager.Instance.IsCanFight(storyLevelCfgs, index, out bool canFight, out string content);
  129. ItemData itemData = StoryBonusDataCache.GetBonusData(storyLevelCfgs[index].id).bonusBase[0];
  130. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  131. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  132. item.m_star.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(storyLevelCfgs[index].id);
  133. item.m_imgLock.visible = canFight ? false : true;
  134. item.m_lock.visible = canFight ? false : true;
  135. item.m_txtTitle.text = canFight ? storyLevelCfgs[index].name : content;
  136. if (canFight) curIndex = index;
  137. if (item.m_loaIcon.data == null)
  138. {
  139. item.m_loaIcon.onClick.Add(OnLoaItemClick);
  140. }
  141. item.m_loaIcon.data = index;
  142. if (item.m_loaBg.data == null)
  143. {
  144. item.m_loaBg.onClick.Add(OnCliclListItem);
  145. }
  146. item.m_loaBg.data = index;
  147. UI_PropertyItem.ProxyEnd();
  148. }
  149. }
  150. }