TravelView.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using ET;
  2. using FairyGUI;
  3. using UI.Travel;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class TravelView : BaseWindow
  8. {
  9. private UI_TravelUI _ui;
  10. private ValueBarController _valueBarController;
  11. public override void Dispose()
  12. {
  13. if (_valueBarController != null)
  14. {
  15. _valueBarController.Dispose();
  16. _valueBarController = null;
  17. }
  18. if (_ui != null)
  19. {
  20. _ui.Dispose();
  21. _ui = null;
  22. }
  23. base.Dispose();
  24. }
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. packageName = UI_TravelUI.PACKAGE_NAME;
  29. _ui = UI_TravelUI.Create();
  30. this.viewCom = _ui.target;
  31. isfullScreen = true;
  32. _valueBarController = new ValueBarController(_ui.m_comValueBar);
  33. _ui.m_btnback.onClick.Add(OnBtnBackClick);
  34. // _ui.m_btnTips.onClick.Add(OnBtnTipsClick);
  35. _ui.m_btnGo.target.onClick.Add(OnBtnGoClick);
  36. _ui.m_btnGet.onClick.Add(OnBtnGetClick);
  37. _ui.m_btnPhoto.onClick.Add(OnBtnPhotoClick);
  38. _ui.m_btnFieldGuide.onClick.Add(OnBtnFieldGuideClick);
  39. }
  40. protected override void AddEventListener()
  41. {
  42. base.AddEventListener();
  43. EventAgent.AddEventListener(ConstMessage.TRAVEL_STATE_CHANGE, UpdateView);
  44. }
  45. protected override void OnShown()
  46. {
  47. base.OnShown();
  48. _valueBarController.OnShown();
  49. _valueBarController.Controller(7);
  50. UpdateView();
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. _valueBarController.OnHide();
  56. }
  57. protected override void RemoveEventListener()
  58. {
  59. base.RemoveEventListener();
  60. EventAgent.RemoveEventListener(ConstMessage.TRAVEL_STATE_CHANGE, UpdateView);
  61. }
  62. private void UpdateView()
  63. {
  64. _ui.m_c1.selectedIndex = 2;// TravelDataManager.Instance.TravelData.Status;
  65. if (_ui.m_c1.selectedIndex == (int)TravelGuideType.NoTravel)
  66. {
  67. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(GlobalCfgArray.globalCfg.travelCostArr[0]);
  68. _ui.m_btnGo.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(cfg.res);
  69. _ui.m_btnGo.m_txtCount.text = string.Format("-{0}", GlobalCfgArray.globalCfg.travelCostArr[1]);
  70. }
  71. else if (_ui.m_c1.selectedIndex == (int)TravelGuideType.Travel)
  72. {
  73. long endTime = TravelDataManager.Instance.TravelData.CreationTime + TravelDataManager.Instance.TravelData.TravelNeedHour * TimeUtil.SECOND_PER_HOUR;
  74. _ui.m_txtTime.text = string.Format("大约{0}后归来", TimeUtil.FormattingTime(TimeHelper.ServerNowSecs, (int)endTime));
  75. }
  76. }
  77. private void OnBtnBackClick()
  78. {
  79. ViewManager.GoBackFrom(typeof(TravelView).FullName);
  80. }
  81. // private void OnBtnTipsClick()
  82. // {
  83. // }
  84. private void OnBtnGoClick()
  85. {
  86. ViewManager.Show<TravelDressupView>(null, new object[] { typeof(TravelView).FullName, this.viewData });
  87. }
  88. private void OnBtnGetClick()
  89. {
  90. ViewManager.Show<TravelRewardView>(null, new object[] { typeof(TravelView).FullName, this.viewData });
  91. }
  92. private void OnBtnPhotoClick()
  93. {
  94. ViewManager.Show<PoemPhotoView>(PictureSourceType.WanShuiQianShan, new object[] { typeof(TravelView).FullName, this.viewData });
  95. }
  96. private void OnBtnFieldGuideClick()
  97. {
  98. ViewManager.Show<TravelGuideView>(null, new object[] { typeof(TravelView).FullName, this.viewData });
  99. }
  100. }
  101. }