local UIGuildAuctionList = UIViewClass() local fixedPriceDuration = DataSheetManager.ConstData:GetDataByID("AuctionBoughtBiddingCountdown").IntValue ------------------------------ 系統函數 ------------------------------------ function UIGuildAuctionList:OnOpened(context) self.curAuctionType = -1 self.curWorldAuctionType = -1 self.isExcuteTimer = false self.cacheItems = {} self:RegistSystemEvent(EventID.UI_GuildAuctionList_RefreshPanel, self.RefreshPanel) self:RefreshPanel(context) end function UIGuildAuctionList:OnUpdateFun() MDL.GuildAuction.RequestGuildAuctionItems(self.curAuctionType ~= -1 and self.curAuctionType) end function UIGuildAuctionList:OnButtonClicked(comp) if comp == self.btn_Close then self.clickedInfoIndex = nil UIUtils.SetActive(self.group_FrameInfo, false) end end function UIGuildAuctionList:OnCellInit(scrollRect, index, cellTable, auctionItem) if scrollRect == self.LoopScroll_Details then if self.clickedInfoIndex then UIUtils.SetActive(self.group_FrameInfo, true) end local auctionData = auctionItem.auctionData local itemData = auctionItem.itemData local isForbid, isJoin = MDL.GuildAuction.GetAuctionLimit() local startPrice, highestPrice, pacePrice, specialOfferInfo = MDL.GuildAuction.GetItemPrices(auctionItem) --region -----------------一口价相关处理------------------------------------------------- local isFixedPrice = auctionItem.isFixedPrice local involvedHeadCount = #auctionItem.fixedPriceAcids local fixedPriceRemainTime = isFixedPrice and auctionItem.fixedPriceTime + fixedPriceDuration - UTL.Time.GetServerTimestamp() or nil local isSelfInvolvedHead = CTL.GuildAuction.IsItemFixedPriceSelfInvolved(auctionItem.fixedPriceAcids) if startPrice < 0 then UIUtils.SetActive(cellTable.group_PresentPrice, false) -- 起拍价小于0表示只有一口价 else UIUtils.SetActive(cellTable.group_PresentPrice, not isFixedPrice) end UIUtils.SetActive(cellTable.group_Time, not isFixedPrice) UIUtils.SetActive(cellTable.group_TimeCrossServer, isFixedPrice) UIUtils.SetLabel(cellTable.txt_fixPriceInfo, string.FormatByIdsId(Const_IDS["IDS_Auction_BiddingDesc1"], fixedPriceRemainTime and UTL.Time.FormatTimeSeconds(fixedPriceRemainTime))) UIUtils.SetLabel(cellTable.txt_headCount, string.FormatByIdsId(Const_IDS["IDS_Auction_BiddingDesc2"], involvedHeadCount)) UIUtils.SetActive(cellTable.btn_ItemServerList, auctionItem.zoneType and auctionItem.zoneType > 0) -- 显示折扣 if specialOfferInfo > 0 then UIUtils.SetActive(cellTable.group_Off, true) UIUtils.SetLabel(cellTable.txt_Off, string.format("-%d%%", specialOfferInfo * 100)) else UIUtils.SetActive(cellTable.group_Off, false) end --endregion local consumeItemData = DataSheetManager.ItemData:GetDataByID(auctionData.AuctionCoin) UTL.Item.SetAtlasSprite(cellTable.icon_Currency_Start, "UI_Common", consumeItemData.Icon) UTL.Item.SetAtlasSprite(cellTable.icon_Currency_Fixed, "UI_Common", consumeItemData.Icon) self:SetCacheItem(cellTable.Item, itemData.ID, auctionData.ItemNum) UIUtils.SetLabel(cellTable.txt_ItemName, auctionItem.itemName) UIUtils.SetActive(cellTable.group_Auction, false) UIUtils.SetActive(cellTable.group_Lead, false) if auctionItem.isOnSale and auctionItem.curPrice > 0 then UIUtils.SetActive(cellTable.group_Auction, auctionItem.ownerAcid ~= BattleDataGetter.GetAcID() or isFixedPrice) UIUtils.SetActive(cellTable.group_Lead, auctionItem.ownerAcid == BattleDataGetter.GetAcID() and not isFixedPrice) end local remainSeconds = auctionItem.endTime - UTL.Time.GetServerTimestamp() local timeStr = remainSeconds > 0 and UTL.Time.FormatTimeClockBySeconds(remainSeconds) or UTL.Time.FormatTimeClockBySeconds(0) UIUtils.SetLabel(cellTable.txt_Date, timeStr) UIUtils.SetActive(cellTable.txt_Time, remainSeconds > 0) UIUtils.SetLabelText(cellTable.txt_Time, auctionItem.isOnSale and Const_IDS["IDS_Auction_BiddingEndTime"] or Const_IDS["IDS_Auction_BiddingStartTime"]) UIUtils.SetLabel(cellTable.txt_CurPrice, auctionItem.curPrice > 0 and auctionItem.curPrice + pacePrice or startPrice) UIUtils.SetLabel(cellTable.txt_FixedPrice, highestPrice) UIUtils.SetActive(cellTable.icon_Heart, not isForbid) UIUtils.SetActive(cellTable.icon_HeartEmpty, not isForbid) UIUtils.SetActive(cellTable.btn_Auction, not isForbid) UIUtils.SetActive(cellTable.btn_FixedPrice, not isForbid) if not isForbid then UIUtils.SetActive(cellTable.icon_Heart, auctionItem.isCollect == true) UIUtils.SetActive(cellTable.icon_HeartEmpty, auctionItem.isCollect == false) cellTable.btn_Auction:SetGray(not auctionItem.isOnSale or auctionItem.ownerAcid == BattleDataGetter.GetAcID(), true) cellTable.btn_FixedPrice:SetGray(not auctionItem.isOnSale or isSelfInvolvedHead, true) end end end function UIGuildAuctionList:OnCellClicked(scrollRect, index, cellTable, target, auctionItem) if scrollRect == self.LoopScroll_Details then local isForbid, isJoin = MDL.GuildAuction.GetAuctionLimit() if target == cellTable.icon_HeartEmpty then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_AddToFavouriteListSucceed"], auctionItem.itemName) MDL.GuildAuction.RequestCollect(auctionItem.auctionId, auctionItem.houseType) elseif target == cellTable.icon_Heart then if auctionItem.ownerAcid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_FavouriteListCannotCancel"]) CTL.Sound.PlayGameSound("UI_invalid") return end CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_RemoveFromFavouriteListSucceed"], auctionItem.itemName) MDL.GuildAuction.RequestCancelCollect(auctionItem.auctionId) elseif target == cellTable.btn_Auction then if isForbid then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_CannotBiddingIntro"]) CTL.Sound.PlayGameSound("UI_invalid") return end if not auctionItem.isOnSale then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_BidNotOpen"]) CTL.Sound.PlayGameSound("UI_invalid") return end if auctionItem.ownerAcid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_WinnerCanNotBid"]) CTL.Sound.PlayGameSound("UI_invalid") return end CTL.GuildAuction.RequestAunctionItem(auctionItem) elseif target == cellTable.btn_FixedPrice then if isForbid then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_CannotBiddingIntro"]) CTL.Sound.PlayGameSound("UI_invalid") return end if not auctionItem.isOnSale then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Auction_BidNotOpen"]) CTL.Sound.PlayGameSound("UI_invalid") return end local isSelfInvolvedHead = CTL.GuildAuction.IsItemFixedPriceSelfInvolved(auctionItem.fixedPriceAcids) if isSelfInvolvedHead then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Auction_AlreadyBidding"], auctionItem.itemName)) CTL.Sound.PlayGameSound("UI_invalid") return end CTL.GuildAuction.RequestBuyImmediately(auctionItem) elseif target == cellTable.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(auctionItem.itemData.ID) elseif target == cellTable.btn_Info then self.clickedInfoIndex = index UIUtils.SetActive(self.group_FrameInfo, true) self.group_FrameInfo.gameObject.transform:SetPosition(cellTable.group_Time.transform.position.x + 0.2, target.transform.position.y - 0.2, 0) elseif target == cellTable.btn_ItemServerList then if auctionItem.zoneType then local context = { serverList = MDL.GuildAuction.GetServerListByAuctionZoneType(auctionItem.zoneType), pos = cellTable.group_Left.transform.position, index = index } self.serverListTip_Canvas:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildAuctionServerListTips), context) end end end end ------------------------------------------------------------------------------- function UIGuildAuctionList:RefreshPanel(params) local isChange = params.auctionType ~= self.curAuctionType or params.worldAuctionType ~= self.curWorldAuctionType self.curAuctionType = params.auctionType self.curWorldAuctionType = params.worldAuctionType if isChange then if self.isExcuteTimer then self:StopRepeatFunc(self.OnUpdateFun) self.isExcuteTimer = false end self.clickedInfoIndex = nil self.LoopScroll_Details:ClearCells() MDL.GuildAuction.RequestGuildAuctionItems(self.curAuctionType, self.curWorldAuctionType) else local auctionItems = MDL.GuildAuction.GetAuctionItemsByType(self.curAuctionType) if auctionItems and #auctionItems > 0 then self.LoopScroll_Details:ReloadAll(auctionItems) else self.LoopScroll_Details:ClearCells() end if not self.isExcuteTimer then self:StartRepeatFunc(self.OnUpdateFun, 1) self.isExcuteTimer = true end end UIUtils.SetActive(self.group_Empty, self.LoopScroll_Details.Count == 0) end function UIGuildAuctionList:OnCellDispose(scrollRect, index, cellTable) self.cacheItems[cellTable.Item] = nil end --这里根据celltable里的item模板节点做key 缓存 id 如果下次刷新时 id 和item能一一对应上 就不用重新设置item图片 特效 --只需要设置数量这种有变化的 解决刷新时特效重新播放 会闪一下的问题 --热更思路特效会随cell一起进池子但是没有停止播放特效 下回从池子那来回 item和id还能对应上 特效不,重新播放 --换包更新思路cell回收时特效会停止播放并且回收 然后self.cacheItems要删除这个item的缓存 下回从池子回来 重新设置item function UIGuildAuctionList:SetCacheItem(item, id, count) if self.cacheItems[item] == id then UTL.Item.SetItemCount(item, count) else UTL.Item.SetItemCell(item, id, count) self.cacheItems[item] = id end end return UIGuildAuctionList