StudioBaseView.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Studio;
  5. namespace GFGGame
  6. {
  7. public class StudioBaseView : BaseWindow
  8. {
  9. protected UI_StudioEctypeUI _ui;
  10. private ValueBarController _valueBarController;
  11. protected StudioCfg studioCfg;
  12. protected List<StoryLevelCfg> storyLevelCfgs;
  13. public override void Dispose()
  14. {
  15. base.Dispose();
  16. }
  17. protected override void OnInit()
  18. {
  19. base.OnInit();
  20. packageName = UI_StudioEctypeUI.PACKAGE_NAME;
  21. _ui = UI_StudioEctypeUI.Create();
  22. this.viewCom = _ui.target;
  23. isfullScreen = true;
  24. _valueBarController = new ValueBarController(_ui.m_valueBar);
  25. _ui.m_list.itemRenderer = ListItemRender;
  26. _ui.m_list.onClickItem.Add(OnCliclListItem);
  27. _ui.m_list.SetVirtual();
  28. _ui.m_btnBuy.onClick.Add(OnCliclBtnBuy);
  29. }
  30. protected override void OnShown()
  31. {
  32. base.OnShown();
  33. _valueBarController.OnShown();
  34. UpdateView();
  35. }
  36. protected override void OnHide()
  37. {
  38. base.OnHide();
  39. _valueBarController.OnHide();
  40. studioCfg = null;
  41. storyLevelCfgs = null;
  42. Timers.inst.Remove(UpdateShowTime);
  43. }
  44. private void UpdateView()
  45. {
  46. _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", 1, this.studioCfg.num);
  47. Timers.inst.Add(1, 0, UpdateShowTime);
  48. }
  49. private void UpdateShowTime(object param)
  50. {
  51. _ui.m_txtTime.text = string.Format("{0}后刷新", TimeUtil.FormattingTime(TimeHelper.ServerNowSecs, GameGlobal.myNumericComponent.GetAsInt(NumericType.DailyResetSecs)));
  52. }
  53. private void ListItemRender(int index, GObject obj)
  54. {
  55. UI_ListItem item = UI_ListItem.Proxy(obj);
  56. // item.m_loaIcon.url=
  57. bool isPass = StoryDataManager.CheckLevelPass(storyLevelCfgs[index].chapterId, storyLevelCfgs[index].level);
  58. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfgs[index].roleLv;
  59. item.m_grpLock.visible = !isPass || !isRoleLv;
  60. string title = string.Format("{0}{1}", studioCfg.name, index + 1);
  61. if (!isPass) title = string.Format("完成主线{0}-{1}解锁", storyLevelCfgs[index].chapterId, storyLevelCfgs[index].level);
  62. if (!isRoleLv) title = string.Format("主角等级达到{}级解锁", storyLevelCfgs[index].level);
  63. item.m_txtTitle.text = title;
  64. item.target.data = storyLevelCfgs[index];
  65. }
  66. private void OnCliclListItem(EventContext context)
  67. {
  68. UI_ListItem item = UI_ListItem.Proxy(context.data as GObject);
  69. StoryLevelCfg storyLevelCfgs = item.target.data as StoryLevelCfg;
  70. }
  71. private void OnCliclBtnBuy()
  72. {
  73. ViewManager.Show<StudioBuyNumView>(this.studioCfg);
  74. }
  75. }
  76. }