123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using FairyGUI;
- using System.Collections;
- using System.Collections.Generic;
- using UI.Card;
- using UnityEngine;
- namespace GFGGame
- {
- public class CardStarRewardView : BaseWindow
- {
- private UI_CardStarRewardUI _ui;
- private List<CardStarCfg> _cardStarRewards;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_CardStarRewardUI.PACKAGE_NAME;
- _ui = UI_CardStarRewardUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_listReward.itemRenderer = RenderListStarRewardItem;
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.CARD_STAR_REWARD, UpdateView);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _cardStarRewards = this.viewData as List<CardStarCfg>;
- UpdateView();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.CARD_STAR_REWARD, UpdateView);
- }
- private void UpdateView()
- {
- _ui.m_listReward.numItems = _cardStarRewards.Count;
- }
- private void RenderListStarRewardItem(int index, GObject obj)
- {
- UI_ListCardStarRewardItem item = UI_ListCardStarRewardItem.Proxy(obj);
- CardStarCfg cardStarCfg = _cardStarRewards[index];
- CardData cardData = CardDataManager.GetCardDataById(cardStarCfg.cardId);
- if (index == 0)
- {
- item.m_txtTitle.text = "激活词牌";
- }
- else
- {
- item.m_txtTitle.text = string.Format("词牌星级达到{0}星", NumberUtil.GetChiniseNumberText(cardStarCfg.starLvl));
- }
- item.m_txtTips.visible = cardStarCfg.starLvl == cardData.itemCfg.animationCardStar;
- item.m_c1.selectedIndex = cardData.starRewardsState.ContainsKey(cardStarCfg.starLvl) ? cardData.starRewardsState[cardStarCfg.starLvl] : 0;
- if (item.m_btnGet.data == null)
- {
- item.m_btnGet.onClick.Add(OnClickBtnGet);
- }
- item.m_btnGet.data = cardStarCfg;
- ItemData reward = ItemUtil.createItemData(cardStarCfg.rewardsArr[0]);
- if (item.m_comItem.data == null)
- {
- item.m_comItem.data = new ItemView(item.m_comItem);
- }
- (item.m_comItem.data as ItemView).SetData(reward);
- (item.m_comItem.data as ItemView).SetComItemScale = 0.65f;
- (item.m_comItem.data as ItemView).SetTxtCountPos(185, 140);
- UI_ListCardStarRewardItem.ProxyEnd();
- }
- private void OnClickBtnGet(EventContext context)
- {
- GObject obj = context.sender as GObject;
- CardStarCfg cardStarCfg = obj.data as CardStarCfg;
- CardSProxy.GetCardStarBonus(cardStarCfg.cardId, cardStarCfg.starLvl).Coroutine();
- }
- }
- }
|