FieldView.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using ET;
  2. using UI.Field;
  3. using UnityEngine;
  4. namespace GFGGame
  5. {
  6. public class FieldView : BaseWindow
  7. {
  8. private UI_FieldUI _ui;
  9. private FieldCfg _curCfg;
  10. private int _curLevelId;
  11. public override void Dispose()
  12. {
  13. base.Dispose();
  14. }
  15. protected override void OnInit()
  16. {
  17. base.OnInit();
  18. packageName = UI_FieldUI.PACKAGE_NAME;
  19. _ui = UI_FieldUI.Create();
  20. this.viewCom = _ui.target;
  21. isfullScreen = true;
  22. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  23. _ui.m_btnGo.onClick.Add(OnClickBtnGo);
  24. _ui.m_btnTask.onClick.Add(OnBtnTaskClick);
  25. _ui.m_c1.onChanged.Add(OnDifficultyChange);
  26. }
  27. protected override void OnShown()
  28. {
  29. base.OnShown();
  30. _curCfg = FieldDataManager.Instance.GetFieldCfgByDifficulty(_ui.m_c1.selectedIndex);
  31. _curLevelId = FieldDataManager.Instance.GetLevelIdByDifficulty(_ui.m_c1.selectedIndex);
  32. }
  33. protected override void OnHide()
  34. {
  35. base.OnHide();
  36. }
  37. private void OnClickBtnBack()
  38. {
  39. ViewManager.GoBackFrom(typeof(FieldView).FullName);
  40. }
  41. private void OnDifficultyChange()
  42. {
  43. _curCfg = FieldDataManager.Instance.GetFieldCfgByDifficulty(_ui.m_c1.selectedIndex);
  44. _curLevelId = FieldDataManager.Instance.GetLevelIdByDifficulty(_ui.m_c1.selectedIndex);
  45. }
  46. private void OnClickBtnGo()
  47. {
  48. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Power) < _curCfg.needPower)
  49. {
  50. PromptController.Instance.ShowFloatTextPrompt("体力不足");
  51. return;
  52. }
  53. ViewManager.Show(ViewName.DRESS_UP_FIGHT_VIEW, _curLevelId, new object[] { typeof(FieldView).Name, this.viewData }, true);
  54. InstanceZonesDataManager.currentLevelCfgId = _curLevelId;
  55. }
  56. private void OnBtnTaskClick()
  57. {
  58. ViewManager.Show<FieldTaskView>();
  59. }
  60. }
  61. }