diff --git a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua index 06f02345b9..eb45da4b2c 100644 --- a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua +++ b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua @@ -1012,6 +1012,7 @@ JumpType = { ZhuTiHuoDong = 20000, QianKunShangDian = 20044, --乾坤商店 SheJiDaDianShangDian = 20060, --社稷大典商店 + XinJiangLaiXiShangDian = 20200, --社稷大典商店 } YaoHunFrame = { --[6] = "r_tongyong_yaohunkuang002", diff --git a/Assets/ManagedResources/~Lua/Modules/DynamicActivity/QianKunBox.lua b/Assets/ManagedResources/~Lua/Modules/DynamicActivity/QianKunBox.lua index ee3af5f583..27a7f79052 100644 --- a/Assets/ManagedResources/~Lua/Modules/DynamicActivity/QianKunBox.lua +++ b/Assets/ManagedResources/~Lua/Modules/DynamicActivity/QianKunBox.lua @@ -161,7 +161,7 @@ function QianKunBox:refreshBtnShow() Util.AddOnceClick(m.btn,function() if not isFree then - if BagManager.GetItemCountById(itemId) 0 then + if self.allData.buyTime > 0 then local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP,10036, 1) local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name MsgPanel.ShowTwo(string.format( Language[10516],finalNum,GetLanguageStrById(itemName)), nil, function() @@ -53,7 +51,7 @@ function XinJiangLaiXi:BindEvent() ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,10036,1,function() PopupTipPanel.ShowTip(Language[10517]) PrivilegeManager.RefreshPrivilegeUsedTimes(2013, 1)--更新特权 - XinJiangLaiXi:Refresh() + self:Refresh() end) end) else @@ -63,19 +61,19 @@ function XinJiangLaiXi:BindEvent() Util.AddClick(self.fightBtn,function() --开始战斗 - if allData.fightTime > 0 then - NetManager.NewGeneralAttackRequest(allData.activityId,2012,function(msg) + if self.allData.fightTime > 0 then + NetManager.NewGeneralAttackRequest(self.allData.activityId,2012,function(msg) PrivilegeManager.RefreshPrivilegeUsedTimes(2012, 1)--更新特权 local fightData = BattleManager.GetBattleServerData(msg,0) UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.XINJIANG,function () UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1,function () - this:Refresh() + self:Refresh() end) end) end) else --购买特权 - if allData.buyTime > 0 then + if self.allData.buyTime > 0 then local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP,10036, 1) local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name MsgPanel.ShowTwo(string.format( Language[10516],finalNum,itemName), nil, function() @@ -83,7 +81,7 @@ function XinJiangLaiXi:BindEvent() ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,10036,1,function() PopupTipPanel.ShowTip(Language[10517]) PrivilegeManager.RefreshPrivilegeUsedTimes(2013, 1)--更新特权 - XinJiangLaiXi:Refresh() + self:Refresh() end) end) else @@ -93,20 +91,7 @@ function XinJiangLaiXi:BindEvent() end) Util.AddClick(self.storeBtn,function() - self.shop:SetActive(true) - self.btnBack:SetActive(false) - self.tabList:SetActive(false) - self.bottomBar:SetActive(false) - this:StoreShow()--商店 - end) - - Util.AddClick(self.shopBack,function() - self.shop:SetActive(false) - self.btnBack:SetActive(true) - self.tabList:SetActive(true) - self.bottomBar:SetActive(true) - parent.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main }) - XinJiangLaiXi:Refresh() + JumpManager.GoJump(40019) end) end @@ -119,55 +104,56 @@ function XinJiangLaiXi:RemoveListener() end --界面打开时调用(用于子类重写) -function XinJiangLaiXi:OnOpen() - +function XinJiangLaiXi:OnOpen(_activityConfig,_index,parent) + self.actConfig = _activityConfig + self.pageIndex = _index + self.parent = parent end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function XinJiangLaiXi:OnShow(_sortingOrder,_parent) local actId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.XinJiangLaiXi) if not actId or actId <= 0 then return end - parent = _parent sortingOrder = _sortingOrder XinJiangLaiXi:Refresh() end function XinJiangLaiXi:Refresh() CheckRedPointStatus(RedPointType.XinJiangLaiXi) - allData = DynamicActivityManager.XinJiangBuildData() + self.allData = DynamicActivityManager.XinJiangBuildData() XinJiangLaiXi:OnShowData() XinJiangLaiXi:SetTime() end function XinJiangLaiXi:OnShowData() self.shop:SetActive(false) - if not itemsGrid then - itemsGrid = {} + if not self.itemsGrid then + self.itemsGrid = {} end - for k,v in ipairs(itemsGrid) do + for k,v in ipairs(self.itemsGrid) do v.gameObject:SetActive(false) end - for i = 1,#allData.reward do - if not itemsGrid[i] then - itemsGrid[i] = SubUIManager.Open(SubUIConfig.ItemView,self.scrollItem.transform) + for i = 1,#self.allData.reward do + if not self.itemsGrid[i] then + self.itemsGrid[i] = SubUIManager.Open(SubUIConfig.ItemView,self.scrollItem.transform) end - itemsGrid[i].gameObject:SetActive(true) - itemsGrid[i]:OnOpen(false, allData.reward[i], 1,false,false,false,sortingOrder) + self.itemsGrid[i].gameObject:SetActive(true) + self.itemsGrid[i]:OnOpen(false, self.allData.reward[i], 1,false,false,false,sortingOrder) end if self.LiveObj then poolManager:UnLoadLive(self.LiveObj.name,self.LiveObj) self.LiveObj = nil end - local configData = ConfigManager.GetConfigData(ConfigName.NewHeroConfig,allData.activityId) + local configData = ConfigManager.GetConfigData(ConfigName.NewHeroConfig,self.allData.activityId) local HeroId = configData.HeroId local imgName = GetResourcePath(ConfigManager.GetConfigData(ConfigName.HeroConfig,HeroId).Live) self.LiveObj = poolManager:LoadLive(imgName,self.liveRoot.transform, Vector3.one*configData.Size[1], Vector2.New(configData.Size[2],configData.Size[3])) - self.tip1.text = Language[10520]..""..allData.fightTime.."" - self.tip2.text = Language[10521]..""..allData.buyTime.."" - self.money.text = allData.money + self.tip1.text = Language[10520]..""..self.allData.fightTime.."" + self.tip2.text = Language[10521]..""..self.allData.buyTime.."" + self.money.text = self.allData.money end function XinJiangLaiXi:SetTime() @@ -175,14 +161,14 @@ function XinJiangLaiXi:SetTime() self.timer:Stop() self.timer = nil end - local timeDown = allData.endTime - GetTimeStamp() + local timeDown = self.allData.endTime - GetTimeStamp() self.time.text = Language[10470]..TimeToFelaxible(timeDown) self.timer = Timer.New(function() timeDown = timeDown - 1 if timeDown < 1 then self.timer:Stop() self.timer = nil - parent:ClosePanel() + self.parent:ClosePanel() return end self.time.text = Language[10470]..TimeToFelaxible(timeDown) @@ -195,15 +181,6 @@ function XinJiangLaiXi:OnOpen() end ---商店 -function XinJiangLaiXi:StoreShow() - if not self.shopView then - self.shopView = SubUIManager.Open(SubUIConfig.ShopView, self.content.transform) - end - self.shopView:ShowShop(SHOP_TYPE.XINJIANG_SHOP,sortingOrder) - parent.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.XinJiangLaiXi }) -end - function XinJiangLaiXi:OnClose() end @@ -219,7 +196,7 @@ function XinJiangLaiXi:OnDestroy() self.LiveObj = nil end sortingOrder = 0 - itemsGrid = {} + self.itemsGrid = {} end function XinJiangLaiXi:OnHide() diff --git a/Assets/ManagedResources/~Lua/Modules/DynamicActivity/YiJingBaoKu.lua b/Assets/ManagedResources/~Lua/Modules/DynamicActivity/YiJingBaoKu.lua index e899128f34..417ac0a728 100644 --- a/Assets/ManagedResources/~Lua/Modules/DynamicActivity/YiJingBaoKu.lua +++ b/Assets/ManagedResources/~Lua/Modules/DynamicActivity/YiJingBaoKu.lua @@ -224,7 +224,7 @@ function YiJingBaoKu:AddBackToFrontClick() else Util.GetGameObject(self._itemsList[18],"front"):GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0, 0, 0)) end - YiJingBaoKu:Refresh() + self:Refresh() end end) end) diff --git a/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_RecrutDetail.lua b/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_RecrutDetail.lua index d8670b0a8c..90e368e758 100644 --- a/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_RecrutDetail.lua +++ b/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_RecrutDetail.lua @@ -50,7 +50,7 @@ function this:OnShow(_parent,...) sortingOrder = _parent.sortingOrder local args = {...} local helpType = args[1] - local str=ConfigManager.TryGetConfigData(ConfigName.QAConfig,helpType).content + local str = ConfigManager.TryGetConfigData(ConfigName.QAConfig,helpType).content str = string.gsub(str,"{","") str = string.gsub(str,"}","") str = string.gsub(str,"|","\n")--换行 @@ -60,45 +60,58 @@ function this:OnShow(_parent,...) local str2 = ActivityGiftManager.GetTimeStartToEnd(activityType) this.time.text="概率有效期:"..str2 - local poolUpType = args[3] + local poolUpType = args[3] or 0 local poolType = args[4] or 0 + LogGreen("poolUpType:"..poolUpType.." poolType:"..poolType) local UpItemList=RecruitManager.GetRewardPreviewData(poolUpType) local itemList = RecruitManager.GetRewardPreviewData(poolType) - local rateList = this:BuildRateData(activityType,itemList,UpItemList) - this:ReFreshUpItem(UpItemList,rateList) + local _upRateList,rateList = this:BuildRateData(activityType,itemList,UpItemList) + this:ReFreshUpItem(UpItemList,_upRateList) end function this:ReFreshUpItem(UpItem,rateList) - local rewardData,showData,curScore = DynamicActivityManager.RecrutDetailData(activityType) if(not this.listUpPre) then this.listUpPre={} end for k,v in ipairs(this.listUpPre) do v.gameObject:SetActive(false) end + local index = 0 for n,m in ipairs(UpItem) do - if m then - if not this.listUpPre[n] then - this.listUpPre[n] = SubUIManager.Open(SubUIConfig.ItemView,this.itemGrid.transform) + for k,v in ipairs(rateList) do + if m.Reward[1] == v.id then + index = index + 1 + if not this.listUpPre[index] then + this.listUpPre[index] = SubUIManager.Open(SubUIConfig.ItemView,this.itemGrid.transform) + end + this.listUpPre[index]:OnOpen(false, {m.Reward[1], m.Reward[2]}, 1.1, true) + this.listUpPre[index].name:GetComponent("Text").text=""..string.format("%.2f", (v.value/100000)*100) .."%" + this.listUpPre[index].gameObject:SetActive(true) end - this.listUpPre[n]:OnOpen(false, {m.Reward[1], m.Reward[2]}, 1.1, true) - this.listUpPre[n].name:GetComponent("Text").text=""..string.format("%.2f", (rateList[n].value/100000)*100) .."%" - this.listUpPre[n].gameObject:SetActive(true) end end end function this:BuildRateData(actType,UpItem,upItemList) local rateList = {} - local _rateList = {} + local _upRateList = {} if actType == ActivityTypeDef.FindFairy then - _rateList = this:ReculateUpHeroRate(UpItem,upItemList,"5星UP!",ConfigName.HeroConfig) - rateList = this:RefreshHeroRate(UpItem,_rateList) + _upRateList = this:ReculateUpHeroRate(UpItem,upItemList,"5星UP!",ConfigName.HeroConfig) + rateList = this:RefreshHeroRate(UpItem,_upRateList) elseif actType == ActivityTypeDef.QianKunBox then - _rateList = this:ReculateUpHeroRate(UpItem,upItemList,"魂印UP!",ConfigName.EquipConfig) - rateList = this:RefreshSoulRate(UpItem,_rateList) + _upRateList = this:ReculateUpHeroRate(UpItem,upItemList,"魂印UP!",ConfigName.EquipConfig) + rateList = this:RefreshSoulRate(UpItem,_upRateList) elseif actType == ActivityTypeDef.LingShouBaoGe then - rateList = this:RefreshMonsterRate(UpItem,upItemList,"灵兽UP!",ConfigName.SpiritAnimal) + local rewardData,showData,curScore = DynamicActivityManager.RecrutDetailData(activityType) + for n,m in ipairs(upItemList) do + if m and m.Reward[1] == showData.monsterId then + local _config = ConfigManager.GetConfigData(ConfigName.SpiritAnimal,m.Reward[1]) + local readingName = _config.ReadingName or _config.Name + table.insert(_upRateList,{id = m.Reward[1],tag="灵兽UP!",name = readingName,value = m.Weight}) + break + end + end + rateList = this:RefreshMonsterRate(upItemList,_upRateList) elseif actType == ActivityTypeDef.XiangYaoDuoBao then rateList = this:RefreshNewHeroRate(UpItem,upItemList,"5星UP!",ConfigName.HeroConfig) end @@ -121,7 +134,7 @@ function this:BuildRateData(actType,UpItem,upItemList) this.ratePreList[n].rate.text=string.format("%.2f",(m.value/100000)*100).."%" end - return rateList + return _upRateList,rateList end --通用计算权重功能 @@ -140,7 +153,7 @@ function this:ReculateUpHeroRate(itemList,UpItemList,_tag,config) if v.Reward[1] == m.Reward[1] then local _config = ConfigManager.GetConfigData(config,v.Reward[1]) local readingName = _config.ReadingName or _config.Name - table.insert(rateList,{tag=_tag,name = readingName,value = m.Weight}) + table.insert(rateList,{id = m.Reward[1],tag=_tag,name = readingName,value = m.Weight}) break end end @@ -165,15 +178,17 @@ function this:RefreshHeroRate(hero,_rateList) table.insert(list2,v) end end + local rateList = {} local valueList5 = this:ReculateRate(list5) for i = 1 , #_rateList do valueList5 = valueList5 - _rateList[i].value + table.insert(rateList,_rateList[i]) end - table.insert(_rateList,{tag="5星",name="其他5星",value = valueList5}) - table.insert(_rateList,{tag="4星",name="4星神将",value = this:ReculateRate(list4)}) - table.insert(_rateList,{tag="3星",name="3星神将",value = this:ReculateRate(list3)}) - table.insert(_rateList,{tag="2星",name="2星神将",value = this:ReculateRate(list2)}) - return _rateList + table.insert(rateList,{tag="5星",name="其他5星",value = valueList5}) + table.insert(rateList,{tag="4星",name="4星神将",value = this:ReculateRate(list4)}) + table.insert(rateList,{tag="3星",name="3星神将",value = this:ReculateRate(list3)}) + table.insert(rateList,{tag="2星",name="2星神将",value = this:ReculateRate(list2)}) + return rateList end function this:RefreshSoulRate(soul,_rateList) @@ -193,22 +208,23 @@ function this:RefreshSoulRate(soul,_rateList) table.insert(list7,v)--其他 end end + local rateList = {} local valueList6 = this:ReculateRate(list6) for i = 1 , #_rateList do valueList6 = valueList6 - _rateList[i].value + table.insert(rateList,_rateList[i]) end - table.insert(_rateList,{tag="红色",name="其他".."红色",value = valueList6}) - table.insert(_rateList,{tag="金色",name="金色",value=this:ReculateRate(list5)}) - table.insert(_rateList,{tag="紫色",name="紫色",value=this:ReculateRate(list4)}) - table.insert(_rateList,{tag="其他",name="其他",value=this:ReculateRate(list7)}) - return _rateList + table.insert(rateList,{tag="红色",name="其他".."红色",value = valueList6}) + table.insert(rateList,{tag="金色",name="金色",value=this:ReculateRate(list5)}) + table.insert(rateList,{tag="紫色",name="紫色",value=this:ReculateRate(list4)}) + table.insert(rateList,{tag="其他",name="其他",value=this:ReculateRate(list7)}) + return rateList end function this:RefreshMonsterRate(UpMonster,_rateList) local list1={} local list2={} local list3={} local list4={} - for index, v in ipairs(UpMonster) do if itemConfig[v.Reward[1]].Quantity==5 and (itemConfig[v.Reward[1]].ItemType==22 or itemConfig[v.Reward[1]].ItemType==21) then table.insert(list1,v)--金色灵兽碎片 @@ -220,15 +236,17 @@ function this:RefreshMonsterRate(UpMonster,_rateList) table.insert(list4,v)--其他 end end + local rateList = {} local valueList1 = this:ReculateRate(list1) for i = 1 , #_rateList do valueList1 = valueList1 - _rateList[i].value + table.insert(rateList,_rateList[i]) end - table.insert(_rateList,{tag="金色",name="其他金色奖励",value=valueList1}) - table.insert(_rateList,{tag="紫色",name="紫色奖励",value=this:ReculateRate(list2)}) - table.insert(_rateList,{tag="蓝色",name="蓝色奖励",value=this:ReculateRate(list3)}) - table.insert(_rateList,{tag="其他",name="其他",value=this:ReculateRate(list4)}) - return _rateList + table.insert(rateList,{tag="金色",name="金色灵兽或碎片",value=valueList1}) + table.insert(rateList,{tag="紫色",name="紫色灵兽或碎片",value=this:ReculateRate(list2)}) + table.insert(rateList,{tag="蓝色",name="蓝色灵兽或碎片",value=this:ReculateRate(list3)}) + table.insert(rateList,{tag="其他",name="其他奖励",value=this:ReculateRate(list4)}) + return rateList end function this:RefreshNewHeroRate(UpMonster,_rateList) diff --git a/Assets/ManagedResources/~Lua/Modules/Player/JumpManager.lua b/Assets/ManagedResources/~Lua/Modules/Player/JumpManager.lua index 49f121de72..1c800be77a 100644 --- a/Assets/ManagedResources/~Lua/Modules/Player/JumpManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Player/JumpManager.lua @@ -651,7 +651,11 @@ local jumpDic = { end, [JumpType.SheJiDaDianShangDian] = function (data) - this.JumpActivity(JumpType.QianKunShangDian,data[1]) + this.JumpActivity(JumpType.SheJiDaDianShangDian,data[1]) + end, + + [JumpType.XinJiangLaiXiShangDian] = function (data) + this.JumpActivity(JumpType.XinJiangLaiXiShangDian,data[1]) end, } diff --git a/Assets/ManagedResources/~Lua/Modules/Story/StoryMapManager.lua b/Assets/ManagedResources/~Lua/Modules/Story/StoryMapManager.lua index d8e1ff4cd3..3533726842 100644 --- a/Assets/ManagedResources/~Lua/Modules/Story/StoryMapManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Story/StoryMapManager.lua @@ -2,7 +2,7 @@ local this = StoryMapManager this.groupConfigs = {} this.isShowStory = 0 -local storyMapConfig = ConfigManager.GetConfig(ConfigName.StoryMapConfig) +--local storyMapConfig = ConfigManager.GetConfig(ConfigName.StoryMapConfig) --初始化 function this.Initialize() diff --git a/Assets/ManagedResources/~Lua/View/ShopViewNew.lua b/Assets/ManagedResources/~Lua/View/ShopViewNew.lua new file mode 100644 index 0000000000..07ab62aa36 --- /dev/null +++ b/Assets/ManagedResources/~Lua/View/ShopViewNew.lua @@ -0,0 +1,615 @@ + +local _ShopTypeConfig = ConfigManager.GetConfig(ConfigName.StoreTypeConfig) +-- 通用得商店逻辑 +local ShopView = {} +local sortingOrder = 0 +---===============================生命周期函数================================ +function ShopView:New(gameObject) + local b = {} + b.gameObject = gameObject + b.transform = gameObject.transform + setmetatable(b, { __index = ShopView }) + return b +end +--初始化组件(用于子类重写) +function ShopView:InitComponent() + self.live = Util.GetGameObject(self.gameObject, "live") + self.liveRoot = Util.GetGameObject(self.gameObject, "live/root") + self.liveImg = Util.GetGameObject(self.gameObject, "live/img") + + self.basePanel = Util.GetGameObject(self.gameObject, "base") + self.closeTimePanel = Util.GetGameObject(self.gameObject, "base/closeTime") + self.closeTimeLab = Util.GetGameObject(self.closeTimePanel, "timelab") + self.closeTime = Util.GetGameObject(self.closeTimePanel, "time") + self.refreshTimePanel = Util.GetGameObject(self.gameObject, "base/refreshTime") + self.refreshTimeLab = Util.GetGameObject(self.refreshTimePanel, "timelab") + self.refreshTime = Util.GetGameObject(self.refreshTimePanel, "time") + self.countTimePanel = Util.GetGameObject(self.gameObject, "base/countTime") + self.countTimeLab = Util.GetGameObject(self.countTimePanel, "timelab") + self.countTime = Util.GetGameObject(self.countTimePanel, "time") + self.refreshCountPanel = Util.GetGameObject(self.gameObject, "base/refreshCount") + self.countLabTip = Util.GetGameObject(self.refreshCountPanel, "GameObject/tip") + self.countLab = Util.GetGameObject(self.refreshCountPanel, "GameObject/count") + self.refreshBtnPanel = Util.GetGameObject(self.gameObject, "base/refreshBtn") + self.refreshBtn = Util.GetGameObject(self.refreshBtnPanel, "btn") + self.refreshRedpot = Util.GetGameObject(self.refreshBtnPanel, "redpot") + self.costIcon = Util.GetGameObject(self.refreshBtnPanel, "costIcon") + self.costLab = Util.GetGameObject(self.refreshBtnPanel, "costLab") + + self.contentBg = Util.GetGameObject(self.gameObject, "duihua") + self.content = Util.GetGameObject(self.gameObject, "duihua/Text") + + self.scrollBg = Util.GetGameObject(self.gameObject, "scrollbg") + self.scrollRoot = Util.GetGameObject(self.gameObject, "scrollbg/scrollroot") + self.scrollBg1 = Util.GetGameObject(self.gameObject, "scrollbg/bg1") + self.scrollBg2 = Util.GetGameObject(self.gameObject, "scrollbg/bg2") + self.scrollBg3 = Util.GetGameObject(self.gameObject, "scrollbg/bg3") + self.bottom = Util.GetGameObject(self.gameObject, "scrollbg/bottom") + self.tip = Util.GetGameObject(self.gameObject, "scrollbg/tip") + self.shopItem = Util.GetGameObject(self.gameObject, "scrollbg/scrollroot/shopItem") + self.rechargeShopItem = Util.GetGameObject(self.gameObject, "scrollbg/scrollroot/item") + self.titleBg = Util.GetGameObject(self.gameObject, "scrollbg/titlebg") + self.titleImg = Util.GetGameObject(self.gameObject, "scrollbg/titlebg/title") + self.helpBtn = Util.GetGameObject(self.gameObject, "scrollbg/titlebg/helpBtn")--scrollbg/titlebg/ + self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition + -- 创建循环列表 + if not self.ScrollView then + self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollRoot.transform, + self.shopItem, nil, Vector2.New(1000, 1024), 1, 3, Vector2.New(80, 0)) + self.ScrollView.moveTween.MomentumAmount = 1 + self.ScrollView.moveTween.Strength = 2 + end + + + -- 创建循环列表 + if not self.RechargeScrollView then + self.RechargeScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollRoot.transform, + self.rechargeShopItem, nil, Vector2.New(1000, 1024), 1, 3, Vector2.New(80, 0)) + self.RechargeScrollView.moveTween.MomentumAmount = 1 + self.RechargeScrollView.moveTween.Strength = 2 + self.RechargeScrollView.gameObject.transform.localPosition = Vector3.New(0, -20, 0) + self.RechargeScrollView.elastic = false + end + +end +--绑定事件(用于子类重写) +function ShopView:BindEvent() + Util.AddOnceClick(self.refreshBtn, function() + PlaySoundWithoutClick("UI_refresh") + local isPopUp = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. self.ShopType) + local currentTime = os.date("%Y%m%d", PlayerManager.serverTime) + local shopType = self.ShopType + local isAutoRecover = ShopManager.IsAutoRecoverCount(shopType) + if (isPopUp ~= currentTime) and not isAutoRecover then + local shopInfo = ShopManager.GetShopInfoByType(shopType) + local costId, abcd = shopInfo.RefreshItem[1][1], shopInfo.RefreshItem[2] + local refreshNum = PrivilegeManager.GetPrivilegeUsedTimes(shopInfo.RefreshPrivilege) + local costNum = CalculateCostCount(refreshNum, abcd) + local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) + local costName = itemConfig[costId].Name + local str = string.format("是否花费%d%s刷新商店", costNum, costName) + MsgPanel.ShowTwo(str, function() + end, function(isShow) + if (isShow) then + local currentTime = os.date("%Y%m%d", PlayerManager.serverTime) + RedPointManager.PlayerPrefsSetStr(PlayerManager.uid .. self.ShopType, currentTime) + end + ShopManager.RequestRefreshShop(shopType, false) + end, "取消", "确定",nil,true) + else + ShopManager.RequestRefreshShop(self.ShopType, false) + end + + -- 重置商店刷新按钮点击状态 + ShopManager.SetShopRefreshBtnClickStatus(self.ShopType, true) + end) + --帮助按钮 + Util.AddOnceClick(ShopView.helpBtn, function() + if self.ShopConfig.HelpId==0 then + return + end + UIManager.OpenPanel(UIName.HelpPopup, self.ShopConfig.HelpId , ShopView.helpPosition.x,ShopView.helpPosition.y+372)--因层级锚点原因,需手动调整高度 + end) +end + +--界面打开时调用(用于子类重写) +function ShopView:OnOpen(_activityConfig,_index,parent) + self.actConfig = _activityConfig + self.pageIndex = _index + self.parent = parent +end + +function ShopView:OnShow(_sortingOrder) + self.gameObject:SetActive(true) + sortingOrder = _sortingOrder + self.actId = self.actConfig.ActId + self.actType = self.actConfig.ActiveType > 0 and self.actConfig.ActiveType or self.actConfig.FunType + if self.actConfig.IfBack == 1 then + if self.actConfig.ActiveType > 0 then + local id = ActivityGiftManager.IsActivityTypeOpen(self.actConfig.ActiveType) + LogGreen("id:"..id) + if id and id > 0 then + self.actId = id + local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups,"PageType",self.actConfig.PageType,"ActiveType",self.actConfig.ActiveType,"ActId",id) + if config then + self.actConfig = config + end + end + end + end + self.ShopType = self.actConfig.ShopData[1][1] + self:ShowShop() +end + +-- 设置要显示的商店类型 +function ShopView:ShowShop() + self.ScrollView:ForeachItemGO(function (index, go) + go.gameObject:SetActive(false) + end) + -- 红点销毁 + self.refreshRedpot:SetActive(false) + self.ShopId = ShopManager.GetShopDataByType(self.ShopType).id + self.ShopConfig = _ShopTypeConfig[self.ShopId] + -- 显示帮助按钮 + self.helpBtn:SetActive(self.ShopConfig.HelpId ~= 0) + self:RefreshShopInfo(false, true) + -- 设置tip显隐 + local isSSSHop = self.ShopType == SHOP_TYPE.SOUL_STONE_SHOP + self.scrollBg1:SetActive(not isSSSHop) + self.scrollBg2:SetActive(not isSSSHop) + self.titleBg:SetActive(not isSSSHop) + self.bottom:SetActive(not isSSSHop) + self.scrollBg3:SetActive(isSSSHop) + self.tip:SetActive(isSSSHop) +end +-- 刷新商店内容显示 +function ShopView:RefreshShopInfo(isRefresh, isTop) + if self.ShopType == SHOP_TYPE.SOUL_STONE_SHOP then + self.RechargeShopData = OperatingManager.GetGiftGoodsInfoList(GoodsTypeDef.DemonCrystal) + else + self.ShopData = ShopManager.GetShopDataByType(self.ShopType) + end + + self:RefreshLive() + self:RefreshBase() + self:RefreshItemList(isTop) + + -- 刷新商店的查看时间 + ShopManager.RefreshShopCheckTime(self.ShopType) + + if isRefresh then + -- 物品节点播放特效 + if self._GoodsItemList then + for _, item in pairs(self._GoodsItemList) do + item:OnShowUIeffectItemViewSaoguang() + end + end + end +end + +-- 刷新立绘显示 +function ShopView:RefreshLive() + if not self.ShopConfig.LiveName or self.ShopConfig.LiveName == "" then + self.live:SetActive(false) + return + end + self.live:SetActive(true) + self.liveImg:SetActive(false) + self.liveRoot:SetActive(false) + -- 立绘 + --TODO:动态加载立绘 + self.liveRoot:SetActive(true) + + if self.liveNode then + poolManager:UnLoadLive(self.LiveName, self.liveNode) + end + local scale = self.ShopConfig.LiveScale + scale = Vector3.New(scale[1], scale[2], scale[3]) + + local livePos = Vector3.zero + if self.ShopConfig.LivePos then + livePos.x = self.ShopConfig.LivePos[1] + livePos.y = self.ShopConfig.LivePos[2] + end + + self.LiveName = self.ShopConfig.LiveName + self.liveNode = poolManager:LoadLive(self.ShopConfig.LiveName, self.liveRoot.transform, scale, livePos) + local SkeletonGraphic = self.liveNode:GetComponent("SkeletonGraphic") + local idle = function() + SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) + end + SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) + SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle + poolManager:SetLiveClearCall(self.ShopConfig.LiveName, self.liveNode, function() + SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idle + end) +end + +-- 刷新时间及刷新按钮 +function ShopView:RefreshBase() + -- 自动刷新时间倒计时 + local leftTime = ShopManager.GetShopRefreshLeftTime(self.ShopType) + self.isShowRefreshTime = leftTime >= 0 + self.refreshTimePanel:SetActive(self.isShowRefreshTime) + -- 商店关闭时间倒计时 + local closeTime = ShopManager.GetShopCloseTime(self.ShopType) + self.isShowCloseTime = closeTime >= 0 and not self.isShowRefreshTime + self.closeTimePanel:SetActive(self.isShowCloseTime) + if self.isShowCloseTime then + if self.ShopType == SHOP_TYPE.ARENA_SHOP or self.ShopType == SHOP_TYPE.TOP_MATCH_SHOP then + self.closeTimeLab:GetComponent("Text").text = "距离刷新:" + else + self.closeTimeLab:GetComponent("Text").text = "距离商人离开:" + end + end + -- 次数恢复时间 + local countTime = ShopManager.GetShopRefreshCountRecoverTime(self.ShopType) + self.isShowCountTime = countTime >= 0 + self.countTimePanel:SetActive(self.isShowCountTime) + --开始倒计时 + self:StartTimeCount() + + -- 主动刷新按钮 + local leftCount = ShopManager.GetShopLeftRefreshCount(self.ShopType) + if leftCount == -2 then + -- 不支持刷新 + self.refreshCountPanel:SetActive(false) + self.refreshBtnPanel:SetActive(false) + else + self.refreshBtnPanel:SetActive(true) + if leftCount == -1 then + -- 无限制次数刷新 + self.refreshCountPanel:SetActive(false) + elseif leftCount >= 0 then + -- 限制次数刷新 + self.refreshCountPanel:SetActive(true) + self.countLab:GetComponent("Text").text = leftCount + end + + local isAutoRecover = ShopManager.IsAutoRecoverCount(self.ShopType) + if isAutoRecover then + self.costIcon:SetActive(false) + self.costLab:SetActive(false) + self.countLabTip:GetComponent("Text").text = "(剩余免费刷新 次)" + self.isMaxTime = false + else + self.costIcon:SetActive(true) + self.costLab:SetActive(true) + self.countLabTip:GetComponent("Text").text = "(剩余可用刷新 次)" + -- 刷新物品计算 + local shopInfo = ShopManager.GetShopInfoByType(self.ShopType) + local costId, abcd = shopInfo.RefreshItem[1][1], shopInfo.RefreshItem[2] + self.costIcon:GetComponent("Image").sprite = SetIcon(costId) + -- 商店特权正确性检测 + if not shopInfo.RefreshPrivilege or shopInfo.RefreshPrivilege == 0 then + Log("错误:商店类型 == " .. self.ShopType .. "商店支持手动刷新,但是未配置刷新次数对应的特权id(无限制次数也需要配置特权id)请检查") + end + local refreshNum = PrivilegeManager.GetPrivilegeUsedTimes(shopInfo.RefreshPrivilege) + self.costLab:GetComponent("Text").text = "×" .. CalculateCostCount(refreshNum, abcd) + end + end + + -- 商店标题 + if self.ShopConfig.Title and self.ShopConfig.Title ~= "" then + self.titleImg:GetComponent("Image").sprite = Util.LoadSprite(self.ShopConfig.Title) + end + self.contentBg:SetActive(false) +end + +-- 开始倒计时 +function ShopView:StartTimeCount() + local self = self + local function _TimeUpdate() + -- 检测计时器是否已销毁,避免计时器销毁后仍然会执行一次,导致报错的问题 + if not self._TimeCounter then + return + end + -- 刷新时间 + if self.isShowRefreshTime then + local refreshTime = ShopManager.GetShopRefreshLeftTime(self.ShopType) + if refreshTime >= 0 then + self.refreshTime:GetComponent("Text").text = TimeToHMS(refreshTime) + end + end + -- 关闭时间 + if self.isShowCloseTime then + local closeTime = ShopManager.GetShopCloseTime(self.ShopType) + if closeTime >= 0 then + local timeStr = "" + -- if self.ShopType == SHOP_TYPE.ACTIVITY_SHOP then + -- timeStr = TimeToDHMS(closeTime) + -- else + timeStr = TimeToHMS(closeTime) + -- end + self.closeTime:GetComponent("Text").text = timeStr + end + end + -- 次数恢复时间 + if self.isShowCountTime then + local refreshTime = ShopManager.GetShopRefreshCountRecoverTime(self.ShopType) + local maxTime = ShopManager.GetMaxRefreshCount(self.ShopType) + local isAutoRecover, leftTime = ShopManager.IsAutoRecoverCount(self.ShopType) + if refreshTime > 0 then + self.countTime:GetComponent("Text").text = TimeToHMS(refreshTime) + elseif isAutoRecover and maxTime == leftTime and not self.isMaxTime then + -- self:RefreshBase() + self.countTime:GetComponent("Text").text = "次数已满" + self.countLabTip:GetComponent("Text").text = "(剩余免费刷新 次)" + self.countLab:GetComponent("Text").text = leftTime + self.isMaxTime = true + elseif isAutoRecover and maxTime ~= leftTime and refreshTime == 0 then + self:RefreshBase() + self.isMaxTime = false + end + end + end + -- 开始吧 + if not self._TimeCounter then + self._TimeCounter = Timer.New(_TimeUpdate, 1, -1, true) + self._TimeCounter:Start() + end + -- 刷新一次 + _TimeUpdate() +end + +-- 刷新物品列表 +function ShopView:RefreshItemList(isTop) + if self.ShopType == SHOP_TYPE.SOUL_STONE_SHOP then + self.ScrollView.gameObject:SetActive(false) + self.RechargeScrollView.gameObject:SetActive(true) + local itemlist = self.RechargeShopData + self.RechargeScrollView:SetData(itemlist, function(index, shopItem) + local itemData = itemlist[index] + self:RechargeShopItemAdapter(shopItem, itemData) + + end, not isTop) + else + -- 重置列表 + self.RechargeScrollView.gameObject:SetActive(false) + self.ScrollView.gameObject:SetActive(true) + local itemlist = ShopManager.CheckShopItemList(self.ShopData.storeItem) + self.ScrollView:SetData(itemlist, function(index, shopItem) + local itemData = itemlist[index] + self:ShopItemAdapter(shopItem, itemData) + end, not isTop) + end +end + +-- 妖晶商店物品数据匹配 +function ShopView:RechargeShopItemAdapter(shopItem, itemData) + -- 获取对象 + local first = Util.GetGameObject(shopItem, "first") + local firstNum = Util.GetGameObject(shopItem, "first/Text"):GetComponent("Text") + local icon = Util.GetGameObject(shopItem, "icon"):GetComponent("Image") + local num = Util.GetGameObject(shopItem, "itemName"):GetComponent("Text") + local price = Util.GetGameObject(shopItem, "price/Text"):GetComponent("Text") + + -- 计算数据 + local itemInfo = ShopManager.GetRechargeItemInfo(itemData.goodsId) + icon.sprite = Util.LoadSprite(GetResourcePath(itemInfo.Resources)) + num.text = itemInfo.Name + price.text = MoneyUtil.GetMoneyMark() .. MoneyUtil.GetMoney(itemInfo.Price) + + -- 判断首充赠送 + local curBuyCount = itemData.buyTimes + first:SetActive(curBuyCount < 1) + firstNum.text = itemInfo.FirstMultiple[1][2] + + -- 购买事件 + Util.AddOnceClick(shopItem, function() + PayManager.Pay(itemData.goodsId, function(id) + self:RechargeSuccessFunc(itemData.goodsId) + end) + end) +end + +-- 商店物品数据匹配 +function ShopView:ShopItemAdapter(shopItem, itemData) + -- 获取对象 + local bg = Util.GetGameObject(shopItem, "bg") + local item = Util.GetGameObject(bg, "item") + local itemName = Util.GetGameObject(bg, "itemName"):GetComponent("Text") + local limitBg = Util.GetGameObject(bg, "buyLimitbg") + local limitTip = Util.GetGameObject(bg, "buyLimitbg/tip"):GetComponent("Text") + local limitTimes = Util.GetGameObject(bg, "buyLimitbg/buyLimit"):GetComponent("Text") + local priceBg = Util.GetGameObject(bg, "pricebg") + local itemPrice = Util.GetGameObject(bg, "pricebg/price"):GetComponent("Text") + local costIcon = Util.GetGameObject(bg, "pricebg/costIcon"):GetComponent("Image") + local discountbg = Util.GetGameObject(bg, "discountbg") + local empty = Util.GetGameObject(shopItem, "empty") + local lock = Util.GetGameObject(shopItem, "lock") + local lockTip = Util.GetGameObject(shopItem, "lock/tip"):GetComponent("Text") + + -- 计算数据 + local itemInfo = ShopManager.GetShopItemInfo(itemData.id) + local curBuyCount = itemData.buyNum + local maxLimitCount = ShopManager.GetShopItemLimitBuyCount(itemData.id) + local costId, price = ShopManager.calculateBuyCost(self.ShopType, itemData.id, 1) + + local goods = ShopManager.GetShopItemGoodsInfo(itemData.id) + itemName.text = ConfigManager.GetConfigData(ConfigName.ItemConfig,goods[1][1]).Name--itemInfo.GoodsName + -- 折扣 + if price == 0 then + discountbg:SetActive(true) + discountbg:GetComponent("Image").sprite = Util.LoadSprite("s_shop_zhekou_00") + else + local isDiscount = itemInfo.IsDiscount == 1 + discountbg:SetActive(isDiscount) + if isDiscount then + discountbg:GetComponent("Image").sprite = Util.LoadSprite("s_shop_zhekou_0" .. itemInfo.DiscountDegree) + end + end + -- 消耗物品的信息 + itemPrice.text = PrintWanNum2(tonumber(price))--tostring(price) + costIcon.sprite = SetIcon(costId) + + -- 判断商品栏位是否解锁 + local _IsUnLock = true + if self.ShopType == SHOP_TYPE.GUILD_SHOP then + local isUnLock, unLockLevel = MyGuildManager.GetGuildShopSortIsUnLock(itemInfo.Sort) + if not isUnLock then + _IsUnLock = false + lockTip.text = string.format("公会%d级解锁", unLockLevel) + end + end + lock:SetActive(not _IsUnLock) + priceBg.gameObject:SetActive(_IsUnLock) + itemName.gameObject:SetActive(_IsUnLock) + + -- 限购 + limitBg:SetActive(maxLimitCount ~= -1) + limitTimes.text = maxLimitCount + -- 售空 限购次数为-1 表示不限购 + local isEmpty = maxLimitCount ~= -1 and curBuyCount >= maxLimitCount + if curBuyCount >= maxLimitCount then + empty:SetActive(true) + else + empty:SetActive(false) + end + empty:SetActive(isEmpty) + + -- 数据匹配 + if not self._GoodsItemList then + self._GoodsItemList = {} + end + if not self._GoodsItemList[shopItem] then + self._GoodsItemList[shopItem] = SubUIManager.Open(SubUIConfig.ItemView, item.transform) + end + Util.SetGray(self._GoodsItemList[shopItem].gameObject, not _IsUnLock) + if isEmpty or not _IsUnLock then -- 物品空或者未解锁不现实物品特效 + self._GoodsItemList[shopItem]:OnOpen(false, goods[1],1,false,false,false) + else + self._GoodsItemList[shopItem]:OnOpen(false, goods[1],1,false,false,false,ShopView.sortingOrder) + end + + -- 商品颜色显示 + local imgColor = isEmpty and Color.New(0.5, 0.5, 0.5, 1) or Color.New(1, 1, 1, 1) + local textA = isEmpty and 0.7 or 1 + Util.SetColor(bg, imgColor) + self:SetAlpha(itemName, textA) + self:SetAlpha(limitTip, textA) + self:SetAlpha(limitTimes, textA) + self:SetAlpha(itemPrice, textA) + + -- 购买事件 + Util.AddOnceClick(lock, function() + PopupTipPanel.ShowTip("商品未解锁") + end) + Util.AddOnceClick(empty, function() + PopupTipPanel.ShowTip("商品已售空") + end) + Util.AddOnceClick(bg, function() + -- 售空 + if isEmpty then + PopupTipPanel.ShowTip("商品已售空") + return + end + if not _IsUnLock then + PopupTipPanel.ShowTip("商品未解锁") + return + end + UIManager.OpenPanel(UIName.ShopBuyPopup, self.ShopType, itemData.id) + end) +end + +-- 充值成功回调 +function ShopView:RechargeSuccessFunc(id) + FirstRechargeManager.RefreshAccumRechargeValue(id) + OperatingManager.RefreshGiftGoodsBuyTimes(GoodsTypeDef.DemonCrystal, id) + self:RefreshShopInfo(false, false) + --PopupTipPanel.ShowTip("购买成功,请到邮箱中领取!") + PlayerPrefs.SetInt(PlayerManager.uid.."czlb", 0) + CheckRedPointStatus(RedPointType.GrowthPackage)--成长礼包红点检测 +end + +--界面关闭时调用(用于子类重写) +function ShopView:OnClose() + self.gameObject:SetActive(false) + if self._TimeCounter then + self._TimeCounter:Stop() + self._TimeCounter = nil + end +end + +--界面销毁时调用(用于子类重写) +function ShopView:OnDestroy() + -- 物品节点回收 + if self._GoodsItemList then + for _, item in pairs(self._GoodsItemList) do + Util.SetColor(item.gameObject, Color.New(1,1,1,1)) + Util.SetGray(item.gameObject, false) + SubUIManager.Close(item) + end + self._GoodsItemList = {} + end + if self.ScrollView then + SubUIManager.Close(self.ScrollView) + self.ScrollView = nil + end + if self.RechargeScrollView then + SubUIManager.Close(self.RechargeScrollView) + self.RechargeScrollView = nil + end + if self.liveNode then + poolManager:UnLoadLive(self.LiveName, self.liveNode) + self.liveNode = nil + end +end + + + +---=================================工具函数========================================== +-- 设置文本透明度 +function ShopView:SetAlpha(text, a) + local color = text.color + color.a = a + text.color = color +end + +---=====================================对外接口=============================---- + +-- 设置立绘位置 +function ShopView:SetLivePosition(pos) + -- 计算位置 + if not pos then + return + end + if not self.liveNode then + return + end + self.liveNode.transform.localPosition = pos +end + +-- 设置商店物品栏位置 +function ShopView:SetItemContentPosition(pos) + -- 计算位置 + if not pos then + return + end + self.scrollBg.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(pos.x, pos.y) + --self.scrollBg.transform.localPosition = pos +end + +-- 设置基础信息位置 +function ShopView:SetBasePanelPostion(pos) + self.basePanel:GetComponent("RectTransform").anchoredPosition = pos +end + +-- 设置层级 +function ShopView:SetSortLayer(sortLayer) + if not self._GoodsItemList then + self._GoodsItemList = {} + end + -- + -- Log("sortLayer _GoodsItemList "..sortLayer.." "..LengthOfTable(self._GoodsItemList)) + for _, item in pairs(self._GoodsItemList) do + item:SetEffectLayer(sortLayer)--ShopView.sortingOrder) + end + + -- self.titleBg:GetComponent("Canvas").sortingOrder = sortLayer + 1 + + -- 保存层级 + ShopView.sortingOrder = sortLayer +end + +return ShopView \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/View/ShopViewNew.lua.meta b/Assets/ManagedResources/~Lua/View/ShopViewNew.lua.meta new file mode 100644 index 0000000000..ab7cefcd29 --- /dev/null +++ b/Assets/ManagedResources/~Lua/View/ShopViewNew.lua.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 13777c91f94f6034fbc21a2f5d70a6db +timeCreated: 1557889987 +licenseType: Pro +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: