TravelRewardView.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(TravelDataManager.Instance.TravelData.TravelLocationId);
  51. TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(TravelDataManager.Instance.TravelData.TravelSuitId);
  52. _ui.m_comPostCard.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
  53. _ui.m_comPostCard.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelBgPath(travelSuitCfg.reourcesArr[TravelDataManager.Instance.TravelData.SuitResIndex]);
  54. _ui.m_comPostCard.m_txtLocationName.text = loactionCfg.name;
  55. _ui.m_comPostCard.m_txtTime.text = TimeUtil.FormattingTime2(TravelDataManager.Instance.TravelData.CreationTime);
  56. _ui.m_list.numItems = TravelDataManager.Instance.TravelData.RewardItems.Count;
  57. }
  58. private void RenderListItem(int index, GObject obj)
  59. {
  60. ItemData itemData = TravelDataManager.Instance.TravelData.RewardItems[index];
  61. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  62. UI_ComReward item = UI_ComReward.Proxy(obj);
  63. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  64. item.m_txtCount.text = itemData.num.ToString();
  65. UI_ComReward.ProxyEnd();
  66. }
  67. private async void OnBtnGetClick()
  68. {
  69. bool result = await TravelSProxy.ReqGetTravelReward();
  70. if (result)
  71. {
  72. UI_TravelUI travelViewUI = UI_TravelUI.Proxy(ViewManager.GetUIView(typeof(TravelView).FullName).viewCom);
  73. Vector2 vector2 = travelViewUI.target.TransformPoint(travelViewUI.m_btnPhoto.xy, _ui.target);
  74. _ui.m_t0.SetValue("end", vector2.x, vector2.y);
  75. _ui.m_t0.Play(this.Hide);
  76. }
  77. }
  78. }
  79. }