TravelRewardView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Travel;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class TravelRewardView : BaseWindow
  9. {
  10. private UI_TravelRewardUI _ui;
  11. public override void Dispose()
  12. {
  13. if (_ui != null)
  14. {
  15. _ui.Dispose();
  16. _ui = null;
  17. }
  18. base.Dispose();
  19. }
  20. protected override void OnInit()
  21. {
  22. base.OnInit();
  23. packageName = UI_TravelRewardUI.PACKAGE_NAME;
  24. _ui = UI_TravelRewardUI.Create();
  25. this.viewCom = _ui.target;
  26. isfullScreen = true;
  27. _ui.m_list.itemRenderer = RenderListItem;
  28. _ui.m_btnGet.onClick.Add(OnBtnGetClick);
  29. }
  30. protected override void AddEventListener()
  31. {
  32. base.AddEventListener();
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. UpdateView();
  38. }
  39. protected override void OnHide()
  40. {
  41. _ui.m_t1.Play();
  42. base.OnHide();
  43. }
  44. protected override void RemoveEventListener()
  45. {
  46. base.RemoveEventListener();
  47. }
  48. private void UpdateView()
  49. {
  50. TravelData travelData = TravelDataManager.Instance.TravelData;
  51. TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(travelData.TravelLocationId);
  52. _ui.m_comPostCard.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
  53. _ui.m_comPostCard.m_txtLocationName.text = loactionCfg.name;
  54. _ui.m_comPostCard.m_txtTime.text = TimeUtil.FormattingTime2(travelData.CreationTime);
  55. if (travelData.TravelSuitId > 0)
  56. {
  57. TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(travelData.TravelSuitId);
  58. _ui.m_comPostCard.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelRolePath(travelSuitCfg.reourcesArr[travelData.SuitResIndex]);
  59. _ui.m_comPostCard.m_comTravel.m_loaRole.SetXY(loactionCfg.positionsArr[travelData.PositionIndex][0], loactionCfg.positionsArr[travelData.PositionIndex][1]);
  60. }
  61. _ui.m_list.numItems = travelData.RewardItems.Count;
  62. }
  63. private void RenderListItem(int index, GObject obj)
  64. {
  65. ItemData itemData = TravelDataManager.Instance.TravelData.RewardItems[index];
  66. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  67. UI_ComReward item = UI_ComReward.Proxy(obj);
  68. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  69. item.m_txtCount.text = "x" + itemData.num.ToString();
  70. UI_ComReward.ProxyEnd();
  71. }
  72. private async void OnBtnGetClick()
  73. {
  74. bool result = await TravelSProxy.ReqGetTravelReward();
  75. if (result)
  76. {
  77. // GComponent travelViewUI = ViewManager.GetUIView(typeof(TravelView).Name).viewCom;
  78. // GButton btnPhoto = travelViewUI.GetChild("btnPhoto").asButton;
  79. // // UI_TravelUI travelViewUI = UI_TravelUI.Proxy(ViewManager.GetUIView(typeof(TravelView).Name).viewCom);
  80. // Vector2 vector2 = travelViewUI.TransformPoint(btnPhoto.xy, _ui.target);
  81. _ui.m_t1.SetValue("start", _ui.m_comPostCard.target.x, _ui.m_comPostCard.target.y);
  82. _ui.m_t0.SetValue("start", _ui.m_comPostCard.target.x, _ui.m_comPostCard.target.y);
  83. _ui.m_t0.SetValue("end", _ui.m_btnGet.x - 240, _ui.m_btnGet.y);
  84. _ui.m_t0.Play(this.Hide);
  85. }
  86. }
  87. }
  88. }