using UI.Store; using UI.CommonGame; using FairyGUI; using System.Collections.Generic; using ET; using UnityEngine; using System; // using System.Diagnostics; namespace GFGGame { public class StoreView : BaseWindow { private UI_StoreUI _ui; // private ValueBarController _valueBarController; private List> _arenaSubTab = new List>(); private List _storeTabCfgs = new List(); private int _curTabIndex = 0; private int _curSubTabIndex = 0; private string _curViewName = ""; public override void Dispose() { if (_ui != null) { _ui.Dispose(); } _arenaSubTab.Clear(); _ui = null; base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_StoreUI.PACKAGE_NAME; _ui = UI_StoreUI.Create(); this.viewCom = _ui.target; isfullScreen = true; isReturnView = true; this.bringToFontOnClick = false; _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_fhl"); _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_comTab.m_c1.onChanged.Add(OnTabChange); _ui.m_listSubTab.itemRenderer = RenderListSubTabItem; _ui.m_listSubTab.onClickItem.Add(OnListSubTabClick); PreloadStoreChargeAddUp(); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot); EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateRedDot); EventAgent.AddEventListener(ConstMessage.NOTICE_BATCH_TASK_STATE_CHANGE, UpdateStoreMonthRedDot); EventAgent.AddEventListener(ConstMessage.STORE_BROCADE_WEAV_RECEIVE, UpdateStoreMonthRedDot); } protected override void OnShown() { base.OnShown(); StoreTabCfg arenaTab = StoreTabCfgArray.Instance.GetCfgByfunctionId(ConstFunctionId.STORE_ARENA); _arenaSubTab.Clear(); _arenaSubTab.Add(new List() { arenaTab.subTabArr[0][0], arenaTab.subTabArr[0][1], arenaTab.subTabArr[0][2] }); for (int i = ArenaDataManager.Instance.SeasonId; i > 0; i--) { _arenaSubTab.Add(new List() { string.Format("第{0}赛季", i), i.ToString(), "StoreArenaView" }); } _curTabIndex = this.viewData == null ? ConstStoreTabId.STORE_CHARGE : (int)(this.viewData as object[])[0]; _ui.m_comTab.m_c1.selectedIndex = _curTabIndex; _ui.m_comTab.target.scrollPane.SetPercX((float)(_curTabIndex - 1) / (float)StoreTabCfgArray.Instance.dataArray.Length, false); _curSubTabIndex = this.viewData == null ? 0 : (int)(this.viewData as object[])[1]; if (_curTabIndex == ConstStoreTabId.STORE_GIFT_BAG && _curSubTabIndex > 0 && !ShopDataManager.Instance.GetShopActivityIsShow(_curSubTabIndex)) { _curSubTabIndex -= 1; } if (_ui.m_listSubTab.numItems > _curSubTabIndex) { _ui.m_listSubTab.selectedIndex = _curSubTabIndex; _ui.m_listSubTab.ScrollToView(_curSubTabIndex); OnListSubTabChange(_curSubTabIndex); } if(_curTabIndex == ConstStoreTabId.STORE_MONTH_CARD && _curSubTabIndex == 2) ViewManager.Hide(); UpdateRedDot(); } protected override void OnHide() { base.OnHide(); _ui.m_comTab.m_c1.selectedIndex = 0; _ui.m_listSubTab.selectedIndex = 0; ViewManager.Hide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot); EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateRedDot); EventAgent.RemoveEventListener(ConstMessage.NOTICE_BATCH_TASK_STATE_CHANGE, UpdateStoreMonthRedDot); EventAgent.RemoveEventListener(ConstMessage.STORE_BROCADE_WEAV_RECEIVE, UpdateStoreMonthRedDot); } private void OnClickBtnBack() { ViewManager.Hide(_curViewName); this.Hide(); //ViewManager.GoBackFrom(typeof(StoreView).FullName); } private void OnTabChange() { StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_ui.m_comTab.m_c1.selectedIndex); if (tabCfg == null) return; if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(tabCfg.functionId)) { _ui.m_comTab.m_c1.selectedIndex = _ui.m_comTab.m_c1.previsousIndex; } _curTabIndex = _ui.m_comTab.m_c1.selectedIndex; if (tabCfg.functionId == ConstFunctionId.STORE_ARENA) { _ui.m_listSubTab.numItems = _arenaSubTab.Count; } else { _storeTabCfgs.Clear(); if (tabCfg.index == ConstStoreTabId.STORE_GIFT_BAG) { for (int i = 0; i < tabCfg.subTabArr.Length; i++) { int menu2 = int.Parse(tabCfg.subTabArr[i][1]); if (menu2 == ConstStoreSubId.STORE_GIFT_BAG_ACTIVITY || menu2 == ConstStoreSubId.STORE_GIFT_BAG_TSY) { if (!ShopDataManager.Instance.GetShopActivityIsShow(menu2)) continue; } _storeTabCfgs.Add(tabCfg.subTabArr[i]); } } else { _storeTabCfgs = new List(tabCfg.subTabArr); } _ui.m_listSubTab.numItems = _storeTabCfgs.Count; } _ui.m_listSubTab.selectedIndex = 0; _curSubTabIndex = 0; OnListSubTabChange(_curSubTabIndex); UpdateRedDot(); } private void RenderListSubTabItem(int index, GObject obj) { GButton item = obj.asButton; StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_curTabIndex); int menu2 = 0; if (tabCfg.functionId == ConstFunctionId.STORE_ARENA) { item.title = _arenaSubTab[index][0]; menu2 = int.Parse(_arenaSubTab[index][1]); } else { item.title = _storeTabCfgs[index][0]; menu2 = int.Parse(_storeTabCfgs[index][1]); } item.data = index; } private void OnListSubTabClick(EventContext context) { GObject obj = context.data as GObject; int index = (int)obj.data; if (index < 0) return; OnListSubTabChange(index); } private void OnListSubTabChange(int index) { StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_curTabIndex); string viewName = ""; int menu2 = 0; if (tabCfg.functionId == ConstFunctionId.STORE_ARENA) { menu2 = int.Parse(_arenaSubTab[index][1]); viewName = _arenaSubTab[index][2]; } else { menu2 = int.Parse(_storeTabCfgs[index][1]); viewName = _storeTabCfgs[index][2]; } if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(viewName)) { _ui.m_listSubTab.selectedIndex = _curSubTabIndex; return; } ViewManager.Hide(_curViewName); if (!string.IsNullOrEmpty(viewName) && viewName != "“”") { ViewManager.Show("GFGGame." + viewName, menu2); } _curSubTabIndex = index; _curViewName = "GFGGame." + viewName; } private void UpdateRedDot() { RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn0.target, RedDotDataManager.Instance.GetChargeAddUpRewardRed()); for (int i = 0; i < _ui.m_listSubTab.numItems; i++) { RedDotController.Instance.SetComRedDot(_ui.m_listSubTab.GetChildAt(i).asCom, false); } if (_ui.m_comTab.m_c1.selectedIndex == ConstStoreTabId.STORE_CHARGE) { RedDotController.Instance.SetComRedDot(_ui.m_listSubTab.GetChildAt(ConstStoreSubId.STORE_CHARGE_ADDUP).asCom, RedDotDataManager.Instance.GetChargeAddUpRewardRed()); } UpdateStoreMonthRedDot(); RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn2.target, RedDotDataManager.Instance.GetGiftBagRewardRed()); if (_ui.m_comTab.m_c1.selectedIndex == ConstStoreTabId.STORE_GIFT_BAG) { RedDotController.Instance.SetComRedDot(_ui.m_listSubTab.GetChildAt(ConstStoreSubId.STORE_GIFT_BAG_ACTIVITY).asCom, RedDotDataManager.Instance.GetGiftBagRewardRed()); } } //月卡红点刷新 private void UpdateStoreMonthRedDot() { RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn1.target, RedDotDataManager.Instance.GetGoldCardRewardRed() || RedDotDataManager.Instance.GetBlackCardRewardRed() || RedDotDataManager.Instance.GetBlackCardClothingRed() || RedDotDataManager.Instance.GetStoreBrocadeWeavRewardRed()); if (_ui.m_comTab.m_c1.selectedIndex == ConstStoreTabId.STORE_MONTH_CARD) { RedDotController.Instance.SetComRedDot(_ui.m_listSubTab.GetChildAt(ConstStoreSubId.STORE_MONTH_GOLD_CARD).asCom, RedDotDataManager.Instance.GetGoldCardRewardRed()); RedDotController.Instance.SetComRedDot(_ui.m_listSubTab.GetChildAt(ConstStoreSubId.STORE_MONTH_BLACK_CARD).asCom, RedDotDataManager.Instance.GetBlackCardRewardRed() || RedDotDataManager.Instance.GetBlackCardClothingRed()); RedDotController.Instance.SetComRedDot(_ui.m_listSubTab.GetChildAt(ConstStoreSubId.STORE_MONTH_BROCADE_WEAV).asCom, RedDotDataManager.Instance.GetStoreBrocadeWeavRewardRed()); } } //会员中心模型预加载 private void PreloadStoreChargeAddUp() { int vipIndex = Math.Max(0, RoleDataManager.vipLv - 1); for (int i = vipIndex; i >= 0; i--) { PreloadSuitModel(i); } for (int i = vipIndex + 1; i < VipCfgArray.Instance.dataArray.Length - 1; i++) { PreloadSuitModel(i); } } private void PreloadSuitModel(int index) { VipCfg vipCfg = VipCfgArray.Instance.dataArray[index + 1]; SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(vipCfg.suitId); ResType resType = ResType.Sprite; if (suitCfg.aniRes != "") resType = ResType.Animation; PreloadManager.Instance.PreloadSuitRes(vipCfg.suitId, resType, new int[] { ConstDressUpItemType.BEI_JING }, true); } } }