123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- 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;
- 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();
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
- 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);
- Timers.inst.AddUpdate(CheckGuide);
- }
- private void UpdateCardList(int mainScore = 0)
- {
- List<CardData> cardList = CardDataManager.GetCardListByRarity(mainScore);
- if (CardDataManager._selectList.Keys.Count > 0)
- {
- //筛选
- cardList = CardDataManager.FilterCardList(cardList, CardDataManager._selectList as Dictionary<int, Dictionary<int, int>>);
- }
- _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<CardData>)[index];//CardDataManager.GetCardList(_ui.m_listRole.selectedIndex)[index];
- listItem.target.data = data;
- listItem.m_comCard.m_loaCard.url = ResPathUtil.GetCardSmallPath(data.resources[data.resIndex]);
- RarityIconController.UpdateRarityIcon(listItem.m_loaRarity, data.itemCfg.id, false);// ResPathUtil.GetCommonGameResPath("kp_sxing_x_" + data.itemCfg.rarity);
- listItem.m_loaMainScore.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (data.itemCfg.mainScore));
- listItem.m_loaBorder.url = "ui://Card/kp_kuang_" + data.itemCfg.rarity;//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_ComStar.ProxyEnd();
- 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 : 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);
- }
- private void OnClickBtnHome()
- {
- GameController.GoBackToMainView();
- }
- 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();
- this.Clear();
- Timers.inst.Remove(CheckGuide);
- }
- private void CheckGuide(object param)
- {
- if (GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0)
- {
- UpdateToCheckGuide(null);
- }
- else
- {
- Timers.inst.Remove(CheckGuide);
- }
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_listCard, ConstGuideId.UP_CARD_LV, 3, "选择可升级的词牌", 0, true, 0, 0, 0, true, true);
- }
- }
- }
|