FieldView.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. FieldDataManager.Instance.difficulty = _ui.m_c1.selectedIndex;
  31. _curCfg = FieldDataManager.Instance.GetFieldCfgByDifficulty(_ui.m_c1.selectedIndex);
  32. _curLevelId = FieldDataManager.Instance.GetLevelIdByDifficulty(_ui.m_c1.selectedIndex);
  33. UpdateView();
  34. _ui.m_proTaskReward.max = 100;
  35. _ui.m_proTaskReward.value = 88;
  36. }
  37. protected override void OnHide()
  38. {
  39. base.OnHide();
  40. }
  41. private void OnClickBtnBack()
  42. {
  43. ViewManager.GoBackFrom(typeof(FieldView).FullName);
  44. }
  45. private void OnDifficultyChange()
  46. {
  47. FieldDataManager.Instance.difficulty = _ui.m_c1.selectedIndex;
  48. _curCfg = FieldDataManager.Instance.GetFieldCfgByDifficulty(_ui.m_c1.selectedIndex);
  49. _curLevelId = FieldDataManager.Instance.GetLevelIdByDifficulty(_ui.m_c1.selectedIndex);
  50. UpdateView();
  51. }
  52. private void UpdateView()
  53. {
  54. _ui.m_txtScore.text = ConstDressUpScoreType.scoreTypeList()[FieldDataManager.Instance.scoreType].ToString();
  55. _ui.m_txtMaxLv.text = string.Format("最高记录:{0}/{1}", 0, _curCfg.num);
  56. _ui.m_txtConsume.text = string.Format("x{0}", _curCfg.needPower);
  57. }
  58. private void OnClickBtnGo()
  59. {
  60. // ViewManager.Show<FieldFightInfoView>();
  61. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Power) < _curCfg.needPower)
  62. {
  63. PromptController.Instance.ShowFloatTextPrompt("体力不足");
  64. return;
  65. }
  66. ViewManager.Show(ViewName.DRESS_UP_FIGHT_VIEW, _curLevelId, new object[] { typeof(FieldView).Name, this.viewData }, true);
  67. InstanceZonesDataManager.currentLevelCfgId = _curLevelId;
  68. }
  69. private void OnBtnTaskClick()
  70. {
  71. ViewManager.Show<FieldTaskView>();
  72. }
  73. }
  74. }