/// <summary> /// 商店倒计时结束数据刷新 /// </summary> private void UpdateData() { bool m_IsRefresh = false; for (int i = 0; i < CountDownCompent.m_CountDowns.Count; i++) { CountDownCompent countDown = CountDownCompent.m_CountDowns[i]; if (countDown.m_Time <= ServerTimeUtil.Instance.GetNowTime()) { if (countDown.m_Time > 0) { m_IsRefresh = true; } } } if (m_ShopProxy.GetRefreshTime() <= ServerTimeUtil.Instance.GetNowTime()) { if (m_ShopProxy.GetRefreshTime() > 0) { m_IsRefresh = true; } } if (m_IsRefresh) { UIManager.Instance.StartCoroutine(GetEnumerator()); } }
/// <summary> /// 倒计时时间刷新 /// </summary> private void UpdateTime() { for (int i = 0; i < CountDownCompent.m_CountDowns.Count; i++) { CountDownCompent countDown = CountDownCompent.m_CountDowns[i]; if (countDown.m_Time <= ServerTimeUtil.Instance.GetNowTime()) { countDown.m_CountDownLabel.gameObject.SetActive(false); } else { long leftTime = (long)countDown.m_Time - (long)ServerTimeUtil.Instance.GetNowTime(); countDown.m_CountDownLabel.gameObject.SetActive(true); SetTime(leftTime, countDown.m_CountDownLabel, "shop_text_1005"); } } if (m_ShopProxy.GetRefreshTime() <= ServerTimeUtil.Instance.GetNowTime()) { LeftLabel.gameObject.SetActive(false); } else { if (State.GetPageIndex() == 0) { long refreshTime = (long)m_ShopProxy.GetRefreshTime() - (long)ServerTimeUtil.Instance.GetNowTime(); LeftLabel.gameObject.SetActive(true); SetTime(refreshTime, LeftLabel, "shop_text_1004"); } else { LeftLabel.gameObject.SetActive(false); } } }
protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { Animator m_Animator = cellView.GetComponent <Animator>(); if (m_Animator) { m_Animator.SetBool("IsOn", selected); } UIViewListLayout style = State.GetPageLayoutStyle(State.GetPageIndex()); if (State.GetPageIndex() == 0) { ShopWindowVO m_ShopWindowVO = (ShopWindowVO)cellData; NpcShopElementGrid m_ShopElementGrid = cellView.GetOrAddComponent <NpcShopElementGrid>(); if (style == UIViewListLayout.Grid) { m_ShopElementGrid.SetData(m_ShopWindowVO, selected, false); } else { m_ShopElementGrid.SetData(m_ShopWindowVO, selected, true); } CountDownCompent m_CountDownCompent = cellView.GetOrAddComponent <CountDownCompent>(); m_CountDownCompent.SetTime(m_ShopWindowVO.RefreshTime); if (selected) { if (m_ShopWindowVO.IsOpen == 0 || m_ShopWindowVO.ServerLeftNum == 0 || !m_ShopElementGrid.MoneyeEnough() || m_ShopWindowVO.LimitCount == 0 || m_ShopWindowVO.LimitCount < m_ShopWindowVO.ShopItemConfig.Value.Bounds && m_ShopWindowVO.LimitCount > 0) { State.GetAction(UIAction.Shop_Buy).Enabled = false; } else { State.GetAction(UIAction.Shop_Buy).Enabled = true; } m_OpenShopParameter = new OpenShopParameter(); m_OpenShopParameter.OperateType = 0; m_OpenShopParameter.Tid = m_ShopWindowVO.Tid; m_OpenShopParameter.Id = m_ShopWindowVO.Oid; m_OpenShopParameter.MoneyType = m_ShopWindowVO.ShopItemConfig.Value.MoneyType; m_OpenShopParameter.Price = m_ShopWindowVO.ShopItemConfig.Value.BuyCost * m_ShopWindowVO.ShopItemConfig.Value.DisCount; m_OpenShopParameter.LimitCount = (int)m_ShopWindowVO.LimitCount; m_OpenShopParameter.Stock = (int)m_ShopWindowVO.ServerLeftNum; m_OpenShopParameter.Bounds = m_ShopWindowVO.ShopItemConfig.Value.Bounds; m_OpenShopParameter.Category = ItemTypeUtil.GetItemType(m_ShopWindowVO.ShopItemConfig.Value.ItemGood.Value.Type).MainType; } } else if (State.GetPageIndex() == 1) { ItemBase m_PackageItem = (ItemBase)cellData; NpcShopSellElementGrid m_SellElementGrid = cellView.GetOrAddComponent <NpcShopSellElementGrid>(); if (style == UIViewListLayout.Grid) { m_SellElementGrid.SetData(m_PackageItem, selected, false); } else { m_SellElementGrid.SetData(m_PackageItem, selected, true); } if (selected) { if (m_PackageItem.Replicas != null && m_PackageItem.Replicas.Count > 0) { State.GetAction(UIAction.Shop_Sell).Enabled = false; } else if (m_PackageItem.MainType == Category.Expendable) { State.GetAction(UIAction.Shop_Sell).Enabled = false; } else { State.GetAction(UIAction.Shop_Sell).Enabled = true; } m_OpenShopParameter = new OpenShopParameter(); m_OpenShopParameter.OperateType = 1; m_OpenShopParameter.Tid = m_PackageItem.TID; m_OpenShopParameter.Id = m_PackageItem.UID; if (m_PackageItem.ItemConfig.SellCurrency == 1100004) { m_OpenShopParameter.MoneyType = 1; } else { m_OpenShopParameter.MoneyType = 2; } m_OpenShopParameter.Price = (int)m_PackageItem.ItemConfig.MoneyPrice; m_OpenShopParameter.LimitCount = (int)m_PackageItem.Count; m_OpenShopParameter.Stock = (int)m_PackageItem.Count; m_OpenShopParameter.Bounds = 1; m_OpenShopParameter.Category = m_PackageItem.MainType; } } else { ShopSellBackVO m_SellBack = (ShopSellBackVO)cellData; CountDownCompent m_CountDownCompent = cellView.GetOrAddComponent <CountDownCompent>(); m_CountDownCompent.SetTime(m_SellBack.ExpireTime); NpcShopSellBackElementGrid m_SellElementGrid = cellView.GetOrAddComponent <NpcShopSellBackElementGrid>(); if (style == UIViewListLayout.Grid) { m_SellElementGrid.SetData(m_SellBack, false); } else { m_SellElementGrid.SetData(m_SellBack, true); } if (selected) { if (!m_SellElementGrid.MoneyeEnough()) { State.GetAction(UIAction.Shop_Buy).Enabled = false; } else { State.GetAction(UIAction.Shop_Buy).Enabled = true; } m_OpenShopParameter = new OpenShopParameter(); m_OpenShopParameter.OperateType = 2; m_OpenShopParameter.Tid = (uint)m_SellBack.Tid; m_OpenShopParameter.Id = m_SellBack.Uid; if (m_SellBack.ItemConfig.SellCurrency == 1100004) { m_OpenShopParameter.MoneyType = 1; } else { m_OpenShopParameter.MoneyType = 2; } m_OpenShopParameter.Price = m_SellBack.ItemConfig.BuybackPrice; m_OpenShopParameter.LimitCount = (int)m_SellBack.Num; m_OpenShopParameter.Stock = (int)m_SellBack.Num; m_OpenShopParameter.Bounds = 1; m_OpenShopParameter.Category = ItemTypeUtil.GetItemType(m_SellBack.ItemConfig.Type).MainType; } } }