1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Travel;
- using UnityEngine;
- namespace GFGGame
- {
- public class TravelRewardView : BaseWindow
- {
- private UI_TravelRewardUI _ui;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_TravelRewardUI.PACKAGE_NAME;
- _ui = UI_TravelRewardUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_list.itemRenderer = RenderListItem;
- _ui.m_btnGet.onClick.Add(OnBtnGetClick);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- UpdateView();
- }
- protected override void OnHide()
- {
- _ui.m_t1.Play();
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void UpdateView()
- {
- TravelLoactionCfg loactionCfg = TravelLoactionCfgArray.Instance.GetCfg(TravelDataManager.Instance.TravelData.TravelLocationId);
- TravelSuitCfg travelSuitCfg = TravelSuitCfgArray.Instance.GetCfg(TravelDataManager.Instance.TravelData.TravelSuitId);
- _ui.m_comPostCard.m_comTravel.m_loaBg.url = ResPathUtil.GetTravelBgPath(loactionCfg.res);
- _ui.m_comPostCard.m_comTravel.m_loaRole.url = ResPathUtil.GetTravelBgPath(travelSuitCfg.reourcesArr[TravelDataManager.Instance.TravelData.SuitResIndex]);
- _ui.m_comPostCard.m_txtLocationName.text = loactionCfg.name;
- _ui.m_comPostCard.m_txtTime.text = TimeUtil.FormattingTime2(TravelDataManager.Instance.TravelData.CreationTime);
- _ui.m_list.numItems = TravelDataManager.Instance.TravelData.RewardItems.Count;
- }
- private void RenderListItem(int index, GObject obj)
- {
- ItemData itemData = TravelDataManager.Instance.TravelData.RewardItems[index];
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
- UI_ComReward item = UI_ComReward.Proxy(obj);
- item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
- item.m_txtCount.text = itemData.num.ToString();
- UI_ComReward.ProxyEnd();
- }
- private async void OnBtnGetClick()
- {
- bool result = await TravelSProxy.ReqGetTravelReward();
- if (result)
- {
- UI_TravelUI travelViewUI = UI_TravelUI.Proxy(ViewManager.GetUIView(typeof(TravelView).FullName).viewCom);
- Vector2 vector2 = travelViewUI.target.TransformPoint(travelViewUI.m_btnPhoto.xy, _ui.target);
- _ui.m_t0.SetValue("end", vector2.x, vector2.y);
- _ui.m_t0.Play(this.Hide);
- }
- }
- }
- }
|