TaskView.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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("lm_beijing2");
  33. _ui.m_c1.onChanged.Add(OnCtrlChange);
  34. BattlePassTaskSProxy.GetBattlePassInfo().Coroutine();
  35. }
  36. private void OnBtnBackClick()
  37. {
  38. ViewManager.Hide<CombTaskView>();
  39. ViewManager.Hide<BattlePassTaskView>();
  40. ViewManager.GoBackFrom(typeof(TaskView).FullName);
  41. }
  42. protected override void OnShown()
  43. {
  44. base.OnShown();
  45. _valueBarController.OnShown();
  46. _ui.m_c1.selectedIndex = viewData == null ? 1 : (int)(viewData as object[])?[0]!;
  47. }
  48. protected override void OnHide()
  49. {
  50. base.OnHide();
  51. _valueBarController.OnHide();
  52. _ui.m_c1.selectedIndex = 0;
  53. }
  54. private void OnCtrlChange()
  55. {
  56. switch (_ui.m_c1.selectedIndex)
  57. {
  58. case 1:
  59. ViewManager.Show<CombTaskView>();
  60. ViewManager.Hide<BattlePassTaskView>();
  61. break;
  62. case 2:
  63. ViewManager.Show<BattlePassTaskView>();
  64. ViewManager.Hide<CombTaskView>();
  65. break;
  66. }
  67. viewData = null;
  68. }
  69. }
  70. }