123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using UI.FieldGuide;
- using FairyGUI;
- using UnityEngine;
- using System.Collections.Generic;
- using System;
- namespace GFGGame
- {
- public class TravelShowView : BaseWindow
- {
- private UI_TravelShowUI _ui;
- private TravelGuideCfg _cfg;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui = UI_TravelShowUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_btnReward.target.onClick.Add(OnBtnRewardClick);
- _ui.m_list.itemRenderer = RenderListItem;
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xqfs_bj");
- }
- protected override void OnShown()
- {
- base.OnShown();
- _cfg = this.viewData as TravelGuideCfg;
- UpdateView();
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRewardState);
- }
- protected override void OnHide()
- {
- base.OnHide();
- if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRewardState);
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(TravelShowView).FullName);
- }
- private void UpdateView()
- {
- _ui.m_list.numItems = _cfg.locationsArr.Length;
- UpdateRewardState();
- }
- private void UpdateRewardState()
- {
- // int state = TravelDataManager.Instance.ListTravelAreaRewardState[_index];
- _ui.m_btnReward.m_c1.selectedIndex = TravelDataManager.Instance.GetGuideRewardStateByAreaId(_cfg.id) == ConstBonusStatus.GOT ? 0 : 1;
- RedDotController.Instance.SetComRedDot(_ui.m_btnReward.target, RedDotDataManager.Instance.GetTravelGuideAreaRed(_cfg.id));
- }
- private void RenderListItem(int index, GObject obj)
- {
- TravelLoactionCfg locationCfg = TravelLoactionCfgArray.Instance.GetCfgBylocation(_cfg.locationsArr[index]);
- UI_ListTravelLocationItem item = UI_ListTravelLocationItem.Proxy(obj);
- item.m_txtName.text = locationCfg.name;
- item.m_comLocation.m_loaLocation.url = ResPathUtil.GetTravelBgPath(locationCfg.res);
- int count = TravelDataManager.Instance.GetTravelCountByLocationId(locationCfg.id);
- item.m_txtCount.text = string.Format("已到达:{0}次", count);
- item.m_c1.selectedIndex = count > 0 ? 1 : 0;
- UI_ListTravelLocationItem.ProxyEnd();
- }
- private void OnBtnRewardClick()
- {
- int state = TravelDataManager.Instance.GetGuideRewardStateByAreaId(_cfg.id);
- if (state == ConstBonusStatus.CAN_NOT_GET)
- {
- List<ItemData> rewards = ItemUtil.CreateItemDataList(_cfg.rewardsArr);
- ViewManager.Show<RewardPreView>(new object[] { rewards, "活跃度奖励", "到达该区域所有地点时可领取" });
- }
- else if (state == ConstBonusStatus.CAN_GET)
- {
- TravelSProxy.ReqGetTravelGuideReward(_cfg.id).Coroutine();
- }
- }
- }
- }
|