| | |
| | | //-------------------------------------------------------- |
| | | |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using UnityEngine; |
| | |
| | | |
| | | |
| | | ////开服盛典 |
| | | public class OSGalaBaseWin : FunctionsBaseWin |
| | | public class OSGalaBaseWin : UIBase |
| | | { |
| | | [SerializeField] Transform moneyTrans2; |
| | | [SerializeField] Transform galaTrans; |
| | | [SerializeField] ScrollerController tabScroller; |
| | | [SerializeField] Image processImg; |
| | | [SerializeField] Text timeText; |
| | | [SerializeField] Text galaTimeText; |
| | | [SerializeField] Text totalScoreText; |
| | | [SerializeField] ItemCell[] itemCells; |
| | | [SerializeField] Image[] gotImgs; |
| | | [SerializeField] Text[] scoreTexts; |
| | | [SerializeField] UIEffectPlayer[] effectPlayers; |
| | | |
| | | [SerializeField] Transform totalRechargeTrans; |
| | | [SerializeField] Text totalRechargeTimeText; |
| | | [SerializeField] ItemCell totalRechargeItemCell; |
| | | [SerializeField] Text totalRechargeScoreText; |
| | | [SerializeField] RotationTween totalRechargeRotationTween; |
| | | [SerializeField] Image totalRechargeFreeRedImage; |
| | | [SerializeField] Image totalRechargeHaveImage; |
| | | |
| | | [SerializeField] Transform totDayRechargeTrans; |
| | | [SerializeField] Text totDayRechargeTimeText; |
| | | [SerializeField] ItemCell totDayRechargeItemCell; |
| | | [SerializeField] Text totDayRechargeScoreText; |
| | | [SerializeField] RotationTween totDayRechargeRotationTween; |
| | | [SerializeField] Image totDayRechargeFreeRedImage; |
| | | [SerializeField] Image totDayRechargeHaveImage; |
| | | |
| | | private int nowTabId = 0; |
| | | private UIBase currentSubUI; |
| | | private List<int> tabIdList = new List<int> { 0, 1, 2, 3, 4 }; |
| | | private Dictionary<int, string> tabTitleKeys = new Dictionary<int, string> |
| | | { |
| | | { 0, "DayMission1" }, |
| | | { 1, "OSActivity9" }, |
| | | { 2, "OSActivity3" }, |
| | | { 3, "TotalRecharge04" }, |
| | | { 4, "TotalRecharge05" }, |
| | | }; |
| | | private Dictionary<int, int> tabRedpointKeys = new Dictionary<int, int> |
| | | { |
| | | { 0, 1131 }, |
| | | { 1, 1132 }, |
| | | { 2, 1133 }, |
| | | { 3, 1135 }, |
| | | { 4, 1136 }, |
| | | }; |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | base.OnPreOpen(); |
| | | tabScroller.OnRefreshCell += OnRefreshTabCell; |
| | | OSActivityManager.Instance.OnOSGalaDataChangeEvent += OnOSGalaDataChangeEvent; |
| | | GlobalTimeEvent.Instance.secondEvent += ShowTime; |
| | | StoreModel.Instance.RefreshBuyShopLimitEvent += OnRefreshBuyShopLimitEvent; |
| | | TotalRechargeManager.Instance.OnTotalRechargePlayerInfoEvent += OnTotalRechargePlayerInfoEvent; |
| | | TotDayRechargeManager.Instance.OnTotDayRechargePlayerInfoEvent += OnTotDayRechargePlayerInfoEvent; |
| | | CreateTabScroller(); |
| | | Display(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | base.OnPreClose(); |
| | | tabScroller.OnRefreshCell -= OnRefreshTabCell; |
| | | OSActivityManager.Instance.OnOSGalaDataChangeEvent -= OnOSGalaDataChangeEvent; |
| | | GlobalTimeEvent.Instance.secondEvent -= ShowTime; |
| | | StoreModel.Instance.RefreshBuyShopLimitEvent -= OnRefreshBuyShopLimitEvent; |
| | | TotalRechargeManager.Instance.OnTotalRechargePlayerInfoEvent -= OnTotalRechargePlayerInfoEvent; |
| | | TotDayRechargeManager.Instance.OnTotDayRechargePlayerInfoEvent -= OnTotDayRechargePlayerInfoEvent; |
| | | CloseCurrentSubUI(); |
| | | } |
| | | |
| | | |
| | | protected override void OpenSubUIByTabIndex() |
| | | private void OnTotDayRechargePlayerInfoEvent() |
| | | { |
| | | switch (functionOrder) |
| | | tabScroller.m_Scorller.RefreshActiveCellViews(); |
| | | SelectBottomTab(nowTabId); |
| | | Display(); |
| | | } |
| | | |
| | | private void OnTotalRechargePlayerInfoEvent() |
| | | { |
| | | tabScroller.m_Scorller.RefreshActiveCellViews(); |
| | | SelectBottomTab(nowTabId); |
| | | Display(); |
| | | } |
| | | |
| | | private void OnRefreshBuyShopLimitEvent() |
| | | { |
| | | tabScroller.m_Scorller.RefreshActiveCellViews(); |
| | | SelectBottomTab(nowTabId); |
| | | Display(); |
| | | } |
| | | |
| | | private void CreateTabScroller() |
| | | { |
| | | tabScroller.Refresh(); |
| | | bool isOSGalaOpen = OSActivityManager.Instance.IsOpenedOSGala(); |
| | | bool isTotDayRechargeOpen = TotDayRechargeManager.Instance.IsOpen; |
| | | bool isTotalRechargeOpen = TotalRechargeManager.Instance.IsOpen; |
| | | List<int> visibleTabs = new List<int>(); |
| | | for (int i = 0; i < tabIdList.Count; i++) |
| | | { |
| | | int tabId = tabIdList[i]; |
| | | bool canShow = false; |
| | | if (tabId == 0 || tabId == 1 || tabId == 2) |
| | | { |
| | | canShow = isOSGalaOpen; |
| | | } |
| | | else if (tabId == 3) |
| | | { |
| | | canShow = isTotalRechargeOpen; |
| | | } |
| | | else if (tabId == 4) |
| | | { |
| | | canShow = isTotDayRechargeOpen; |
| | | } |
| | | if (canShow) |
| | | { |
| | | visibleTabs.Add(tabId); |
| | | tabScroller.AddCell(ScrollerDataType.Header, tabId); |
| | | } |
| | | } |
| | | if (visibleTabs.Count > 0) |
| | | { |
| | | nowTabId = visibleTabs[0]; |
| | | } |
| | | tabScroller.Restart(); |
| | | SelectBottomTab(nowTabId); |
| | | } |
| | | |
| | | private void OnRefreshTabCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<OSGalaTabCell>(); |
| | | string titleKey = tabTitleKeys.ContainsKey(cell.index) ? tabTitleKeys[cell.index] : ""; |
| | | int redpointId = tabRedpointKeys.ContainsKey(cell.index) ? tabRedpointKeys[cell.index] : 0; |
| | | _cell?.Display(cell.index, nowTabId, titleKey, redpointId, OnTabClicked); |
| | | } |
| | | |
| | | private void OnTabClicked(int index) |
| | | { |
| | | if (nowTabId == index) |
| | | { |
| | | return; |
| | | } |
| | | nowTabId = index; |
| | | tabScroller.m_Scorller.RefreshActiveCellViews(); |
| | | SelectBottomTab(index); |
| | | } |
| | | |
| | | private void SelectBottomTab(int index) |
| | | { |
| | | if (currentSubUI != null) |
| | | { |
| | | currentSubUI.CloseWindow(); |
| | | currentSubUI = null; |
| | | } |
| | | |
| | | galaTrans.SetActive(index == 0 || index == 1 || index == 2); |
| | | moneyTrans2.SetActive(index == 0 || index == 1 || index == 2); |
| | | |
| | | totalRechargeTrans.SetActive(index == 3); |
| | | totDayRechargeTrans.SetActive(index == 4); |
| | | |
| | | switch (index) |
| | | { |
| | | case 0: |
| | | currentSubUI = UIManager.Instance.OpenWindow<OSGalaMissionWin>(); |
| | |
| | | case 2: |
| | | currentSubUI = UIManager.Instance.OpenWindow<OSGalaGiftWin>(); |
| | | break; |
| | | case 3: |
| | | currentSubUI = UIManager.Instance.OpenWindow<TotalRechargeWin>(); |
| | | |
| | | var data = TotalRechargeManager.Instance.GetStoreData(); |
| | | bool isReceived = TotalRechargeManager.Instance.IsReceived(data.shopId); |
| | | totalRechargeItemCell.Init(new ItemCellModel(data.storeConfig.ItemID, false, data.storeConfig.ItemCnt)); |
| | | totalRechargeItemCell.button.SetListener(() => |
| | | { |
| | | if (!isReceived) |
| | | { |
| | | StoreModel.Instance.SendBuyShopItem(data.storeConfig, 1); |
| | | } |
| | | else |
| | | { |
| | | ItemTipUtility.Show(data.storeConfig.ItemID); |
| | | } |
| | | |
| | | }); |
| | | |
| | | totalRechargeHaveImage.SetActive(isReceived); |
| | | totalRechargeFreeRedImage.SetActive(!isReceived); |
| | | totalRechargeTimeText.text = TotalRechargeManager.Instance.GetActTimeStr(); |
| | | totalRechargeScoreText.text = Language.Get("TotalRecharge06", TotalRechargeManager.Instance.coinTotal); |
| | | if (!isReceived) |
| | | { |
| | | totalRechargeRotationTween.Play(); |
| | | } |
| | | else |
| | | { |
| | | totalRechargeRotationTween.Stop(); |
| | | totalRechargeRotationTween.SetStartState(); |
| | | } |
| | | break; |
| | | case 4: |
| | | currentSubUI = UIManager.Instance.OpenWindow<TotDayRechargeWin>(); |
| | | |
| | | var data1 = TotDayRechargeManager.Instance.GetStoreData(); |
| | | bool isReceived1 = TotDayRechargeManager.Instance.IsReceived(data1.shopId); |
| | | totDayRechargeItemCell.Init(new ItemCellModel(data1.storeConfig.ItemID, false, data1.storeConfig.ItemCnt)); |
| | | totDayRechargeItemCell.button.SetListener(() => |
| | | { |
| | | if (!isReceived1) |
| | | { |
| | | StoreModel.Instance.SendBuyShopItem(data1.storeConfig, 1); |
| | | } |
| | | else |
| | | { |
| | | ItemTipUtility.Show(data1.storeConfig.ItemID); |
| | | } |
| | | |
| | | }); |
| | | |
| | | totDayRechargeHaveImage.SetActive(isReceived1); |
| | | totDayRechargeFreeRedImage.SetActive(!isReceived1); |
| | | totDayRechargeTimeText.text = TotDayRechargeManager.Instance.GetActTimeStr(); |
| | | totDayRechargeScoreText.text = Language.Get("TotalRecharge07", TotDayRechargeManager.Instance.totalDays); |
| | | if (!isReceived1) |
| | | { |
| | | totDayRechargeRotationTween.Play(); |
| | | } |
| | | else |
| | | { |
| | | totDayRechargeRotationTween.Stop(); |
| | | totDayRechargeRotationTween.SetStartState(); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void CloseCurrentSubUI() |
| | | { |
| | | if (currentSubUI != null) |
| | | { |
| | | currentSubUI.CloseWindow(); |
| | | currentSubUI = null; |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | void ShowTime() |
| | | { |
| | | if (TimeUtility.OpenDay >= OSActivityManager.Instance.osGalaOpenDays) |
| | | { |
| | | timeText.text = Language.Get("OSActivity6"); |
| | | galaTimeText.text = Language.Get("OSActivity6"); |
| | | } |
| | | else |
| | | { |
| | | timeText.text = Language.Get("OSActivity10") + TimeUtility.SecondsToShortDHMS(TimeUtility.GetRemindTimeByOpenDay(OSActivityManager.Instance.osGalaOpenDays)); |
| | | galaTimeText.text = Language.Get("OSActivity10") + TimeUtility.SecondsToShortDHMS(TimeUtility.GetRemindTimeByOpenDay(OSActivityManager.Instance.osGalaOpenDays)); |
| | | } |
| | | totalRechargeTimeText.text = TotalRechargeManager.Instance.GetActTimeStr(); |
| | | totDayRechargeTimeText.text = TotDayRechargeManager.Instance.GetActTimeStr(); |
| | | } |
| | | } |
| | | |