抽卡表现 先临时提一波

This commit is contained in:
CloudJ 2023-06-01 10:00:10 +08:00
parent 44a7937320
commit 83753326b6
4 changed files with 75 additions and 7 deletions

View File

@ -12,6 +12,7 @@ ItemConst.ITEM_ID_EXP = 12
ItemConst.ITEM_ID_BOX_KEY_LV_1 = 13
ItemConst.ITEM_ID_BOX_KEY_LV_2 = 14
ItemConst.ITEM_ID_BOX_KEY_LV_3 = 15
ItemConst.ITEM_ID_BOX_LV_5 = 18
ItemConst.ITEM_ID_RANDOM_FRAGMENT = 19
ItemConst.ITEM_TYPE = {

View File

@ -6,19 +6,23 @@ local SUMMON_ICON_NAME = {
[GConst.SummonConst.SUMMON_TYPE.LV_3] = "shop_chest_3"
}
local BOUNTY_ICON_NAME = {
[GConst.ItemConst.ITEM_ID_BOX_LV_1] = "shop_chest_2",
[GConst.ItemConst.ITEM_ID_BOX_LV_2] = "shop_chest_2",
[GConst.ItemConst.ITEM_ID_BOX_LV_3] = "shop_chest_3",
[GConst.ItemConst.ITEM_ID_BOX_LV_4] = "shop_chest_3",
[GConst.ItemConst.ITEM_ID_BOX_LV_1] = "bounty_chest_1",
[GConst.ItemConst.ITEM_ID_BOX_LV_2] = "bounty_chest_2",
[GConst.ItemConst.ITEM_ID_BOX_LV_3] = "bounty_chest_5",
[GConst.ItemConst.ITEM_ID_BOX_LV_4] = "bounty_chest_3",
[GConst.ItemConst.ITEM_ID_BOX_LV_5] = "bounty_chest_4",
}
function BoxOpenUI:ctor(params)
self.params = params or {} -- 将信息传递给下一个界面
self.type = self.params and self.params.type
self.iconName = "shop_chest_1" -- 默认图标
self.iconAtlas = GConst.ATLAS_PATH.SHOP
if self.type == GConst.ShopConst.BOX_REWARD_TYPE.SUMMON then
self.iconAtlas = GConst.ATLAS_PATH.SHOP
self.iconName = SUMMON_ICON_NAME[self.params.params or GConst.SummonConst.SUMMON_TYPE.LV_1]
elseif self.type == GConst.ShopConst.BOX_REWARD_TYPE.BOUNTY then
self.iconAtlas = GConst.ATLAS_PATH.BOUNTY
self.iconName = BOUNTY_ICON_NAME[self.params.params or GConst.ItemConst.ITEM_ID_BOX_KEY_LV_1]
end
end
@ -39,7 +43,7 @@ function BoxOpenUI:onLoadRootComplete()
self.openBtn = self.uiMap["box_open_ui.open_btn"]
self.btnText = self.uiMap["box_open_ui.open_btn.text"]
self.boxImg:setSprite(GConst.ATLAS_PATH.SHOP, self.iconName)
self.boxImg:setSprite(self.iconAtlas, self.iconName)
self.btnText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_7)) -- 立即打开
self.openBtn:addClickListener(function()

View File

@ -1,9 +1,21 @@
local BoxRewardUI = class("BoxRewardUI", BaseUI)
local BOX_HERO_CELL = "app/ui/shop/cell/box_hero_cell"
local CELL_NUM = 4
local QLT_DELAY_TIME = {
[1] = 0.25,
[2] = 0.25,
[3] = 0.5,
[4] = 0.5,
[5] = 0.75,
[6] = 1
}
local FADE_TIME = 0.5
function BoxRewardUI:ctor(params)
self.params = params or {}
self.rewards = params.rewards or {}
self.actionStatus = {}
self.fragmentRewards = {}
self.coinNum = 0
@ -44,6 +56,7 @@ function BoxRewardUI:onLoadRootComplete()
end)
self.scrollRect:addRefreshCallback(function(index, cell)
cell:refresh(self.fragmentRewards[index])
self:playCellAction(cell, index)
end)
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.fragmentRewards)
@ -76,4 +89,49 @@ function BoxRewardUI:onLoadRootComplete()
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CLOSE_BOX_OPEN_UI)
end
function BoxRewardUI:playCellAction(cell, idx)
if self.actionStatus[idx] then
return
end
local delayTime = self:getCellDelayTime(idx)
local canvasGroup = cell.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
if not canvasGroup then
canvasGroup = cell.baseObject:addComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
end
canvasGroup.alpha = 0
local seq = cell.baseObject:createBindTweenSequence()
seq:AppendInterval(delayTime)
local tween = canvasGroup:DOFade(1, FADE_TIME)
tween:SetEase(CS.DG.Tweening.Ease.InOutSine)
seq:Append(tween)
seq:AppendCallback(function()
self.actionStatus[idx] = true
self:turnToNext(idx)
end)
end
function BoxRewardUI:turnToNext(idx)
if not self.showAction or idx ~= self.turnIdx * CELL_NUM then
return
end
self:performWithDelayGlobal(function()
self.scrollRect:moveToIndex((self.turnIdx - 6)*CELL_NUM + 1)
self.turnIdx = self.turnIdx + 1
if self.turnIdx >= self.maxIdx then
self.showAction = false
end
end, 0.025)
end
function BoxRewardUI:getCellDelayTime(idx)
-- 品质对应时间
if idx <= 35 then
return idx* 0.2 -- 0.05
else
local re = (idx - 1)%5 + 1
return re* 0.1 -- 0.025
end
end
return BoxRewardUI

View File

@ -40,9 +40,14 @@ function HotCell:refresh(data)
self.icon:setVisible(false)
self.heroNode:setVisible(true)
local heroEntity = DataManager.HeroData:getHeroById(reward.id)
if heroEntity then
self.heroCell:refresh(heroEntity)
else
self.heroCell:refreshWithCfgId(reward.id)
end
self.heroNumText:setText("X" .. tostring(reward.num))
self.nameText:setText(ModuleManager.ItemManager:getItemName(reward.id))
self.nameText:setText(ModuleManager.HeroManager:getHeroName(reward.id, false))
else
self.icon:setVisible(true)
self.heroNode:setVisible(false)