StudioPropertyView.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 int _propertySelectIndex = 0;
  10. private int _typeSelectIndex = 0;
  11. private int firstOpenProperty = -1;//第一个开放的副本(打开界面时,如未选择副本,则默认选中第一个开启的副本)
  12. //书画副本
  13. public override void Dispose()
  14. {
  15. base.Dispose();
  16. }
  17. protected override void OnInit()
  18. {
  19. base.OnInit();
  20. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  21. _ui.m_listProperty.itemRenderer = ListPropertyItemRender;
  22. _ui.m_listProperty.onClickItem.Add(OnClickListProperty);
  23. }
  24. protected override void OnShown()
  25. {
  26. firstOpenProperty = -1;
  27. _typeSelectIndex = (int)(this.viewData as object[])[0];
  28. _propertySelectIndex = (int)(this.viewData as object[])[1];
  29. _ui.m_c1.selectedIndex = _typeSelectIndex;
  30. StudioDataManager.Instance.VIEW_NAME = typeof(StudioPropertyView).Name;
  31. StudioCfg[] studioCfgs = StudioCfgArray.Instance.GetCfgs(typeof(StudioPropertyView).Name);
  32. _ui.m_listProperty.numItems = studioCfgs.Length;
  33. _propertySelectIndex = TimeUtil.CheckDayOfWeek(studioCfgs[_propertySelectIndex].timeArr) ? _propertySelectIndex : firstOpenProperty;
  34. _ui.m_listProperty.selectedIndex = _propertySelectIndex;
  35. this.studioCfg = studioCfgs[_ui.m_listProperty.selectedIndex];
  36. this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
  37. this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgs(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
  38. _ui.m_list.numItems = this.storyLevelCfgs.Length;
  39. _ui.m_list.ScrollToView(curIndex);
  40. base.OnShown();
  41. }
  42. protected override void OnHide()
  43. {
  44. base.OnHide();
  45. }
  46. private void OnClickBtnBack()
  47. {
  48. ViewManager.GoBackFrom(typeof(StudioPropertyView).FullName);
  49. }
  50. private void ListPropertyItemRender(int index, GObject obj)
  51. {
  52. StudioCfg[] studioCfgs = StudioCfgArray.Instance.GetCfgs(typeof(StudioPropertyView).Name);
  53. GButton item = obj.asButton;
  54. item.GetChild("icon0").asLoader.url = string.Format("ui://Studio/gzsltb_{0}", index + 1);
  55. item.GetChild("icon1").asLoader.url = string.Format("ui://Studio/gzsatb_{0}", index + 1);
  56. item.GetChild("icon2").asLoader.url = string.Format("ui://Studio/gzswtb_{0}", index + 1);
  57. item.GetChild("icon2").asLoader.visible = TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr) ? false : true;
  58. if (firstOpenProperty < 0 && TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr)) firstOpenProperty = index;
  59. item.data = index;
  60. }
  61. private void OnClickListProperty(EventContext context)
  62. {
  63. GButton item = (context.data as GObject).asButton;
  64. int index = (int)item.data;
  65. StudioCfg[] studioCfgs = StudioCfgArray.Instance.GetCfgs(typeof(StudioPropertyView).Name);
  66. StudioCfg studioCfg = studioCfgs[index];
  67. if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  68. {
  69. _ui.m_listProperty.selectedIndex = _propertySelectIndex;
  70. string str = "";
  71. for (int i = 0; i < studioCfg.timeArr.Length; i++)
  72. {
  73. str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]);
  74. if (i == studioCfg.timeArr.Length - 1) break;
  75. str += "、";
  76. }
  77. PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str));
  78. return;
  79. }
  80. _propertySelectIndex = index;
  81. this.studioCfg = studioCfg;
  82. this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
  83. this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgs(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
  84. _ui.m_list.numItems = this.storyLevelCfgs.Length;
  85. _ui.m_list.ScrollToView(curIndex);
  86. UpdateView();
  87. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _ui.m_listProperty.selectedIndex;
  88. }
  89. }
  90. }