using UnityEngine; using FairyGUI; using UI.FieldGuide; using UI.Card; using UI.CommonGame; using System.Collections.Generic; namespace GFGGame { public class CardDetailView : BaseView { private const int listRoleCount = 5; private UI_CardDetailUI _ui; private int _selectType = 0; public override void Dispose() { if (_ui != null) { _ui.Dispose(); } _ui = null; base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_CardDetailUI.PACKAGE_NAME; _ui = UI_CardDetailUI.Create(); viewCom = _ui.target; isfullScreen = true; _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_btnHome.onClick.Add(OnClickBtnHome); _ui.m_btnFilter.onClick.Add(OnclickBtnFilter); _ui.m_listCard.itemRenderer = RenderListCardItem; _ui.m_listCard.onClickItem.Add(OnClickListCardItem); _ui.m_listCard.SetVirtual(); _ui.m_listRole.itemRenderer = RenderListRoleItem; _ui.m_listRole.onClickItem.Add(OnClickListRoleItem); _ui.m_listRole.selectedIndex = 0; EventAgent.AddEventListener(ConstMessage.CARD_REFRESH, () => { UpdateCardList(_ui.m_listRole.selectedIndex); }); } protected override void OnShown() { base.OnShown(); CardSProxy.GetCardInfos().Coroutine(); int listRoleSelect = this.viewData != null ? (int)this.viewData : 0; _ui.m_listRole.selectedIndex = listRoleSelect; _ui.m_listRole.numItems = listRoleCount; this.UpdateCardList((int)_ui.m_listRole.GetChildAt(_ui.m_listRole.selectedIndex).data); } private void UpdateCardList(int rarity = 0) { List cardList = CardDataManager.GetCardListByRarity(rarity); if (CardDataManager._selectList.Keys.Count > 0) { //筛选 cardList = CardDataManager.FilterCardList(cardList, CardDataManager._selectList as Dictionary>); } _ui.m_listCard.data = cardList; _ui.m_listCard.numItems = cardList.Count; _ui.m_txtTips.visible = _ui.m_listCard.numItems == 0 ? true : false; } private void RenderListCardItem(int index, GObject obj) { UI_ListCardItem listItem = UI_ListCardItem.Proxy(obj); CardData data = (_ui.m_listCard.data as List)[index];//CardDataManager.GetCardList(_ui.m_listRole.selectedIndex)[index]; listItem.target.data = data; listItem.m_loaCard.m_loaCard.url = ResPathUtil.GetCardSmallPath(data.resources[data.resIndex]); listItem.m_loaRarity.url = ResPathUtil.GetCommonGameResPath("kp_sxing_x_" + data.itemCfg.rarity); listItem.m_txtLv.text = "Lv.\n" + data.lv; listItem.m_txtName.text = data.itemCfg.name; UI_ComStar comStar = UI_ComStar.Proxy(listItem.m_comStar); comStar.m_c1.selectedIndex = data.star; UI_ListCardItem.ProxyEnd(); } private void OnClickListCardItem(EventContext context) { ViewManager.Show(ViewName.CARD_FOSTER_VIEW, (context.data as GObject).data, new object[] { ViewName.CARD_DETAIL_VIEW, _ui.m_listRole.selectedIndex }); // this.Clear(); } private void RenderListRoleItem(int index, GObject obj) { obj.data = index == 0 ? 0 : listRoleCount - index; } private void OnClickListRoleItem(EventContext context) { int index = (int)(context.data as GObject).data; this.UpdateCardList(index); } /*******************************************************监听函数**************************************************/ private void OnclickBtnFilter() { ViewManager.Show(ViewName.CARD_FILTER_VIEW, null, new object[] { ViewName.CARD_DETAIL_VIEW, _ui.m_listRole.selectedIndex }); } private void OnClickBtnBack() { ViewManager.GoBackFrom(ViewName.CARD_DETAIL_VIEW); this.Clear(); } private void OnClickBtnHome() { GameController.GoBackToMainView(); this.Clear(); } private void Clear() { // this._selectType = 0; CardDataManager._selectList.Clear(); _ui.m_listRole.selectedIndex = 0; _ui.m_listCard.selectedIndex = 0; } protected override void OnHide() { base.OnHide(); } protected override void UpdateToCheckGuide(object param) { if (!ViewManager.CheckIsTopView(this.viewCom)) return; GuideController.TryGuide(_ui.m_listCard, ConstGuideId.UP_CARD_STAR, 3, "选择可升星的词牌", 0); } } }