FieldView.cs 3.1 KB

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