TaskView.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using UI.Task;
  2. namespace GFGGame
  3. {
  4. public class TaskView : BaseWindow
  5. {
  6. private UI_TaskUI _ui;
  7. private ValueBarController _valueBarController;
  8. public override void Dispose()
  9. {
  10. if (_valueBarController != null)
  11. {
  12. _valueBarController.Dispose();
  13. _valueBarController = null;
  14. }
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_TaskUI.PACKAGE_NAME;
  26. _ui = UI_TaskUI.Create();
  27. viewCom = _ui.target;
  28. isfullScreen = true;
  29. bringToFontOnClick = false;
  30. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  31. _valueBarController = new ValueBarController(_ui.m_comValueBar);
  32. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_txz");
  33. _ui.m_c1.onChanged.Add(OnCtrlChange);
  34. }
  35. private void OnBtnBackClick()
  36. {
  37. ViewManager.Hide<CombTaskView>();
  38. ViewManager.Hide<BattlePassTaskView>();
  39. ViewManager.GoBackFrom(typeof(TaskView).FullName);
  40. }
  41. protected override void OnShown()
  42. {
  43. base.OnShown();
  44. _valueBarController.OnShown();
  45. _ui.m_c1.selectedIndex = viewData == null ? 1 : (int)(viewData as object[])?[0]!;
  46. }
  47. protected override void OnHide()
  48. {
  49. base.OnHide();
  50. _valueBarController.OnHide();
  51. _ui.m_c1.selectedIndex = 0;
  52. }
  53. private void OnCtrlChange()
  54. {
  55. switch (_ui.m_c1.selectedIndex)
  56. {
  57. case 1:
  58. ViewManager.Show<CombTaskView>();
  59. ViewManager.Hide<BattlePassTaskView>();
  60. break;
  61. case 2:
  62. ViewManager.Show<BattlePassTaskView>();
  63. ViewManager.Hide<CombTaskView>();
  64. break;
  65. }
  66. viewData = null;
  67. }
  68. }
  69. }