836 lines
26 KiB
Lua
836 lines
26 KiB
Lua
|
||
local uiCtrl = require_ex('UI/Panels/Base/UICtrl')
|
||
local PANEL_ID = PanelId.ShopWeapon
|
||
local PHASE_ID = PhaseId.ShopWeapon
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl = HL.Class('ShopWeaponCtrl', uiCtrl.UICtrl)
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_shopSystem = HL.Field(HL.Any)
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_permanentBoxCell = HL.Field(HL.Forward("UIListCache"))
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_permanentBoxSubBoxCellDict = HL.Field(HL.Table)
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_permanentBoxSubGoodsCellDict = HL.Field(HL.Table)
|
||
|
||
|
||
ShopWeaponCtrl.m_permanentGoodsCell = HL.Field(HL.Forward("UIListCache"))
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_firstNaviTarget = HL.Field(HL.Any)
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_naviCellTable = HL.Field(HL.Table)
|
||
|
||
|
||
ShopWeaponCtrl.m_currNaviRow = HL.Field(HL.Int) << 1
|
||
|
||
|
||
ShopWeaponCtrl.m_currNaviCol = HL.Field(HL.Int) << 1
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_haveSeenLines = HL.Field(HL.Table)
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.s_messages = HL.StaticField(HL.Table) << {
|
||
[MessageConst.ON_SHOP_REFRESH] = '_OnShopRefresh',
|
||
[MessageConst.ON_SHOP_JUMP_EVENT] = 'OnClickGoods',
|
||
[MessageConst.ON_SHOP_GOODS_CONDITION_REFRESH] = 'UpdateAll',
|
||
[MessageConst.ON_GACHA_POOL_INFO_CHANGED] = 'OnGachaPoolInfoChanged',
|
||
[MessageConst.ON_GACHA_POOL_ROLE_DATA_CHANGED] = 'OnGachaPoolRoleDataChanged',
|
||
}
|
||
|
||
|
||
|
||
ShopWeaponCtrl.m_normalGoods = HL.Field(HL.Any)
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.OnCreate = HL.Override(HL.Any) << function(self, arg)
|
||
self.m_phase = arg.phase
|
||
|
||
self:_InitShortCut()
|
||
|
||
self.m_shopSystem = GameInstance.player.shopSystem
|
||
|
||
self.m_permanentBoxCell = UIUtils.genCellCache(self.view.commonWeapons.weaponCase)
|
||
self.m_permanentGoodsCell = UIUtils.genCellCache(self.view.commonWeapons.shopWeaponCell)
|
||
self.m_permanentBoxSubBoxCellDict = {}
|
||
self.m_permanentBoxSubGoodsCellDict = {}
|
||
|
||
self.m_naviCellTable = {}
|
||
self.m_haveSeenLines = {}
|
||
self:UpdateUpWeapon()
|
||
self:UpdateWeeklyAndDailyWeapon()
|
||
self:_StartCoroutine(function()
|
||
coroutine.wait(0.2)
|
||
self:UpdatePermanentWeapon()
|
||
end)
|
||
|
||
self.view.scroll.onValueChanged:AddListener(function(data)
|
||
self:_ComputeSeeGoods()
|
||
|
||
local show = (self.view.scroll.normalizedPosition.y) > 0.05
|
||
if self.view.upWeaponNextPage.gameObject.activeSelf == show then
|
||
return
|
||
end
|
||
if show then
|
||
self.view.upWeaponNextPage.gameObject:SetActive(true)
|
||
else
|
||
self.view.upWeaponNextPage.gameObject:SetActive(false)
|
||
end
|
||
end)
|
||
|
||
|
||
UIUtils.setAsNaviTarget(self.m_firstNaviTarget)
|
||
|
||
local cashShopCtrl = self.m_phase.cashShopCtrl
|
||
if cashShopCtrl == nil then
|
||
cashShopCtrl = self.m_phase.m_panel2Item[PanelId.CashShop].uiCtrl
|
||
end
|
||
|
||
self.view.controllerHintPlaceholder:InitControllerHintPlaceholder({
|
||
self.view.inputGroup.groupId,
|
||
cashShopCtrl.view.inputGroup.groupId,
|
||
})
|
||
|
||
self.m_phase:HidePsStore()
|
||
|
||
self:_ProcessArg(arg)
|
||
end
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl._ProcessArg = HL.Method(HL.Any) << function(self, arg)
|
||
if arg == nil or string.isEmpty(arg.goodsId) then
|
||
return
|
||
end
|
||
|
||
local goodsId = arg.goodsId
|
||
arg.goodsId = nil
|
||
local goods = Tables.shopGoodsTable[goodsId]
|
||
local shopId = goods.shopId
|
||
local goodsData = self.m_shopSystem:GetShopGoodsData(shopId, goodsId)
|
||
if goodsData == nil then
|
||
logger.error(ELogChannel.UI, "商店商品数据为空")
|
||
return
|
||
end
|
||
|
||
local isBox = string.isEmpty(goods.rewardId)
|
||
if isBox then
|
||
PhaseManager:OpenPhase(PhaseId.GachaWeaponPool, {goodsData = goodsData}, nil, true)
|
||
else
|
||
self:_StartCoroutine(function()
|
||
UIManager:Open(PanelId.ShopDetail, goodsData)
|
||
end)
|
||
end
|
||
return
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.UpdateGoodsCell = HL.Method(HL.Any, HL.Table) << function(self, cell, info)
|
||
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl._OnShopRefresh = HL.Method() << function(self)
|
||
if UIManager:IsOpen(PanelId.ShopDetail) then
|
||
UIManager:Close(PanelId.ShopDetail)
|
||
end
|
||
|
||
self:UpdateAll()
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl.UpdateAll = HL.Method() << function(self)
|
||
self.m_naviCellTable = {}
|
||
|
||
self:UpdateUpWeapon()
|
||
self:UpdateWeeklyAndDailyWeapon()
|
||
self:UpdatePermanentWeapon()
|
||
|
||
|
||
self.m_currNaviRow = math.min(self.m_currNaviRow, #self.m_naviCellTable)
|
||
local currRow = self.m_naviCellTable[self.m_currNaviRow]
|
||
self.m_currNaviCol = math.min(self.m_currNaviCol, #currRow)
|
||
local cell = currRow[self.m_currNaviCol].cell
|
||
UIUtils.setAsNaviTarget(cell)
|
||
end
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.OnClickGoods = HL.Method(HL.Opt(HL.Table)) << function(self, arg)
|
||
|
||
local goodsId = arg.goods
|
||
if goodsId then
|
||
local goods = Tables.shopGoodsTable[goodsId]
|
||
local shopId = goods.shopId
|
||
local goodsData = self.m_shopSystem:GetShopGoodsData(shopId, goodsId)
|
||
if goodsData == nil then
|
||
logger.error(ELogChannel.UI, "商店商品数据为空")
|
||
return
|
||
end
|
||
|
||
local isBox = string.isEmpty(goods.rewardId)
|
||
if isBox then
|
||
PhaseManager:OpenPhase(PhaseId.GachaWeaponPool, {goodsData = goodsData})
|
||
else
|
||
UIManager:Open(PanelId.ShopDetail, goodsData)
|
||
end
|
||
return
|
||
end
|
||
|
||
if arg.sourceId and arg.targetId then
|
||
PhaseManager:OpenPhase(PhaseId.CommonMoneyExchange, {sourceId = arg.sourceId, targetId = arg.targetId})
|
||
end
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl.UpdateUpWeapon = HL.Method() << function(self)
|
||
local _, box, goods = self.m_shopSystem:GetNowUpWeaponData()
|
||
local singleWeaponCase = self.view.randomWeaponsCase
|
||
local singleWeaponCaseCell = singleWeaponCase.shopWeaponCaseCell
|
||
local doubleWeaponCase = self.view.doubleRandomWeaponsCase
|
||
if box == nil or box.Count == 0 then
|
||
|
||
doubleWeaponCase.gameObject:SetActive(false)
|
||
singleWeaponCase.gameObject:SetActive(true)
|
||
singleWeaponCase.stayTunedNode.gameObject:SetActive(true)
|
||
singleWeaponCaseCell.gameObject:SetActive(false)
|
||
self.m_firstNaviTarget = singleWeaponCase.inputBindingGroupNaviDecorator
|
||
table.insert(self.m_naviCellTable, {
|
||
{ length = 6, cell = singleWeaponCase.inputBindingGroupNaviDecorator }
|
||
})
|
||
return
|
||
end
|
||
|
||
|
||
local csGachaSys = GameInstance.player.gacha
|
||
|
||
if box.Count == 1 then
|
||
|
||
singleWeaponCase.gameObject:SetActive(true)
|
||
doubleWeaponCase.gameObject:SetActive(false)
|
||
singleWeaponCaseCell.gameObject:SetActive(true)
|
||
singleWeaponCase.stayTunedNode.gameObject:SetActive(false)
|
||
self.m_firstNaviTarget = singleWeaponCase.inputBindingGroupNaviDecorator
|
||
table.insert(self.m_naviCellTable, {
|
||
{ length = 6, cell = singleWeaponCase.inputBindingGroupNaviDecorator, goodsId = box[0].goodsId }
|
||
})
|
||
local boxData = box[0]
|
||
|
||
self:_UpdateSingleLimitedWeapon(singleWeaponCaseCell, boxData, false)
|
||
|
||
local goodsCfg = Tables.shopGoodsTable[boxData.goodsTemplateId]
|
||
local poolId = goodsCfg.weaponGachaPoolId
|
||
|
||
local _, poolInfo = csGachaSys.poolInfos:TryGetValue(poolId)
|
||
local closeTime = poolInfo.closeTime
|
||
local poolTimeNode = singleWeaponCaseCell.view.poolTimeNode
|
||
poolTimeNode.endTimeTxt.text = Utils.appendUTC(Utils.timestampToDateMDHM(closeTime))
|
||
end
|
||
|
||
if box.Count >= 2 then
|
||
|
||
singleWeaponCase.gameObject:SetActive(false)
|
||
doubleWeaponCase.gameObject:SetActive(true)
|
||
local boxData1 = box[0]
|
||
local boxData2 = box[1]
|
||
local weaponCaseCell1 = doubleWeaponCase.shopWeaponCaseCell1
|
||
local weaponCaseCell2 = doubleWeaponCase.shopWeaponCaseCell2
|
||
self.m_firstNaviTarget = weaponCaseCell1.inputBindingGroupNaviDecorator
|
||
table.insert(self.m_naviCellTable, {
|
||
{ length = 3, cell = weaponCaseCell1.inputBindingGroupNaviDecorator, goodsId = box[0].goodsId },
|
||
{ length = 3, cell = weaponCaseCell2.inputBindingGroupNaviDecorator, goodsId = box[1].goodsId },
|
||
})
|
||
|
||
self:_UpdateSingleLimitedWeapon(weaponCaseCell1, boxData1, true)
|
||
self:_UpdateSingleLimitedWeapon(weaponCaseCell2, boxData2, true)
|
||
|
||
local goodsCfg = Tables.shopGoodsTable[boxData1.goodsTemplateId]
|
||
local poolId = goodsCfg.weaponGachaPoolId
|
||
local _, poolInfo = csGachaSys.poolInfos:TryGetValue(poolId)
|
||
local closeTime = poolInfo.closeTime
|
||
doubleWeaponCase.titleCloseTimeTxt:SetAndResolveTextStyle(string.format(Language.LUA_SHOP_WEAPON_TIME_LIMIT, Utils.timestampToDateYMDHM(closeTime)))
|
||
end
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl._UpdateSingleLimitedWeapon = HL.Method(HL.Any, HL.Any, HL.Boolean) << function(self, weaponCaseCell, boxData, isDoublePool)
|
||
|
||
local csGachaSys = GameInstance.player.gacha
|
||
local goodsCfg = Tables.shopGoodsTable[boxData.goodsTemplateId]
|
||
|
||
weaponCaseCell:InitCashShopItem(boxData, true)
|
||
|
||
|
||
local poolId = goodsCfg.weaponGachaPoolId
|
||
|
||
local _, poolInfo = csGachaSys.poolInfos:TryGetValue(poolId)
|
||
if poolInfo == nil then
|
||
logger.error("卡池信息不存在!卡池id:" .. poolId)
|
||
return
|
||
end
|
||
|
||
local weaponPoolCfg = Tables.gachaWeaponPoolTable[poolId]
|
||
local gachaTypeCfg = Tables.gachaWeaponPoolTypeTable[weaponPoolCfg.type]
|
||
weaponCaseCell.view.poolNameTxt.text = weaponPoolCfg.name
|
||
local uiPrefabName = isDoublePool and weaponPoolCfg.doublePoolNodeUIPrefab or weaponPoolCfg.poolNodeUIPrefab
|
||
if weaponCaseCell.view.uiPrefabName ~= uiPrefabName then
|
||
if weaponCaseCell.view.node then
|
||
GameObject.Destroy(weaponCaseCell.view.node)
|
||
end
|
||
local path = string.format("Assets/Beyond/DynamicAssets/Gameplay/UI/Prefabs/CashShop/Widgets/WeaponPoolNode/%s.prefab", uiPrefabName)
|
||
local prefab = self.loader:LoadGameObject(path)
|
||
local obj = CSUtils.CreateObject(prefab, weaponCaseCell.view.weaponPoolNodeRoot)
|
||
|
||
obj.name = weaponPoolCfg.id
|
||
weaponCaseCell.view.uiPrefabName = uiPrefabName
|
||
weaponCaseCell.view.node = obj
|
||
end
|
||
|
||
local showHardGuarantee = poolInfo.upGotCount <= 0
|
||
local guaranteeNode = weaponCaseCell.view.guaranteeNode
|
||
if showHardGuarantee then
|
||
local upWeaponId = weaponPoolCfg.upWeaponIds[0]
|
||
local weaponItemCfg = Tables.itemTable[upWeaponId]
|
||
local weaponCfg = Tables.weaponBasicTable[upWeaponId]
|
||
local weaponTypeIconName = UIConst.WEAPON_EXHIBIT_WEAPON_TYPE_ICON_PREFIX .. weaponCfg.weaponType:ToInt()
|
||
guaranteeNode.stateController:SetState("HardGuarantee")
|
||
guaranteeNode.itemIcon:InitItemIcon(upWeaponId)
|
||
guaranteeNode.rewardNameTxt.text = weaponItemCfg.name
|
||
guaranteeNode.weaponTypeIcon:LoadSprite(UIConst.UI_SPRITE_WEAPON_EXHIBIT, weaponTypeIconName)
|
||
guaranteeNode.remainNeedPullCountTxt.text = math.ceil((gachaTypeCfg.hardGuarantee - poolInfo.hardGuaranteeProgress) / 10)
|
||
guaranteeNode.btn.onClick:RemoveAllListeners()
|
||
guaranteeNode.btn.onClick:AddListener(function()
|
||
CashShopUtils.ShowWikiWeaponPreview(poolId, upWeaponId)
|
||
end)
|
||
else
|
||
guaranteeNode.stateController:SetState("LoopReward")
|
||
|
||
local loopRewardInfos = CashShopUtils.GetGachaWeaponLoopRewardInfo(poolId)
|
||
if not loopRewardInfos then
|
||
guaranteeNode.gameObject:SetActive(false)
|
||
return
|
||
else
|
||
guaranteeNode.gameObject:SetActive(true)
|
||
table.sort(loopRewardInfos, function(a, b)
|
||
return a.remainNeedPullCount < b.remainNeedPullCount
|
||
end)
|
||
|
||
local info = loopRewardInfos[1]
|
||
guaranteeNode.itemIcon:InitItemIcon(info.itemId)
|
||
guaranteeNode.rewardNameTxt.text = info.name
|
||
guaranteeNode.remainNeedPullCountTxt.text = info.remainNeedPullCount
|
||
guaranteeNode.btn.onClick:RemoveAllListeners()
|
||
guaranteeNode.btn.onClick:AddListener(function()
|
||
|
||
logger.info("武器卡池,up武器预览或宝箱预览")
|
||
if info.isWeaponItemCase then
|
||
UIManager:Open(PanelId.BattlePassWeaponCase, { itemId = info.itemId, isPreview = true })
|
||
else
|
||
CashShopUtils.ShowWikiWeaponPreview(poolId, info.itemId)
|
||
end
|
||
end)
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl.UpdatePermanentWeapon = HL.Method() << function(self)
|
||
local _, box, goods = self.m_shopSystem:GetPermanentWeaponShopData()
|
||
self.m_shopSystem:SortGoodsList(box)
|
||
self.m_shopSystem:SortGoodsList(goods)
|
||
|
||
local boxList = self:_GetGoodsDataInfoList(box)
|
||
local goodsList = self:_GetGoodsDataInfoList(goods)
|
||
|
||
|
||
local rowCount = (#boxList % 3 > 0) and (math.floor(#boxList / 3) + 1) or math.floor(#boxList / 3)
|
||
|
||
local useGoodsNumber = (rowCount * 3 - #boxList) * 2
|
||
if useGoodsNumber > #goodsList then
|
||
useGoodsNumber = #goodsList
|
||
end
|
||
self.m_permanentBoxCell:Refresh(rowCount, function(cell, index)
|
||
local naviDataLine = {}
|
||
cell.gameObject.name = tostring(index)
|
||
cell.transform:SetSiblingIndex(index - 1)
|
||
local boxCell = nil
|
||
local goodsCell = nil
|
||
if self.m_permanentBoxSubBoxCellDict[index] then
|
||
boxCell = self.m_permanentBoxSubBoxCellDict[index]
|
||
else
|
||
boxCell = UIUtils.genCellCache(cell.shopWeaponSuperiorCell)
|
||
self.m_permanentBoxSubBoxCellDict[index] = boxCell
|
||
end
|
||
if self.m_permanentBoxSubGoodsCellDict[index] then
|
||
goodsCell = self.m_permanentBoxSubGoodsCellDict[index]
|
||
else
|
||
goodsCell = UIUtils.genCellCache(cell.shopWeaponCell)
|
||
self.m_permanentBoxSubGoodsCellDict[index] = goodsCell
|
||
end
|
||
local startBoxIndex = 3 * (index - 1) + 1
|
||
local endBoxIndex = (3 * index <= #boxList) and (3 * index) or #boxList
|
||
boxCell:Refresh(endBoxIndex - startBoxIndex + 1, function(boxCell, boxIndex)
|
||
boxCell.gameObject.name = "boxCell" .. tostring(boxIndex)
|
||
local trueIndex = startBoxIndex + boxIndex - 1
|
||
boxCell:InitCashShopItem(boxList[trueIndex])
|
||
boxCell.view.cashShopItemTag.gameObject:SetActive(false)
|
||
table.insert(naviDataLine, {
|
||
length = 2, cell = boxCell.view.inputBindingGroupNaviDecorator, goodsId = boxList[trueIndex].goodsId })
|
||
end)
|
||
|
||
if index == rowCount and useGoodsNumber > 0 then
|
||
goodsCell:Refresh(useGoodsNumber, function(goodsCell, goodsIndex)
|
||
goodsCell.gameObject.name = "goodsCell" .. tostring(goodsIndex)
|
||
goodsCell:InitCashShopItem(goodsList[goodsIndex])
|
||
table.insert(naviDataLine, {
|
||
length = 1,
|
||
cell = goodsCell.view.inputBindingGroupNaviDecorator,
|
||
goodsId = goodsList[goodsIndex].goodsId })
|
||
end)
|
||
else
|
||
goodsCell:Refresh(0, function(goodsCell, goodsIndex) end)
|
||
end
|
||
|
||
table.insert(self.m_naviCellTable, naviDataLine)
|
||
end)
|
||
|
||
|
||
|
||
if #goodsList > useGoodsNumber then
|
||
local naviDataLine = {}
|
||
local countPerLine = self.view.commonWeapons.container.constraintCount
|
||
self.m_permanentGoodsCell:Refresh(#goodsList - useGoodsNumber, function(cell, index)
|
||
cell.gameObject.name = tostring(index)
|
||
local trueIndex = index + useGoodsNumber
|
||
cell:InitCashShopItem(goodsList[trueIndex])
|
||
table.insert(naviDataLine, {
|
||
length = 1,
|
||
cell = cell.view.inputBindingGroupNaviDecorator,
|
||
goodsId = goodsList[trueIndex].goodsId
|
||
})
|
||
if index % countPerLine == 0 or index == #goodsList - useGoodsNumber then
|
||
|
||
table.insert(self.m_naviCellTable, naviDataLine)
|
||
naviDataLine = {}
|
||
end
|
||
end)
|
||
else
|
||
self.m_permanentGoodsCell:Refresh(0, function(cell, index) end)
|
||
end
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.UpdateWeeklyAndDailyWeapon = HL.Method() << function(self)
|
||
local now = CS.Beyond.DateTimeUtils.GetCurrentTimestampBySeconds()
|
||
local _, weeklyBox, weeklyGoods = self.m_shopSystem:GetWeeklyWeaponData()
|
||
local _, dailyBox, dailyGoods = self.m_shopSystem:GetDailyWeaponData()
|
||
local weeklyCell = self.view.timeLimitWeapons.weeklyLimitWeapons
|
||
local dailyCell = self.view.timeLimitWeapons.dailyLimitWeapons
|
||
local naviDataLine = { }
|
||
|
||
if weeklyGoods ~= nil then
|
||
|
||
local weeklyGoodsInfo = {}
|
||
|
||
for _, weeklyGood in pairs(weeklyGoods) do
|
||
local goodsTableData = Tables.shopGoodsTable:GetValue(weeklyGood.goodsId)
|
||
local displayItem = UIUtils.getRewardFirstItem(goodsTableData.rewardId)
|
||
local itemId = displayItem.id
|
||
local itemData = Tables.itemTable[itemId]
|
||
table.insert(weeklyGoodsInfo, {
|
||
goodsData = weeklyGood,
|
||
rarity = itemData.rarity
|
||
})
|
||
end
|
||
table.sort(weeklyGoodsInfo, Utils.genSortFunction({"rarity"}, false))
|
||
weeklyCell.shopWeaponCell.gameObject:SetActive(weeklyGoods.Count >= 1)
|
||
if weeklyGoods.Count >= 1 then
|
||
weeklyCell.shopWeaponCell.gameObject:SetActive(true)
|
||
weeklyCell.shopWeaponCell:InitCashShopItem(weeklyGoodsInfo[1].goodsData)
|
||
table.insert(naviDataLine, {
|
||
length = 2,
|
||
cell = weeklyCell.shopWeaponCell.view.inputBindingGroupNaviDecorator,
|
||
goodsId = weeklyGoodsInfo[1].goodsData.goodsId
|
||
})
|
||
end
|
||
weeklyCell.shopWeaponCell02.gameObject:SetActive(weeklyGoods.Count >= 2)
|
||
if weeklyGoods.Count >= 2 then
|
||
weeklyCell.shopWeaponCell02.gameObject:SetActive(true)
|
||
weeklyCell.shopWeaponCell02:InitCashShopItem(weeklyGoodsInfo[2].goodsData)
|
||
table.insert(naviDataLine, {
|
||
length = 1,
|
||
cell = weeklyCell.shopWeaponCell02.view.inputBindingGroupNaviDecorator,
|
||
goodsId = weeklyGoodsInfo[2].goodsData.goodsId
|
||
})
|
||
end
|
||
|
||
local weeklyTime = weeklyCell.timeLimitTitleText
|
||
local weeklyEndTime = GameInstance.player.shopSystem:GetWeaponGoodsTimeLimit(weeklyGoods[0]) + 1
|
||
if weeklyEndTime == 0 then
|
||
weeklyEndTime = weeklyGoods[0].closeTimeStamp - DateTimeUtils.GetCurrentTimestampBySeconds() + 1
|
||
end
|
||
weeklyTime.text = string.format(Language.LUA_SHOP_WEAPON_WEEKLY_TIME_LIMIT,
|
||
Utils.appendUTC(Utils.timestampToDateYMDHM(weeklyEndTime + now)))
|
||
else
|
||
weeklyCell.shopWeaponCell.gameObject:SetActive(false)
|
||
weeklyCell.shopWeaponCell02.gameObject:SetActive(false)
|
||
table.insert(naviDataLine, {
|
||
length = 3,
|
||
cell = weeklyCell.expectLayout.expectLayout,
|
||
goodsId = nil
|
||
})
|
||
end
|
||
weeklyCell.expectLayout.gameObject:SetActive(weeklyGoods == nil)
|
||
|
||
if dailyGoods ~= nil then
|
||
GameInstance.player.shopSystem:SortGoodsList(dailyGoods)
|
||
for i = 1, 3 do
|
||
local goodsCell = dailyCell["shopWeaponCell0" .. i]
|
||
goodsCell.gameObject:SetActive(dailyGoods.Count >= i)
|
||
if dailyGoods.Count >= i then
|
||
goodsCell:InitCashShopItem(dailyGoods[i - 1])
|
||
table.insert(naviDataLine, {
|
||
length = 1,
|
||
cell = goodsCell.view.inputBindingGroupNaviDecorator,
|
||
goodsId = dailyGoods[i-1].goodsId
|
||
})
|
||
end
|
||
end
|
||
|
||
local dailyTime = dailyCell.timeLimitTitleText
|
||
local dailyEndTime = GameInstance.player.shopSystem:GetWeaponGoodsTimeLimit(dailyGoods[0]) + 1
|
||
dailyTime.text = string.format(Language.LUA_SHOP_WEAPON_DAILY_TIME_LIMIT,
|
||
Utils.appendUTC(Utils.timestampToDateYMDHM(dailyEndTime + now)))
|
||
else
|
||
for i = 1, 3 do
|
||
local goodsCell = dailyCell["shopWeaponCell0" .. i]
|
||
goodsCell.gameObject:SetActive(false)
|
||
end
|
||
table.insert(naviDataLine, {
|
||
length = 3,
|
||
cell = dailyCell.expectLayout.expectLayout,
|
||
goodsId = nil
|
||
})
|
||
end
|
||
dailyCell.expectLayout.expectLayout.gameObject:SetActive(dailyGoods == nil)
|
||
|
||
table.insert(self.m_naviCellTable, naviDataLine)
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl.OnShow = HL.Override() << function(self)
|
||
Notify(MessageConst.CASH_SHOP_SHOW_WALLET_BAR, {
|
||
moneyIds = {Tables.CashShopConst.WeaponTabMoneyId},
|
||
})
|
||
|
||
if self.m_phase.m_needGameEvent then
|
||
self.m_phase.m_needGameEvent = false
|
||
EventLogManagerInst:GameEvent_ShopEnter(
|
||
self.m_phase.m_enterButton,
|
||
self.m_phase.m_enterPanel,
|
||
"",
|
||
CashShopConst.CashShopCategoryType.Weapon,
|
||
""
|
||
)
|
||
end
|
||
|
||
CashShopUtils.TryOpenSpecialGiftPopup()
|
||
CashShopUtils.TryFadeSpecialGiftPopup()
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl.OnClose = HL.Override() << function(self)
|
||
local goodsIds = {}
|
||
for _, lineNumber in ipairs(self.m_haveSeenLines) do
|
||
local lineData = self.m_naviCellTable[lineNumber]
|
||
if lineData then
|
||
for _, data in ipairs(lineData) do
|
||
local goodsId = data.goodsId
|
||
if goodsId then
|
||
table.insert(goodsIds, goodsId)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
if #goodsIds > 0 then
|
||
for _, goodsId in ipairs(goodsIds) do
|
||
if GameInstance.player.shopSystem:IsNewGoodsId(goodsId) then
|
||
GameInstance.player.shopSystem:RecordSeeGoodsId(goodsId)
|
||
end
|
||
end
|
||
GameInstance.player.shopSystem:SetGoodsIdSee()
|
||
end
|
||
end
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl._GetGoodsDataInfoList = HL.Method(HL.Userdata).Return(HL.Table) << function(self, goodsDataList)
|
||
local list = {}
|
||
for i = 0, goodsDataList.Count - 1 do
|
||
local goodsData = goodsDataList[i]
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
table.insert(list, goodsData)
|
||
end
|
||
return list
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl.ChooseLimitedWeaponPool = HL.Method(HL.Any) << function(self, boxData)
|
||
PhaseManager:OpenPhase(PhaseId.GachaWeaponPool, { goodsData = boxData })
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl.OnGachaPoolInfoChanged = HL.Method() << function(self)
|
||
self:UpdateUpWeapon()
|
||
self:UpdateWeeklyAndDailyWeapon()
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl.OnGachaPoolRoleDataChanged = HL.Method() << function(self)
|
||
self:UpdateUpWeapon()
|
||
self:UpdateWeeklyAndDailyWeapon()
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl._InitShortCut = HL.Method() << function(self)
|
||
if not DeviceInfo.usingController then
|
||
return
|
||
end
|
||
|
||
self:BindInputPlayerAction("cashshop_navigation_4_dir_left", function()
|
||
self:_OnGoLeft()
|
||
end)
|
||
|
||
self:BindInputPlayerAction("cashshop_navigation_4_dir_up", function()
|
||
self:_OnGoUp()
|
||
end)
|
||
|
||
self:BindInputPlayerAction("cashshop_navigation_4_dir_right", function()
|
||
self:_OnGoRight()
|
||
end)
|
||
|
||
self:BindInputPlayerAction("cashshop_navigation_4_dir_down", function()
|
||
self:_OnGoDown()
|
||
end)
|
||
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl._OnGoLeft = HL.Method() << function(self)
|
||
if self.m_currNaviCol == 1 then
|
||
return
|
||
end
|
||
|
||
local table = self.m_naviCellTable[self.m_currNaviRow][self.m_currNaviCol - 1]
|
||
local cell = table.cell
|
||
UIUtils.setAsNaviTarget(cell)
|
||
self.m_currNaviCol = self.m_currNaviCol - 1
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl._OnGoUp = HL.Method() << function(self)
|
||
if self.m_currNaviRow == 1 then
|
||
return
|
||
end
|
||
|
||
local leftLength = self:_GetCurrLeftLength()
|
||
local index, data = self:_FindCellByLeftLength(self.m_currNaviRow - 1, leftLength)
|
||
if data then
|
||
UIUtils.setAsNaviTarget(data.cell)
|
||
self.m_currNaviRow = self.m_currNaviRow - 1
|
||
self.m_currNaviCol = index
|
||
end
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl._OnGoRight = HL.Method() << function(self)
|
||
local currRow = self.m_naviCellTable[self.m_currNaviRow]
|
||
|
||
if self.m_currNaviCol == #currRow then
|
||
return
|
||
end
|
||
|
||
local table = currRow[self.m_currNaviCol + 1]
|
||
local cell = table.cell
|
||
UIUtils.setAsNaviTarget(cell)
|
||
self.m_currNaviCol = self.m_currNaviCol + 1
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl._OnGoDown = HL.Method() << function(self)
|
||
logger.info("ShopWeaponCtrl._OnGoDown")
|
||
|
||
if self.m_currNaviRow == #self.m_naviCellTable then
|
||
return
|
||
end
|
||
|
||
local leftLength = self:_GetCurrLeftLength()
|
||
local index, data = self:_FindCellByLeftLength(self.m_currNaviRow + 1, leftLength)
|
||
if data then
|
||
UIUtils.setAsNaviTarget(data.cell)
|
||
self.m_currNaviRow = self.m_currNaviRow + 1
|
||
self.m_currNaviCol = index
|
||
end
|
||
end
|
||
|
||
|
||
|
||
ShopWeaponCtrl._GetCurrLeftLength = HL.Method().Return(HL.Int) << function(self)
|
||
local currRow = self.m_naviCellTable[self.m_currNaviRow]
|
||
local leftLength = 0
|
||
for i = 1, self.m_currNaviCol - 1 do
|
||
local length = currRow[i].length
|
||
leftLength = leftLength + length
|
||
end
|
||
return leftLength
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl._FindCellByLeftLength = HL.Method(HL.Int, HL.Int).Return(HL.Any, HL.Any)
|
||
<< function(self, row, leftLength)
|
||
local currRow = self.m_naviCellTable[row]
|
||
local sum = 0
|
||
for i = 1, #currRow do
|
||
local left = sum
|
||
local right = sum + currRow[i].length
|
||
if leftLength >= left and leftLength < right then
|
||
return i, currRow[i]
|
||
end
|
||
sum = right
|
||
end
|
||
return nil, nil
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
ShopWeaponCtrl._ComputeSeeGoods = HL.Method() << function(self)
|
||
local viewPortRect = self.view.scroll.viewport
|
||
for idx, line in ipairs(self.m_naviCellTable) do
|
||
local firstCell = line[1].cell
|
||
local vectorArray = CS.System.Array.CreateInstance(typeof(Vector3), 4)
|
||
firstCell.gameObject:GetComponent("RectTransform"):GetWorldCorners(vectorArray)
|
||
local leftUp = vectorArray[0]
|
||
local leftDown = vectorArray[3]
|
||
local leftUpLocalPos = viewPortRect.transform:InverseTransformPoint(leftUp)
|
||
local leftDownLocalPos = viewPortRect.transform:InverseTransformPoint(leftDown)
|
||
local leftUpVisible = viewPortRect.rect:Contains(leftUpLocalPos)
|
||
local leftDownVisible = viewPortRect.rect:Contains(leftDownLocalPos)
|
||
if leftUpVisible or leftDownVisible then
|
||
if lume.find(self.m_haveSeenLines, idx) == nil then
|
||
table.insert(self.m_haveSeenLines, idx)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
|
||
HL.Commit(ShopWeaponCtrl)
|