Compare commits
6 Commits
master
...
dev_activi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13371b47fb | ||
|
|
6495fdc267 | ||
|
|
a92bcdd8ed | ||
|
|
9acaebbcb8 | ||
|
|
073ce9085b | ||
|
|
b4fd1c5974 |
File diff suppressed because it is too large
Load Diff
@ -383,7 +383,7 @@ end
|
||||
|
||||
function SDKManager:getServerList(callback)
|
||||
local postData = {
|
||||
project_id = "b6",
|
||||
project_id = "c1",
|
||||
bundle_id = Platform:getIdentifier(),
|
||||
version = Platform:getClientVersion(),
|
||||
device_id = DeviceHelper:getDeviceId(),
|
||||
|
||||
@ -34,6 +34,17 @@ function SpineManager:loadUISpineWidgetAsync(name, parent, callback)
|
||||
end)
|
||||
end
|
||||
|
||||
function SpineManager:loadUIHeroSpineWidgetAsync(name, parent, callback)
|
||||
local path = string.format(HERO_SPINE_ASSET_PATH, name, name)
|
||||
ResourceManager:loadOriginAssetAsync(path, TYPE_OF_SPINE_ASSET, function(spineAssetPath, spineAsset)
|
||||
if parent and parent:isDestroyed() then
|
||||
ResourceManager:unload(spineAssetPath)
|
||||
return
|
||||
end
|
||||
self:loadUISpinePrefabAsync(parent, spineAssetPath, spineAsset, callback)
|
||||
end)
|
||||
end
|
||||
|
||||
function SpineManager:loadUISpinePrefabAsync(parent, spineAssetPath, spineAsset, callback)
|
||||
ResourceManager:loadAsync(UI_SPINE_PREFAB_PATH, TYPE_OF_GAME_OBJECT, function(prefabPath, prefab)
|
||||
if parent and parent:isDestroyed() then
|
||||
|
||||
@ -1,129 +1,134 @@
|
||||
local ActivityManager = class("ActivityManager", BaseModule)
|
||||
|
||||
function ActivityManager:showGoldPigUI(showType)
|
||||
UIManager:showUI("app/ui/activity/gold_pig/gold_pig_ui", {showType = showType})
|
||||
end
|
||||
|
||||
function ActivityManager:buyGoldPig(id)
|
||||
PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG)
|
||||
end
|
||||
|
||||
function ActivityManager:onBoughtGoldPigFinish(result)
|
||||
if result.status == 0 then
|
||||
DataManager.GoldPigData:onBought(result.pig)
|
||||
end
|
||||
end
|
||||
|
||||
-- 夏日活动分界线-----------------------------------------------------------------------------------------------------
|
||||
|
||||
function ActivityManager:showActivityUI(panelType)
|
||||
if panelType == GConst.ActivityConst.PANEL_TYPE.SKIN then
|
||||
UIManager:showUI("app/ui/activity/activity_gift_skin_ui", panelType)
|
||||
elseif panelType == GConst.ActivityConst.PANEL_TYPE.HERO then
|
||||
UIManager:showUI("app/ui/activity/activity_gift_hero_ui", panelType)
|
||||
else
|
||||
UIManager:showUI("app/ui/activity/activity_ui", panelType)
|
||||
end
|
||||
end
|
||||
|
||||
-- 购买夏日活动战令
|
||||
function ActivityManager:buySummerBounty(giftId)
|
||||
PayManager:purchasePackage(giftId, PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
||||
end
|
||||
|
||||
-- 初始化夏日活动计时器
|
||||
function ActivityManager:initSummerTimer()
|
||||
self:unscheduleGlobal(self.summerSid)
|
||||
|
||||
if DataManager.ActivityData:isActive() then
|
||||
Logger.logHighlight("夏日活动结束倒计时:"..DataManager.ActivityData:getEndRemainTime())
|
||||
self.summerSid = self:performWithDelayGlobal(function()
|
||||
-- 夏日活动结束
|
||||
Logger.logHighlight("夏日活动结束")
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.ACTIVITY_SUMMER_END)
|
||||
end, DataManager.ActivityData:getEndRemainTime())
|
||||
elseif DataManager.ActivityData:getStartRemainTime() > 0 then
|
||||
Logger.logHighlight("夏日活动开始倒计时:"..DataManager.ActivityData:getStartRemainTime())
|
||||
self.summerSid = self:performWithDelayGlobal(function()
|
||||
-- 夏日活动结束
|
||||
Logger.logHighlight("夏日活动开始")
|
||||
self:reqSummerData()
|
||||
end, DataManager.ActivityData:getStartRemainTime())
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求夏日活动数据
|
||||
function ActivityManager:reqSummerData()
|
||||
if not DataManager.ActivityData:isOpen() then
|
||||
return
|
||||
end
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerDataReq, {}, {}, self.rspSummerData, nil)
|
||||
end
|
||||
|
||||
function ActivityManager:rspSummerData(result)
|
||||
if result.summer then
|
||||
DataManager.ActivityData:onGetActData(result.summer)
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求夏日活动任务奖励
|
||||
function ActivityManager:reqSummerTaskReward(id)
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerTaskClaimReq, {id = id, stage = DataManager.ActivityData:getTaskStage(id)}, {}, self.rspSummerTaskReward, nil)
|
||||
end
|
||||
|
||||
function ActivityManager:rspSummerTaskReward(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.ActivityData:onReceivedTaskReward(result.reqData.id, result.stage, result.level, result.exp)
|
||||
|
||||
BIReport:postActOpt(BIReport.ACTIVITY_SUMMER.TASK_REWARD, DataManager.ActivityData:getActId(), DataManager.ActivityData:getBountyLevel(), DataManager.ActivityData:getBountyLevelScore(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求夏日活动战令奖励,id为0就是领取档位全部可领奖励
|
||||
function ActivityManager:reqSummerBountyReward(id, grade)
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimReq, {id = id, grade = grade}, {}, self.rspSummerBountyReward, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_REWARD)
|
||||
end
|
||||
|
||||
function ActivityManager:rspSummerBountyReward(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.ActivityData:onReceivedBountyReward(result.success_id_grade)
|
||||
|
||||
GFunc.showRewardBox(result.rewards)
|
||||
end
|
||||
end
|
||||
|
||||
-- 购买战令等级
|
||||
function ActivityManager:reqBuyBountyLevel()
|
||||
local cost = DataManager.ActivityData:getBuyBountyLevelCost()
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
if not GFunc.checkCost(costId, costNum, true) then
|
||||
return
|
||||
end
|
||||
local params ={
|
||||
titleTx = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_TITLE),
|
||||
content = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_COUNTENT),
|
||||
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
|
||||
showToday = GConst.MESSAGE_BOX_SHOW_TODAY.ACTIVITY_BUY_LEVEL,
|
||||
costId = costId,
|
||||
costNum = costNum,
|
||||
okFunc = function()
|
||||
local id = DataManager.ActivityData:getBountyCfg()[DataManager.ActivityData:getBountyLevel() + 1].id
|
||||
-- Logger.logHighlight("购买战令等级:"..id)
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimByDiamondReq, {id = id}, {}, self.rspBuyBountyLevel, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_LEVEL)
|
||||
end,
|
||||
}
|
||||
GFunc.showMessageBox(params)
|
||||
end
|
||||
|
||||
function ActivityManager:rspBuyBountyLevel(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.ActivityData:onBoughtBountyLevel()
|
||||
|
||||
BIReport:postActOpt(BIReport.ACTIVITY_SUMMER.BUY_LEVEL_UP, DataManager.ActivityData:getActId(), DataManager.ActivityData:getBountyLevel(), DataManager.ActivityData:getBountyLevelScore(), DataManager.ActivityData:getBuyBountyLevelCost())
|
||||
end
|
||||
end
|
||||
|
||||
-- 夏日活动分界线-----------------------------------------------------------------------------------------------------
|
||||
|
||||
local ActivityManager = class("ActivityManager", BaseModule)
|
||||
|
||||
function ActivityManager:showGoldPigUI(showType)
|
||||
UIManager:showUI("app/ui/activity/gold_pig/gold_pig_ui", {showType = showType})
|
||||
end
|
||||
|
||||
function ActivityManager:buyGoldPig(id)
|
||||
PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG)
|
||||
end
|
||||
|
||||
function ActivityManager:onBoughtGoldPigFinish(result)
|
||||
if result.status == 0 then
|
||||
DataManager.GoldPigData:onBought(result.pig)
|
||||
end
|
||||
end
|
||||
|
||||
-- 夏日活动分界线-----------------------------------------------------------------------------------------------------
|
||||
|
||||
function ActivityManager:showActivityUI(panelType)
|
||||
if panelType == GConst.ActivityConst.PANEL_TYPE.SKIN then
|
||||
UIManager:showUI("app/ui/activity/activity_gift_skin_ui", panelType)
|
||||
elseif panelType == GConst.ActivityConst.PANEL_TYPE.HERO then
|
||||
UIManager:showUI("app/ui/activity/activity_gift_hero_ui", panelType)
|
||||
else
|
||||
UIManager:showUI("app/ui/activity/activity_ui", panelType)
|
||||
end
|
||||
end
|
||||
|
||||
-- 购买夏日活动战令
|
||||
function ActivityManager:buySummerBounty(giftId)
|
||||
PayManager:purchasePackage(giftId, PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
||||
end
|
||||
|
||||
-- 初始化夏日活动计时器
|
||||
function ActivityManager:initSummerTimer()
|
||||
self:unscheduleGlobal(self.summerSid)
|
||||
|
||||
if DataManager.ActivityData:isActive() then
|
||||
Logger.logHighlight("夏日活动结束倒计时:"..DataManager.ActivityData:getEndRemainTime())
|
||||
self.summerSid = self:performWithDelayGlobal(function()
|
||||
-- 夏日活动结束
|
||||
Logger.logHighlight("夏日活动结束")
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.ACTIVITY_SUMMER_END)
|
||||
end, DataManager.ActivityData:getEndRemainTime())
|
||||
elseif DataManager.ActivityData:getStartRemainTime() > 0 then
|
||||
Logger.logHighlight("夏日活动开始倒计时:"..DataManager.ActivityData:getStartRemainTime())
|
||||
self.summerSid = self:performWithDelayGlobal(function()
|
||||
-- 夏日活动结束
|
||||
Logger.logHighlight("夏日活动开始")
|
||||
self:reqSummerData()
|
||||
end, DataManager.ActivityData:getStartRemainTime())
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求夏日活动数据
|
||||
function ActivityManager:reqSummerData()
|
||||
if not DataManager.ActivityData:isOpen() then
|
||||
return
|
||||
end
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerDataReq, {}, {}, self.rspSummerData, nil)
|
||||
end
|
||||
|
||||
function ActivityManager:rspSummerData(result)
|
||||
if result.summer then
|
||||
DataManager.ActivityData:onGetActData(result.summer)
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求夏日活动任务奖励
|
||||
function ActivityManager:reqSummerTaskReward(id)
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerTaskClaimReq, {id = id, stage = DataManager.ActivityData:getTaskStage(id)}, {}, self.rspSummerTaskReward, nil)
|
||||
end
|
||||
|
||||
function ActivityManager:rspSummerTaskReward(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.ActivityData:onReceivedTaskReward(result.reqData.id, result.stage, result.level, result.exp)
|
||||
|
||||
BIReport:postActOpt(BIReport.ACTIVITY_SUMMER.TASK_REWARD, DataManager.ActivityData:getActId(), DataManager.ActivityData:getBountyLevel(), DataManager.ActivityData:getBountyLevelScore(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求夏日活动战令奖励,id为0就是领取档位全部可领奖励
|
||||
function ActivityManager:reqSummerBountyReward(id, grade)
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimReq, {id = id, grade = grade}, {}, self.rspSummerBountyReward, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_REWARD)
|
||||
end
|
||||
|
||||
function ActivityManager:rspSummerBountyReward(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.ActivityData:onReceivedBountyReward(result.success_id_grade)
|
||||
|
||||
GFunc.showRewardBox(result.rewards)
|
||||
end
|
||||
end
|
||||
|
||||
-- 购买战令等级
|
||||
function ActivityManager:reqBuyBountyLevel()
|
||||
local cost = DataManager.ActivityData:getBuyBountyLevelCost()
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
if not GFunc.checkCost(costId, costNum, true) then
|
||||
return
|
||||
end
|
||||
local params ={
|
||||
titleTx = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_TITLE),
|
||||
content = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_COUNTENT),
|
||||
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
|
||||
showToday = GConst.MESSAGE_BOX_SHOW_TODAY.ACTIVITY_BUY_LEVEL,
|
||||
costId = costId,
|
||||
costNum = costNum,
|
||||
okFunc = function()
|
||||
local id = DataManager.ActivityData:getBountyCfg()[DataManager.ActivityData:getBountyLevel() + 1].id
|
||||
-- Logger.logHighlight("购买战令等级:"..id)
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimByDiamondReq, {id = id}, {}, self.rspBuyBountyLevel, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_LEVEL)
|
||||
end,
|
||||
}
|
||||
GFunc.showMessageBox(params)
|
||||
end
|
||||
|
||||
function ActivityManager:rspBuyBountyLevel(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.ActivityData:onBoughtBountyLevel()
|
||||
|
||||
BIReport:postActOpt(BIReport.ACTIVITY_SUMMER.BUY_LEVEL_UP, DataManager.ActivityData:getActId(), DataManager.ActivityData:getBountyLevel(), DataManager.ActivityData:getBountyLevelScore(), DataManager.ActivityData:getBuyBountyLevelCost())
|
||||
end
|
||||
end
|
||||
|
||||
-- 夏日活动分界线-----------------------------------------------------------------------------------------------------
|
||||
|
||||
-- region
|
||||
function ActivityManager:getActivityInCfg(actId)
|
||||
return ConfigManager:getConfig("activity")[actId] ~= nil
|
||||
end
|
||||
-- endregion
|
||||
return ActivityManager
|
||||
@ -43,7 +43,7 @@ NetManager.LOGIN_TYPE = {
|
||||
|
||||
function NetManager:getGate()
|
||||
if EDITOR_MODE then
|
||||
return "http://game.juzugame.com:3000"
|
||||
return "https://entrance.wdd817.link"
|
||||
else
|
||||
return "https://d3ksek7t8d0wbt.cloudfront.net/"
|
||||
end
|
||||
|
||||
8
lua/app/ui/activity/common.meta
Normal file
8
lua/app/ui/activity/common.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b74a22f76fd59422da92239b58ec8ffe
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
297
lua/app/ui/activity/common/act_base_ui.lua
Normal file
297
lua/app/ui/activity/common/act_base_ui.lua
Normal file
@ -0,0 +1,297 @@
|
||||
local ActBaseUI = class("ActBaseUI", BaseUI)
|
||||
|
||||
function ActBaseUI:ctor(params)
|
||||
self.page = params.page or self:getActConst().BOTTOM_PAGE.TURNTABLE
|
||||
self.ActConst = self:getActConst()
|
||||
end
|
||||
|
||||
function ActBaseUI:onClose()
|
||||
if self.subComps then
|
||||
for _, comp in pairs(self.subComps) do
|
||||
if comp.onClose then
|
||||
comp:onClose()
|
||||
end
|
||||
end
|
||||
end
|
||||
self.subComps = nil
|
||||
end
|
||||
|
||||
function ActBaseUI:onLoadRootComplete()
|
||||
self:_display()
|
||||
self:_addListeners()
|
||||
self:_bind()
|
||||
self:initComps()
|
||||
|
||||
self:updateCurrencyBar()
|
||||
|
||||
self:scheduleGlobal(function()
|
||||
self:updateTime()
|
||||
end, 0)
|
||||
self:updateTime()
|
||||
end
|
||||
|
||||
function ActBaseUI:_display()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.compsRoot = uiMap["act_main_ui.sub_comps"]
|
||||
self.closeBtn = uiMap["act_main_ui.node_down.close_btn"]
|
||||
self.titleBg = uiMap["act_main_ui.title_bg"]
|
||||
self.titleTx = uiMap["act_main_ui.title_bg.title_tx"]
|
||||
self.helpBtn = uiMap["act_main_ui.title_bg.help_btn"]
|
||||
self.timeTx = uiMap["act_main_ui.title_bg.time_bg.time_tx"]
|
||||
self.disableBg = uiMap["act_main_ui.disable_bg"]
|
||||
self.disableBg:setActive(false)
|
||||
|
||||
self.pageBtns = {}
|
||||
for k, idx in pairs(self:getActConst().BOTTOM_PAGE) do
|
||||
self.pageBtns[idx] = uiMap["act_main_ui.node_down.btns.page_btn_" .. idx]
|
||||
uiMap["act_main_ui.node_down.btns.page_btn_" .. idx .. ".text"]:setText(self:getCellName(idx))
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseUI:_addListeners()
|
||||
self.closeBtn:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
|
||||
if self.helpBtn then
|
||||
self.helpBtn:addClickListener(function()
|
||||
if self.getHelpStr then
|
||||
local params = {}
|
||||
params.desc = self:getHelpStr()
|
||||
ModuleManager.TipsManager:showHelpTips(params)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
for i, btn in ipairs(self.pageBtns) do
|
||||
btn:addClickListener(function()
|
||||
self:refreshPage(i)
|
||||
end, GConst.CLICK_SOUND.NONE)
|
||||
end
|
||||
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(params)
|
||||
if not self:isClosed() then
|
||||
self:closeUI()
|
||||
end
|
||||
end)
|
||||
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_GAME_OPT, function(params)
|
||||
if params.isSettlement and self.subComps[self:getActConst().BOTTOM_PAGE.GAME] then
|
||||
self.subComps[self:getActConst().BOTTOM_PAGE.GAME]:settlementGame()
|
||||
end
|
||||
if params.toGift then
|
||||
self.page = self:getActConst().BOTTOM_PAGE.GIFT
|
||||
self:onRefresh()
|
||||
end
|
||||
self:refreshPageBtns()
|
||||
end)
|
||||
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_TURNTABLE, function(params)
|
||||
if not self:isClosed() and self.page == self:getActConst().BOTTOM_PAGE.TURNTABLE then
|
||||
self.subComps[self.page]:playAni(params)
|
||||
end
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_BIG_REWARD_SHOW, function(params)
|
||||
if self:isClosed() then
|
||||
return
|
||||
end
|
||||
if self.page ~= self:getActConst().BOTTOM_PAGE.TURNTABLE then
|
||||
return
|
||||
end
|
||||
local rewards = DataManager[self:getActDataType()]:getBigRewards()
|
||||
if rewards == nil or #rewards == 0 then
|
||||
return
|
||||
end
|
||||
ModuleManager.ActivityManager:showBigRewardUI(self, rewards)
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_TRIGGER_GIFT, function()
|
||||
if not self:isClosed() and self.page == self:getActConst().BOTTOM_PAGE.TURNTABLE then
|
||||
self.subComps[self.page]:updateTriggerGift()
|
||||
end
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_TURNTABLE_RESET, function()
|
||||
if not self:isClosed() and self.page == self:getActConst().BOTTOM_PAGE.TURNTABLE then
|
||||
self.subComps[self.page]:updateTurntable()
|
||||
end
|
||||
end)
|
||||
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_ACTIVITY_PAGE, function(params)
|
||||
self:refreshPage(params)
|
||||
end)
|
||||
end
|
||||
|
||||
function ActBaseUI:_bind()
|
||||
self:bind(DataManager.PaymentData, "isDirty", function()
|
||||
self.subComps[self.page]:refresh(self, self:getActDataType())
|
||||
self:onRefresh()
|
||||
end)
|
||||
|
||||
self:bind(DataManager[self:getActDataType()], "isDirty", function()
|
||||
if self.page == self:getActConst().BOTTOM_PAGE.GAME then
|
||||
self.subComps[self.page]:refreshStepRewardScrollrect()
|
||||
else
|
||||
self.subComps[self.page]:refresh(self, self:getActDataType())
|
||||
end
|
||||
self:refreshPageBtns()
|
||||
end)
|
||||
self:bind(DataManager.ActTaskData, "isDirty", function()
|
||||
self:refreshPageBtns()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActBaseUI:refreshPage(page)
|
||||
-- if self.page == page then
|
||||
-- return
|
||||
-- end
|
||||
self.page = page
|
||||
self:onRefresh()
|
||||
end
|
||||
|
||||
function ActBaseUI:initComps()
|
||||
if self.subComps then
|
||||
return
|
||||
end
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.subComps = {}
|
||||
|
||||
for k, id in pairs(self:getActConst().BOTTOM_PAGE) do
|
||||
if self:getActConst().COMP_NAME[id] then
|
||||
-- 预制体挂载
|
||||
self.subComps[id] = CellManager:addCellComp(uiMap[self:getActConst().COMP_NAME[id]], self:getActConst().COMP[id])
|
||||
if self.subComps[id].setParentUI then
|
||||
self.subComps[id]:setParentUI(self, self:getActDataType())
|
||||
end
|
||||
elseif self:getActConst().COMP_PATH[id] then
|
||||
-- 动态加载
|
||||
self:loadModule(self:getActConst().COMP_PATH[id], self.compsRoot, self:getActConst().COMP[id], function(comp)
|
||||
comp:getBaseObject():setActive(false)
|
||||
self.subComps[id] = comp
|
||||
if self.subComps[id].setParentUI then
|
||||
self.subComps[id]:setParentUI(self, self:getActDataType())
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if self:getActConst().BOTTOM_PAGE.GAME then
|
||||
local order = self._baseRootCanvas.sortingOrder
|
||||
self.subComps[self:getActConst().BOTTOM_PAGE.GAME]:getBaseObject():setActive(true)
|
||||
local uiHelper = self.subComps[self:getActConst().BOTTOM_PAGE.GAME]:getGameObject():GetComponent(GConst.TYPEOF_UNITY_CLASS.BF_UI_HELPER)
|
||||
if uiHelper then
|
||||
uiHelper:SetSortingOrder(order + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseUI:updateTime()
|
||||
if DataManager[self:getActDataType()]:getRemainTime() <= 0 then
|
||||
self:closeUI()
|
||||
return
|
||||
end
|
||||
|
||||
local remainTime = DataManager[self:getActDataType()]:getRemainTime()
|
||||
if self.cacheRemainTime ~= remainTime then
|
||||
self.cacheRemainTime = remainTime
|
||||
if remainTime > 0 then
|
||||
self.timeTx:setText(I18N:getGlobalText(I18N.GlobalConst.TIME_END_DESC_1, Time:formatNumTimeStr(remainTime)))
|
||||
end
|
||||
end
|
||||
|
||||
for i,v in ipairs(self.subComps) do
|
||||
if v.updateTime then
|
||||
v:updateTime()
|
||||
end
|
||||
end
|
||||
|
||||
if self.subComps[self:getActConst().BOTTOM_PAGE.TURNTABLE] then
|
||||
self.subComps[self:getActConst().BOTTOM_PAGE.TURNTABLE]:updateAni()
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseUI:onRefresh()
|
||||
self:refreshPanel()
|
||||
self:refreshPageBtns()
|
||||
|
||||
self.titleBg:setActive(self.page == self:getActConst().BOTTOM_PAGE.TURNTABLE)
|
||||
self.titleTx:setText(self:getCellName(self.page))
|
||||
if self.helpBtn then
|
||||
self.helpBtn:setActive(self.page == self:getActConst().BOTTOM_PAGE.GAME)
|
||||
|
||||
-- 特殊处理
|
||||
if self:getActDataType() == "ActSailingData" then
|
||||
self.helpBtn:setActive(self.page == self:getActConst().BOTTOM_PAGE.TURNTABLE)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseUI:refreshPanel()
|
||||
for i, comp in ipairs(self.subComps) do
|
||||
comp.baseObject:setActive(i == self.page)
|
||||
if i == self.page then
|
||||
comp:refresh(self, self:getActDataType())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseUI:refreshPageBtns()
|
||||
for i, btn in ipairs(self.pageBtns) do
|
||||
local atlas = GConst.ATLAS_PATH.UI_ACT_COMMON
|
||||
-- 特殊处理
|
||||
if self:getActDataType() == "ActMagicData" then
|
||||
atlas = GConst.ATLAS_PATH.UI_ACT_MAGIC
|
||||
end
|
||||
|
||||
if self.page == i then
|
||||
btn:setSprite(atlas, self:getPageBtnName(i, true))
|
||||
else
|
||||
btn:setSprite(atlas, self:getPageBtnName(i, false))
|
||||
end
|
||||
|
||||
if DataManager[self:getActDataType()]:getRpByPage(i) then
|
||||
btn:addRedPoint(32, 20, 1)
|
||||
else
|
||||
btn:removeRedPoint()
|
||||
end
|
||||
end
|
||||
self:updateCurrencyBar()
|
||||
end
|
||||
|
||||
function ActBaseUI:disableUITouchSelf()
|
||||
self.disableBg:setActive(true)
|
||||
end
|
||||
|
||||
function ActBaseUI:enableUITouchSelf()
|
||||
self.disableBg:setActive(false)
|
||||
end
|
||||
|
||||
-- 界面显示通用方法
|
||||
|
||||
function ActBaseUI:getTaskBannerSize()
|
||||
return 1280, 319
|
||||
end
|
||||
|
||||
function ActBaseUI:getBountyBannerSize()
|
||||
return 1280, 319
|
||||
end
|
||||
|
||||
function ActBaseUI:getShowBountyBg()
|
||||
return true, "common_bg_4"
|
||||
end
|
||||
|
||||
function ActBaseUI:isShowBannerLine1()
|
||||
return true
|
||||
end
|
||||
|
||||
function ActBaseUI:isShowBannerLine2()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActBaseUI:getShowExchangeBg()
|
||||
return true, "assets/arts/textures/background/act_dream/act_dream_bg_2.png"
|
||||
end
|
||||
|
||||
function ActBaseUI:getExchangeTopBg()
|
||||
return true, "assets/arts/textures/background/banner/banner_shop_1.png"
|
||||
end
|
||||
|
||||
return ActBaseUI
|
||||
10
lua/app/ui/activity/common/act_base_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_base_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abe1a937f54a14461ab22b39a661db1a
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
83
lua/app/ui/activity/common/act_big_reward_ui.lua
Normal file
83
lua/app/ui/activity/common/act_big_reward_ui.lua
Normal file
@ -0,0 +1,83 @@
|
||||
local ActBigRewardUI = class("ActBigRewardUI", BaseUI)
|
||||
|
||||
function ActBigRewardUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActBigRewardUI:showCommonBG()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActBigRewardUI:getPrefabPath()
|
||||
return "assets/prefabs/ui/activity/common/act_big_reward_ui.prefab"
|
||||
end
|
||||
|
||||
function ActBigRewardUI:onPressBackspace()
|
||||
self:closeUI()
|
||||
end
|
||||
|
||||
function ActBigRewardUI:onClose()
|
||||
end
|
||||
|
||||
function ActBigRewardUI:ctor(param)
|
||||
self.actUI = param.actUI
|
||||
self.rewards = param.rewards
|
||||
self.idx = 1
|
||||
end
|
||||
|
||||
function ActBigRewardUI:onLoadRootComplete()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.spineTitle = uiMap["act_big_reward_ui.spine_title"]
|
||||
self.txTitle = uiMap["act_big_reward_ui.tx_title"]
|
||||
self.rewardCell = uiMap["act_big_reward_ui.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.btnJump = uiMap["act_big_reward_ui.btn_jump"]
|
||||
self.txJump = uiMap["act_big_reward_ui.btn_jump.tx_jump"]
|
||||
self.txTips = uiMap["act_big_reward_ui.tx_tips"]
|
||||
self.mask = uiMap["act_big_reward_ui.mask"]
|
||||
|
||||
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_GET_1))
|
||||
self.txJump:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_GET_2))
|
||||
self.txTips:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_GET_3))
|
||||
self.spineTitle:playAnimComplete("born", false, true, function()
|
||||
self.spineTitle:playAnim("idle", true, true, true)
|
||||
end)
|
||||
|
||||
self.btnJump:addClickListener(function()
|
||||
if self.actUI and self.actUI.refreshPage then
|
||||
self.actUI:refreshPage(self.actUI.ActConst.BOTTOM_PAGE.EXCHANGE)
|
||||
end
|
||||
self:closeUI()
|
||||
end)
|
||||
self.txTips:addClickListener(function()
|
||||
if self.idx < #self.rewards then
|
||||
self.idx = self.idx + 1
|
||||
self:onRefresh()
|
||||
else
|
||||
self:closeUI()
|
||||
end
|
||||
end)
|
||||
self.mask:addClickListener(function()
|
||||
if self.idx < #self.rewards then
|
||||
self.idx = self.idx + 1
|
||||
self:onRefresh()
|
||||
else
|
||||
self:closeUI()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ActBigRewardUI:onRefresh()
|
||||
self.rewardCell:refresh(self.rewards[self.idx])
|
||||
|
||||
if self.actUI.notHasBigRewardJump and self.actUI:notHasBigRewardJump() then
|
||||
-- 无跳转兑换
|
||||
self.btnJump:setActive(false)
|
||||
self.txTips:setText(I18N:getGlobalText(I18N.GlobalConst.DIVINATION_DESC_7))
|
||||
else
|
||||
-- 有跳转兑换
|
||||
self.btnJump:setActive(true)
|
||||
self.txTips:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_GET_3))
|
||||
end
|
||||
end
|
||||
|
||||
return ActBigRewardUI
|
||||
10
lua/app/ui/activity/common/act_big_reward_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_big_reward_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82598f326b8294ed9840700057942a72
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
167
lua/app/ui/activity/common/act_ferrule_preview_ui.lua
Normal file
167
lua/app/ui/activity/common/act_ferrule_preview_ui.lua
Normal file
@ -0,0 +1,167 @@
|
||||
local ActFerrulePreviewUI = class("ActFerrulePreviewUI", BaseUI)
|
||||
|
||||
local PREVIEW_CELL = "app/ui/activity/common/cell/ferrule_preview_cell"
|
||||
|
||||
function ActFerrulePreviewUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:getPrefabPath()
|
||||
return "assets/prefabs/ui/activity/common/act_ferrule_preview_ui.prefab"
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:ctor(params)
|
||||
self.parentUI = params.parentUI
|
||||
self.dataKey = params.dataKey
|
||||
self.data = DataManager[params.dataKey]
|
||||
self.qltInfo = self.data:getSummerQltInfo()
|
||||
self.addY = 314
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:onLoadRootComplete()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.mask = uiMap["act_ferrule_preview_ui.mask"]
|
||||
self.txTitle = uiMap["act_ferrule_preview_ui.bg.tx_title"]
|
||||
self.btnClose = uiMap["act_ferrule_preview_ui.bg.btn_close"]
|
||||
self.content = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content"]
|
||||
self.txTips = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_title.tx_tips"]
|
||||
self.txScoreDescs = {}
|
||||
self.txScoreNums = {}
|
||||
for i = 1, GConst.PetConst.QUALITY_NUM do
|
||||
table.insert(self.txScoreDescs, uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_title.score_" .. i .. ".tx_desc"])
|
||||
table.insert(self.txScoreNums, uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_title.score_" .. i .. ".tx_score"])
|
||||
end
|
||||
self.bg2 = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_2"]
|
||||
self.descTx = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_2.desc_tx"]
|
||||
self.scrollrect = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_2.scrollrect"]
|
||||
self.bg3 = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_3"]
|
||||
self.descTx = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_3.desc_tx"]
|
||||
self.scrollrect = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_3.scrollrect"]
|
||||
self.bg4 = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_4"]
|
||||
self.descTx = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_4.desc_tx"]
|
||||
self.scrollrect = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_4.scrollrect"]
|
||||
self.bg5 = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_5"]
|
||||
self.descTx = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_5.desc_tx"]
|
||||
self.scrollrect = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_5.scrollrect"]
|
||||
|
||||
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_7))
|
||||
self.txTips:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_8))
|
||||
for qlt, tx in ipairs(self.txScoreDescs) do
|
||||
tx:setText(self:getQltColor(I18N:getGlobalText(I18N.GlobalConst["ACT_VALENTINE_DESC_" .. 19 - qlt]), qlt + 1))
|
||||
end
|
||||
for qlt, tx in ipairs(self.txScoreNums) do
|
||||
local info = self.qltInfo[qlt] or {{point = 0}}
|
||||
tx:setText(self:getQltColor(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_19, info[1].point), qlt + 1))
|
||||
end
|
||||
|
||||
self.btnClose:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:onRefresh()
|
||||
self:refreshQlt5()
|
||||
self:refreshQlt4()
|
||||
self:refreshQlt3()
|
||||
self:refreshQlt2()
|
||||
self.content:setSizeDeltaY(self.addY)
|
||||
self.content:setAnchoredPositionY(0)
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:refreshQlt5()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local bg = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_5"]
|
||||
uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_5.desc_tx"]:setText(self:getQltColor(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_15), 5))
|
||||
bg:setAnchoredPositionY(-self.addY)
|
||||
local qltInfo = self.qltInfo[4] or {}
|
||||
local count = #qltInfo
|
||||
local line = (count - 1) // 5 + 1
|
||||
local addY = line * 105 + 70
|
||||
bg:setSizeDeltaY(addY)
|
||||
local scrollRectObj = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_5.scrollrect"]
|
||||
local scrollRect = scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
scrollRect:addInitCallback(function()
|
||||
return PREVIEW_CELL
|
||||
end)
|
||||
scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(qltInfo[index].pet)
|
||||
end)
|
||||
scrollRect:clearCells()
|
||||
scrollRect:refillCells(count)
|
||||
self.addY = self.addY + addY + 20
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:refreshQlt4()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local bg = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_4"]
|
||||
uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_4.desc_tx"]:setText(self:getQltColor(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_16), 4))
|
||||
bg:setAnchoredPositionY(-self.addY)
|
||||
local qltInfo = self.qltInfo[3] or {}
|
||||
local count = #qltInfo
|
||||
local line = (count - 1) // 5 + 1
|
||||
local addY = line * 105 + 70
|
||||
bg:setSizeDeltaY(addY)
|
||||
local scrollRectObj = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_4.scrollrect"]
|
||||
local scrollRect = scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
scrollRect:addInitCallback(function()
|
||||
return PREVIEW_CELL
|
||||
end)
|
||||
scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(qltInfo[index].pet)
|
||||
end)
|
||||
scrollRect:clearCells()
|
||||
scrollRect:refillCells(count)
|
||||
self.addY = self.addY + addY + 20
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:refreshQlt3()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local bg = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_3"]
|
||||
uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_3.desc_tx"]:setText(self:getQltColor(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_17), 3))
|
||||
bg:setAnchoredPositionY(-self.addY)
|
||||
local qltInfo = self.qltInfo[2] or {}
|
||||
local count = #qltInfo
|
||||
local line = (count - 1) // 5 + 1
|
||||
local addY = line * 105 + 70
|
||||
bg:setSizeDeltaY(addY)
|
||||
local scrollRectObj = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_3.scrollrect"]
|
||||
local scrollRect = scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
scrollRect:addInitCallback(function()
|
||||
return PREVIEW_CELL
|
||||
end)
|
||||
scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(qltInfo[index].pet)
|
||||
end)
|
||||
scrollRect:clearCells()
|
||||
scrollRect:refillCells(count)
|
||||
self.addY = self.addY + addY + 20
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:refreshQlt2()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local bg = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_2"]
|
||||
uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_2.desc_tx"]:setText(self:getQltColor(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_18), 2))
|
||||
bg:setAnchoredPositionY(-self.addY)
|
||||
local qltInfo = self.qltInfo[1] or {}
|
||||
local count = #qltInfo
|
||||
local line = (count - 1) // 5 + 1
|
||||
local addY = line * 105 + 70
|
||||
bg:setSizeDeltaY(addY)
|
||||
local scrollRectObj = uiMap["act_ferrule_preview_ui.bg.content.scrollrect.viewport.content.bg_2.scrollrect"]
|
||||
local scrollRect = scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
scrollRect:addInitCallback(function()
|
||||
return PREVIEW_CELL
|
||||
end)
|
||||
scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(qltInfo[index].pet)
|
||||
end)
|
||||
scrollRect:clearCells()
|
||||
scrollRect:refillCells(count)
|
||||
self.addY = self.addY + addY + 20
|
||||
end
|
||||
|
||||
function ActFerrulePreviewUI:getQltColor(str, qlt)
|
||||
return GFunc.colorText(GFunc.getQltColor(qlt), str)
|
||||
end
|
||||
|
||||
return ActFerrulePreviewUI
|
||||
10
lua/app/ui/activity/common/act_ferrule_preview_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_ferrule_preview_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a643317f1fef34876b478a60ee1e95fe
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
109
lua/app/ui/activity/common/act_fish_preview_ui.lua
Normal file
109
lua/app/ui/activity/common/act_fish_preview_ui.lua
Normal file
@ -0,0 +1,109 @@
|
||||
local ActFishPreviewUI = class("ActFishPreviewUI", BaseUI)
|
||||
|
||||
local FISH_PREVIEW_CELL = "app/ui/activity/common/cell/fish_preview_cell"
|
||||
|
||||
function ActFishPreviewUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActFishPreviewUI:getPrefabPath()
|
||||
return "assets/prefabs/ui/activity/common/act_fish_preview_ui.prefab"
|
||||
end
|
||||
|
||||
function ActFishPreviewUI:ctor(params)
|
||||
self.addY = 437
|
||||
self.parentUI = params.parentUI
|
||||
self.dataKey = params.dataKey
|
||||
self.data = DataManager[params.dataKey]
|
||||
end
|
||||
|
||||
function ActFishPreviewUI:onLoadRootComplete()
|
||||
self:_display()
|
||||
self:_addListeners()
|
||||
end
|
||||
|
||||
function ActFishPreviewUI:_display()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
uiMap["act_fish_preview_ui.bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_11))
|
||||
self:refreshTitle()
|
||||
self:refreshRewards()
|
||||
|
||||
uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content"]:setSizeDeltaY(self.addY + 16)
|
||||
uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content"]:setAnchoredPositionY(0)
|
||||
|
||||
uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg.tx_title"]:setText(self.parentUI:getFishScoreDesc())
|
||||
|
||||
self:bind(self.data, "isDirty", function()
|
||||
self:refreshRewards()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActFishPreviewUI:_addListeners()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
uiMap["act_fish_preview_ui.bg.close_btn"]:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActFishPreviewUI:refreshTitle()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg_title.tx_title"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_7))
|
||||
uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg_title.tx_desc_1"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_12))
|
||||
uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg_title.tx_desc_2"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_13))
|
||||
|
||||
if not self.randomFishInfo then
|
||||
self.randomFishInfo = {}
|
||||
for id, info in pairs(ConfigManager:getConfig("act_active_fish")) do
|
||||
local newInfo = GFunc.getTable(info)
|
||||
self.randomFishInfo[info.qlt] = newInfo
|
||||
end
|
||||
end
|
||||
|
||||
for qlt = 2, 5 do
|
||||
local info = self.randomFishInfo[qlt]
|
||||
for i = 1, 3 do
|
||||
if info then
|
||||
local bg = uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg_title.img_bg_" .. qlt .. "_" .. i]
|
||||
bg:setVisible(info.art[i])
|
||||
if info.art[i] then
|
||||
local icon = uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg_title.img_bg_" .. qlt .. "_" .. i .. ".img_icon"]
|
||||
icon:setSprite(GConst.ATLAS_PATH.UI_ACT_NEW_NEW, info.art[i] .. "_s")
|
||||
end
|
||||
else
|
||||
local bg = uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg_title.img_bg_" .. qlt .. "_" .. i]
|
||||
bg:setVisible(false)
|
||||
end
|
||||
end
|
||||
uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg_title.tx_score_" .. qlt]:setText("+" .. (info and info.point or 0))
|
||||
end
|
||||
end
|
||||
|
||||
function ActFishPreviewUI:refreshRewards()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local bg = uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg"]
|
||||
self.rewardList = self.data:getGameTargetCfgList()
|
||||
self.rewardListCount = #self.rewardList
|
||||
local count = #self.rewardList
|
||||
local line = (count - 1) // 6 + 1
|
||||
local addY = line * 121 + 10
|
||||
bg:setSizeDeltaY(addY)
|
||||
local scrollRectObj = uiMap["act_fish_preview_ui.bg.scrollrect.viewport.content.bg.scrollrect"]
|
||||
if self.scrollRect then
|
||||
self.scrollRect:updateAllCell()
|
||||
return
|
||||
end
|
||||
scrollRectObj:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).enabled = true
|
||||
self.scrollRect = scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return FISH_PREVIEW_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.parentUI, self.dataKey, self.rewardList[index].id, index >= self.rewardListCount)
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(count)
|
||||
self.addY = self.addY + addY
|
||||
scrollRectObj:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).enabled = false
|
||||
end
|
||||
|
||||
return ActFishPreviewUI
|
||||
10
lua/app/ui/activity/common/act_fish_preview_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_fish_preview_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84b23d4e867b745adaf2859d8b5f7f85
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
146
lua/app/ui/activity/common/act_gift_ui.lua
Normal file
146
lua/app/ui/activity/common/act_gift_ui.lua
Normal file
@ -0,0 +1,146 @@
|
||||
local ActGiftUI = class("ActGiftUI", BaseUI)
|
||||
|
||||
function ActGiftUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActGiftUI:showCommonBG()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActGiftUI:getPrefabPath()
|
||||
return self.prefabPath
|
||||
end
|
||||
|
||||
function ActGiftUI:onPressBackspace()
|
||||
self:closeUI()
|
||||
end
|
||||
|
||||
function ActGiftUI:onClose()
|
||||
end
|
||||
|
||||
function ActGiftUI:ctor(param)
|
||||
self.actId = param.actId
|
||||
self.prefabPath = param.prefabPath
|
||||
self.giftIds = DataManager.ActGiftData:getTriggerGiftIdsByActId(self.actId)
|
||||
self.curIndex = 1
|
||||
end
|
||||
|
||||
function ActGiftUI:onLoadRootComplete()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.txTitle = uiMap["act_gift_ui.content.tx_title"]
|
||||
self.imgTime = uiMap["act_gift_ui.content.time_node.img_time"]
|
||||
self.txTime = uiMap["act_gift_ui.content.time_node.tx_time"]
|
||||
self.rewardCells = {}
|
||||
for i = 1, 2 do
|
||||
table.insert(self.rewardCells, uiMap["act_gift_ui.content.reward_node.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL))
|
||||
end
|
||||
self.btnRight = uiMap["act_gift_ui.content.btn_right"]
|
||||
self.btnLeft = uiMap["act_gift_ui.content.btn_left"]
|
||||
self.btnBuy = uiMap["act_gift_ui.content.btn_buy"]
|
||||
self.txBuy = uiMap["act_gift_ui.content.btn_buy.tx_buy"]
|
||||
self.offNode = uiMap["act_gift_ui.content.off_node"]
|
||||
self.txOff = uiMap["act_gift_ui.content.off_node.tx_off"]
|
||||
self.btnClose = uiMap["act_gift_ui.btn_close"]
|
||||
self.layout = uiMap["act_gift_ui.content.layout"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT)
|
||||
self.tags = {}
|
||||
for i = 1, 10 do
|
||||
table.insert(self.tags, uiMap["act_gift_ui.content.layout.tag_" .. i])
|
||||
end
|
||||
|
||||
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_DESC_1))
|
||||
|
||||
self:scheduleGlobal(function()
|
||||
self:updateTime()
|
||||
end, 1)
|
||||
self:updateTime()
|
||||
|
||||
self.btnBuy:addClickListener(function()
|
||||
ModuleManager.ActivityManager:onGiftBuy(self.giftIds[self.curIndex])
|
||||
end)
|
||||
self.btnLeft:addClickListener(function()
|
||||
if self.curIndex <= 1 then
|
||||
return
|
||||
end
|
||||
self:onChangeSelect(self.curIndex - 1)
|
||||
end)
|
||||
self.btnRight:addClickListener(function()
|
||||
if self.curIndex >= #self.giftIds then
|
||||
return
|
||||
end
|
||||
self:onChangeSelect(self.curIndex + 1)
|
||||
end)
|
||||
self.btnClose:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
self:bind(DataManager.PaymentData, "isDirty", function()
|
||||
self:onGiftChange()
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.ACT_TRIGGER_GIFT, function()
|
||||
self:onGiftChange()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGiftUI:updateTime()
|
||||
local remainTime = DataManager.ActGiftData:getTriggerGiftEndTime(self.actId, self.giftIds[self.curIndex]) - Time:getServerTime()
|
||||
if remainTime > 0 then
|
||||
self.txTime:setText(I18N:getGlobalText(I18N.GlobalConst.TIME_END_DESC_1, Time:formatNumTimeStr(remainTime)))
|
||||
else
|
||||
self:onGiftChange()
|
||||
end
|
||||
end
|
||||
|
||||
function ActGiftUI:onGiftChange()
|
||||
self.giftIds = DataManager.ActGiftData:getTriggerGiftIdsByActId(self.actId)
|
||||
if self.giftIds and #self.giftIds > 0 then
|
||||
self:onChangeSelect(1)
|
||||
self:onRefresh()
|
||||
else
|
||||
self:closeUI()
|
||||
end
|
||||
end
|
||||
|
||||
function ActGiftUI:onChangeSelect(idx)
|
||||
self.curIndex = idx
|
||||
self:updateTime()
|
||||
self:onRefresh()
|
||||
end
|
||||
|
||||
function ActGiftUI:onRefresh()
|
||||
local giftId = self.giftIds[self.curIndex]
|
||||
local giftCfg = ConfigManager:getConfig("act_gift")[giftId]
|
||||
local rewards = giftCfg.reward
|
||||
|
||||
for i, cell in ipairs(self.rewardCells) do
|
||||
if rewards and rewards[i] then
|
||||
cell:showCell()
|
||||
cell:refreshByConfig(rewards[i])
|
||||
else
|
||||
cell:hideCell()
|
||||
end
|
||||
end
|
||||
|
||||
self.btnLeft:setActive(self.curIndex > 1)
|
||||
self.btnRight:setActive(self.curIndex < #self.giftIds)
|
||||
|
||||
self.txBuy:setText(GFunc.getFormatPrice(giftCfg.recharge_id))
|
||||
self.offNode:setActive(giftCfg.value ~= nil)
|
||||
self.txOff:setText("-" .. giftCfg.value .. "%")
|
||||
|
||||
for i, tag in ipairs(self.tags) do
|
||||
if self.giftIds[i] then
|
||||
tag:setActive(true)
|
||||
tag:setSprite(GConst.ATLAS_PATH.COMMON, self.curIndex == i and "common_point_2" or "common_point_3")
|
||||
tag:addClickListener(function()
|
||||
self:onChangeSelect(i)
|
||||
end)
|
||||
else
|
||||
tag:setActive(false)
|
||||
end
|
||||
end
|
||||
self.layout:RefreshLayout()
|
||||
|
||||
GFunc.centerImgAndTx(self.imgTime, self.txTime, 3)
|
||||
end
|
||||
|
||||
return ActGiftUI
|
||||
10
lua/app/ui/activity/common/act_gift_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_gift_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 866ce8fae1c40427db75301ef409a8eb
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
141
lua/app/ui/activity/common/act_pop_ui.lua
Normal file
141
lua/app/ui/activity/common/act_pop_ui.lua
Normal file
@ -0,0 +1,141 @@
|
||||
local ActPopUI = class("ActPopUI", BaseUI)
|
||||
|
||||
function ActPopUI:ctor(parmas)
|
||||
self.parmas = parmas or {}
|
||||
self.data = DataManager[parmas.dataKey]
|
||||
self.actId = self.data:getActId()
|
||||
end
|
||||
|
||||
function ActPopUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActPopUI:getOpenSoundId()
|
||||
end
|
||||
|
||||
function ActPopUI:getPrefabPath()
|
||||
return self.parmas.prefabPath
|
||||
end
|
||||
|
||||
function ActPopUI:onClose()
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP)
|
||||
end
|
||||
|
||||
function ActPopUI:onPressBackspace()
|
||||
self:closeUI()
|
||||
end
|
||||
|
||||
function ActPopUI:onLoadRootComplete()
|
||||
self.uiMap = self.root:genAllChildren()
|
||||
self.uiMap["act_pop_ui.mask"]:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
self.uiMap["act_pop_ui.bg.close_btn"]:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
self.titleTx = self.uiMap["act_pop_ui.bg.title_tx"]
|
||||
self.descTx = self.uiMap["act_pop_ui.bg.desc_tx"]
|
||||
self.funcBtn = self.uiMap["act_pop_ui.bg.func_btn"]
|
||||
self.funcBtnTx = self.uiMap["act_pop_ui.bg.func_btn.text"]
|
||||
self.spineObj = self.uiMap["act_pop_ui.bg.ui_spine_obj"]
|
||||
self.spineObj:playAnimComplete("born", false, true, function()
|
||||
self.spineObj:playAnim("idle", true, true)
|
||||
end)
|
||||
|
||||
self:setTextVisible(false)
|
||||
self:performWithDelayGlobal(function()
|
||||
self:setTextVisible(true)
|
||||
end,0.2)
|
||||
|
||||
self.titleTx:setText(self.data:getActNameStr())
|
||||
self.funcBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_GO))
|
||||
|
||||
self.funcBtn:addClickListener(function()
|
||||
if self.parmas.callback then
|
||||
self.parmas.callback()
|
||||
end
|
||||
self:closeUI()
|
||||
end)
|
||||
self:refreshShowReward()
|
||||
self:addPopBar()
|
||||
|
||||
self:scheduleGlobal(function()
|
||||
self:updateTime()
|
||||
end, 1)
|
||||
self:updateTime()
|
||||
|
||||
self:bind(self.data, "isDirty", function(binder, value)
|
||||
local actId = self.data:getActId()
|
||||
if self.actId == nil or self.actId == 0 then
|
||||
self.actId = actId
|
||||
elseif self.actId ~= actId then
|
||||
self:closeUI()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ActPopUI:setTextVisible(visible)
|
||||
self.titleTx:setActive(visible)
|
||||
self.descTx:setActive(visible)
|
||||
self.funcBtnTx:setActive(visible)
|
||||
end
|
||||
|
||||
function ActPopUI:refreshShowReward()
|
||||
local cfg = ConfigManager:getConfig("activity")
|
||||
local actId = self.data:getActId()
|
||||
for i = 1, 5 do
|
||||
local rewardObj = self.uiMap["act_pop_ui.bg.reward_node.reward_cell_" .. i]
|
||||
if rewardObj then
|
||||
local rewardCell = rewardObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
if actId and cfg[actId] then
|
||||
local reward = cfg[actId].show_reward[i]
|
||||
if reward then
|
||||
rewardCell:refreshByConfig(reward)
|
||||
rewardCell:hideRewardNum()
|
||||
rewardCell:setActive(true)
|
||||
else
|
||||
rewardCell:setActive(false)
|
||||
end
|
||||
else
|
||||
rewardCell:setActive(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
local descTx = self.uiMap["act_pop_ui.bg.desc_tx_2"]
|
||||
local currLanguage = I18N:getCurLanguage()
|
||||
if currLanguage == GConst.LANGUAGE.CHINESE_TC or currLanguage == GConst.LANGUAGE.CHINESE then
|
||||
descTx:setSizeDeltaX(520)
|
||||
else
|
||||
descTx:setSizeDeltaX(580)
|
||||
end
|
||||
if actId then
|
||||
local rewardTx = cfg[actId].txt
|
||||
if rewardTx and #rewardTx >= 3 then
|
||||
local name1 = GFunc.getRewardName(rewardTx[1], true)
|
||||
local name2 = GFunc.getRewardName(rewardTx[2], true)
|
||||
local name3 = GFunc.getRewardName(rewardTx[3], true)
|
||||
descTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_TURNTABLE_DESC_3, name1, name2, name3))
|
||||
else
|
||||
descTx:setText(GConst.EMPTY_STRING)
|
||||
end
|
||||
else
|
||||
descTx:setText(GConst.EMPTY_STRING)
|
||||
end
|
||||
end
|
||||
|
||||
function ActPopUI:updateTime()
|
||||
local remainTime = self.data:getRemainTime()
|
||||
if remainTime <= 0 then
|
||||
self:closeUI()
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP)
|
||||
return
|
||||
end
|
||||
self.descTx:setText(I18N:getGlobalText(I18N.GlobalConst.TIME_END_DESC_1, Time:formatNumTimeStr(remainTime)))
|
||||
end
|
||||
|
||||
-- 显示今日不再提示
|
||||
function ActPopUI:addPopBar()
|
||||
ModuleManager.ActivityPopManager:addPopBar(self.root)
|
||||
end
|
||||
|
||||
return ActPopUI
|
||||
10
lua/app/ui/activity/common/act_pop_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_pop_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 033d4f062d2f6477f9eb663210d2cfb4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
45
lua/app/ui/activity/common/act_preview_ui.lua
Normal file
45
lua/app/ui/activity/common/act_preview_ui.lua
Normal file
@ -0,0 +1,45 @@
|
||||
local ActPreviewUI = class("ActPreviewUI", BaseUI)
|
||||
|
||||
function ActPreviewUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActPreviewUI:getPrefabPath()
|
||||
return "assets/prefabs/ui/activity/common/act_preview_ui.prefab"
|
||||
end
|
||||
|
||||
function ActPreviewUI:ctor(pramas)
|
||||
self.rewardList = pramas.rewardList or {}
|
||||
self.rewardWeight = {}
|
||||
self.descStr = pramas.descStr or ""
|
||||
local maxWeight = 0
|
||||
for i,v in ipairs(pramas.rewardWeight or {}) do
|
||||
maxWeight = maxWeight + v
|
||||
end
|
||||
for i,v in ipairs(pramas.rewardWeight or {}) do
|
||||
self.rewardWeight[i] = v / maxWeight
|
||||
end
|
||||
end
|
||||
|
||||
function ActPreviewUI:onLoadRootComplete()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
uiMap["act_preview_ui.content.close_btn"]:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
|
||||
uiMap["act_preview_ui.content.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_FORCE_3))
|
||||
uiMap["act_preview_ui.content.desc_tx"]:setText(self.descStr)
|
||||
|
||||
local scrollrect = uiMap["act_preview_ui.content.scrollrect"]
|
||||
self.scrollRect = scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return GConst.TYPEOF_LUA_CLASS.PROB_REWARD_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.rewardList[index], self.rewardWeight[index])
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.rewardList)
|
||||
end
|
||||
|
||||
return ActPreviewUI
|
||||
10
lua/app/ui/activity/common/act_preview_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_preview_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee0c0179f53d441e1a0e1d4c531b59d4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
55
lua/app/ui/activity/common/act_target_preview_ui.lua
Normal file
55
lua/app/ui/activity/common/act_target_preview_ui.lua
Normal file
@ -0,0 +1,55 @@
|
||||
local ActTargetPreviewUI = class("ActTargetPreviewUI", BaseUI)
|
||||
|
||||
local PREVIEW_CELL = "app/ui/activity/common/cell/target_preview_cell"
|
||||
|
||||
function ActTargetPreviewUI:isFullScreen()
|
||||
return false
|
||||
end
|
||||
|
||||
function ActTargetPreviewUI:getPrefabPath()
|
||||
return "assets/prefabs/ui/activity/common/act_target_preview_ui.prefab"
|
||||
end
|
||||
|
||||
function ActTargetPreviewUI:ctor(params)
|
||||
self.parentUI = params.parentUI
|
||||
self.dataKey = params.dataKey
|
||||
self.targetAtlas = params.targetAtlas
|
||||
self.targetIcon = params.targetIcon
|
||||
self.data = DataManager[params.dataKey]
|
||||
end
|
||||
|
||||
function ActTargetPreviewUI:onLoadRootComplete()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.txTitle = uiMap["act_target_preview_ui.content.tx_title"]
|
||||
self.btnClose = uiMap["act_target_preview_ui.content.btn_close"]
|
||||
self.scrollRectObj = uiMap["act_target_preview_ui.content.scrollrect"]
|
||||
|
||||
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_7))
|
||||
|
||||
self.btnClose:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
self:bind(self.data, "isDirty", function()
|
||||
self:onRefresh()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActTargetPreviewUI:onRefresh()
|
||||
self.rewardList = self.data:getGameTargetCfgList()
|
||||
if self.scrollRect == nil then
|
||||
self.scrollRect = self.scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return PREVIEW_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.dataKey, self.rewardList[index].id, index >= #self.rewardList)
|
||||
cell:refreshIcon(self.targetAtlas, self.targetIcon)
|
||||
end)
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.rewardList)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
end
|
||||
|
||||
return ActTargetPreviewUI
|
||||
10
lua/app/ui/activity/common/act_target_preview_ui.lua.meta
Normal file
10
lua/app/ui/activity/common/act_target_preview_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d063d619a4c5d4d4b865e7bec93ab5a5
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
8
lua/app/ui/activity/common/cell.meta
Normal file
8
lua/app/ui/activity/common/cell.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40134207ca2864f1db30c2e5915bb020
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
88
lua/app/ui/activity/common/cell/bounty_cell.lua
Normal file
88
lua/app/ui/activity/common/cell/bounty_cell.lua
Normal file
@ -0,0 +1,88 @@
|
||||
local BountyCell = class("BountyCell", BaseCell)
|
||||
|
||||
function BountyCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.sliderBg = uiMap["bounty_cell.slider_bg"]
|
||||
self.slider = uiMap["bounty_cell.slider_bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.lvNode = uiMap["bounty_cell.level_bg"]
|
||||
self.lvTx = uiMap["bounty_cell.level_bg.lv_tx"]
|
||||
self.bg = uiMap["bounty_cell.bg"]
|
||||
self.rewardCells = {}
|
||||
for i = 1, 3 do
|
||||
self.rewardCells[i] = uiMap["bounty_cell.rewards.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
self.bg:addClickListener(function()
|
||||
if self.canClaim then
|
||||
self.parentUI:onClaimAllRewards()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function BountyCell:refresh(parentUI, dataKey, index, cfg)
|
||||
self.parentUI = parentUI
|
||||
self.data = DataManager[dataKey]
|
||||
local signDay = self.data:getBountySignDay()
|
||||
local maxDay = self.data:getBountyMaxDay()
|
||||
|
||||
self.canClaim = false
|
||||
-- 刷新进度
|
||||
local helf = self:getBaseObject():getSizeDeltaY() / 2
|
||||
if index == 1 then
|
||||
self.sliderBg:setAnchoredPositionY(-helf / 2)
|
||||
self.sliderBg:setSizeDeltaY(helf)
|
||||
elseif index == maxDay then
|
||||
self.sliderBg:setAnchoredPositionY(helf / 2)
|
||||
self.sliderBg:setSizeDeltaY(helf)
|
||||
else
|
||||
self.sliderBg:setAnchoredPositionY(0)
|
||||
self.sliderBg:setSizeDeltaY(self:getBaseObject():getSizeDeltaY())
|
||||
end
|
||||
if signDay < index or signDay == 1 then
|
||||
self.slider.value = 0
|
||||
elseif signDay < maxDay and signDay == index then
|
||||
self.slider.value = 0.5
|
||||
else
|
||||
self.slider.value = 1
|
||||
end
|
||||
|
||||
self.lvNode:setSprite(parentUI:getBountyLvRes(signDay >= index))
|
||||
self.lvTx:setText(index)
|
||||
|
||||
local isUnlockPro = self.data:isUnlockProReward()
|
||||
local rewards = {cfg.reward[1], cfg.reward_pro[1], cfg.reward_pro[2]}
|
||||
local rewardGear = {GConst.ActivityConst.REWARD_GEAR.COMMON, GConst.ActivityConst.REWARD_GEAR.PRO, GConst.ActivityConst.REWARD_GEAR.PRO}
|
||||
local unlock = {true, isUnlockPro, isUnlockPro}
|
||||
for i = 1, 3 do
|
||||
local reward = rewards[i]
|
||||
local canClaim = self.data:canClaimReward(rewardGear[i], cfg.id)
|
||||
local got = self.data:isReceivedReward(rewardGear[i], cfg.id)
|
||||
if reward then
|
||||
self.rewardCells[i]:setActive(true)
|
||||
self.rewardCells[i]:refreshByConfig(reward, got, got)
|
||||
self.rewardCells[i]:showLock(not unlock[i])
|
||||
if canClaim then
|
||||
self.rewardCells[i]:showFrameAnimation()
|
||||
self.canClaim = true
|
||||
else
|
||||
self.rewardCells[i]:hideFrameAnimation()
|
||||
end
|
||||
self.rewardCells[i]:addClickListener(function()
|
||||
if canClaim then
|
||||
self.parentUI:onClaimAllRewards()
|
||||
else
|
||||
ModuleManager.TipsManager:showRewardTips(reward.id, reward.type, self.rewardCells[i]:getBaseObject())
|
||||
end
|
||||
end)
|
||||
if i == 3 then
|
||||
self.rewardCells[2]:setAnchoredPositionX(93)
|
||||
end
|
||||
else
|
||||
self.rewardCells[i]:setActive(false)
|
||||
if i == 3 then
|
||||
self.rewardCells[2]:setAnchoredPositionX(155)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return BountyCell
|
||||
10
lua/app/ui/activity/common/cell/bounty_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/bounty_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c296bf4454e8b4613a7fe055dcac77c6
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
16
lua/app/ui/activity/common/cell/cook_settlement_cell.lua
Normal file
16
lua/app/ui/activity/common/cell/cook_settlement_cell.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local SettlementCell = class("SettlementCell", BaseCell)
|
||||
|
||||
function SettlementCell:refresh(parentUI, dataKey, data)
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
local uiMap = self:getUIMap()
|
||||
local food = data.food
|
||||
local score = data.score
|
||||
|
||||
uiMap["settlement_cell.icon"]:setSprite(parentUI:getAtlasPath(), parentUI.ActConst.FOOD_ICON[food])
|
||||
uiMap["settlement_cell.name_tx"]:setText(I18N:getText("act_active_cook", food, "value"))
|
||||
uiMap["settlement_cell.score_tx"]:setText(score)
|
||||
end
|
||||
|
||||
return SettlementCell
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 071d8926acadf4ac2b8bdb41f5879228
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
109
lua/app/ui/activity/common/cell/exchange_cell.lua
Normal file
109
lua/app/ui/activity/common/cell/exchange_cell.lua
Normal file
@ -0,0 +1,109 @@
|
||||
local ExchangeCell = class("ExchangeCell", BaseCell)
|
||||
|
||||
function ExchangeCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
|
||||
self.bg = uiMap["exchange_cell.bg"]
|
||||
self.rewardCell = uiMap["exchange_cell.bg.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.icon = uiMap["exchange_cell.bg.icon"]
|
||||
self.costTx = uiMap["exchange_cell.bg.cost_tx"]
|
||||
self.descTx = uiMap["exchange_cell.bg.desc_tx"]
|
||||
self.emptyTx = uiMap["exchange_cell.bg.empty_tx"]
|
||||
self.tagNode = uiMap["exchange_cell.bg.tag"]
|
||||
self.txOff = uiMap["exchange_cell.bg.tag.off_tx"]
|
||||
self.txName = uiMap["exchange_cell.bg.tx_name"]
|
||||
self.changeImg = uiMap["exchange_cell.bg.change_img"]
|
||||
|
||||
self.emptyTx:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_10))
|
||||
|
||||
self.bg:addClickListener(function()
|
||||
self:doExchange()
|
||||
end)
|
||||
end
|
||||
|
||||
function ExchangeCell:refresh(parentUI, dataKey, cfg)
|
||||
self.parentUI = parentUI
|
||||
self.data = DataManager[dataKey]
|
||||
|
||||
local id = cfg.id
|
||||
self.id = id
|
||||
self.cfg = cfg
|
||||
self.reward = cfg.reward[1]
|
||||
self.cost = cfg.cost[1]
|
||||
|
||||
local totalNum = cfg.limit
|
||||
self.remainNum = totalNum - DataManager.ActivityData:getExchangeCount(self.id)
|
||||
self.rewardCell:refreshByConfig(self.reward, self.remainNum <= 0, self.remainNum <= 0)
|
||||
self.descTx:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_8).. ":" .. self.remainNum .. "/" .. totalNum)
|
||||
self.txName:setText(GFunc.getRewardName(self.reward))
|
||||
|
||||
if self.remainNum > 0 then
|
||||
self.bg:setTouchEnable(true)
|
||||
self.bg:setSprite(self.parentUI:getExchangeRes(true))
|
||||
self.costTx:setText(self.cost.num)
|
||||
self.icon:setSprite(GFunc.getIconRes(self.cost.id))
|
||||
GFunc.centerImgAndTx(self.icon, self.costTx, 0)
|
||||
self.emptyTx:setActive(false)
|
||||
self.costTx:setActive(true)
|
||||
self.icon:setActive(true)
|
||||
else
|
||||
self.bg:setTouchEnable(false)
|
||||
self.bg:setSprite(self.parentUI:getExchangeRes())
|
||||
|
||||
self.emptyTx:setActive(true)
|
||||
self.costTx:setActive(false)
|
||||
self.icon:setActive(false)
|
||||
end
|
||||
|
||||
if self.cfg.value then
|
||||
self.tagNode:setActive(true)
|
||||
self.txOff:setText(self.cfg.value .. "%")
|
||||
else
|
||||
self.tagNode:setActive(false)
|
||||
end
|
||||
|
||||
self:refreshChange()
|
||||
end
|
||||
|
||||
function ExchangeCell:refreshChange()
|
||||
local group = self.cfg.group
|
||||
if not group then
|
||||
self.changeImg:setActive(false)
|
||||
return
|
||||
end
|
||||
|
||||
local list = self.data:getExchange2GroupList(group)
|
||||
if #list <= 1 then
|
||||
self.changeImg:setActive(false)
|
||||
return
|
||||
end
|
||||
self.changeImg:setActive(true)
|
||||
self.changeImg:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
||||
self.changeImg:addClickListener(function()
|
||||
local idx = self.data:getExchange2GroupListSelIdx(group)
|
||||
local rewards = {}
|
||||
for i,v in ipairs(list) do
|
||||
table.insert(rewards, v.reward[1])
|
||||
end
|
||||
GFunc.showRewardSelectUI(rewards, idx, function(index)
|
||||
self.data:setExchange2GroupListSelIdx(group, index)
|
||||
end, I18N:getGlobalText(I18N.GlobalConst.GET_REWARD_DESC))
|
||||
end)
|
||||
end
|
||||
|
||||
function ExchangeCell:doExchange()
|
||||
if not self.reward then
|
||||
return
|
||||
end
|
||||
|
||||
if not GFunc.checkCost(self.cost.id, self.cost.num, true) then
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_ACTIVITY_PAGE, self.parentUI.ActConst.BOTTOM_PAGE.TURNTABLE)
|
||||
return
|
||||
end
|
||||
|
||||
GFunc.showBuyFastUI(self.reward, self.cost, self.remainNum, function(count)
|
||||
self.parentUI:reqExchange(self.id, count)
|
||||
end)
|
||||
end
|
||||
|
||||
return ExchangeCell
|
||||
10
lua/app/ui/activity/common/cell/exchange_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/exchange_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 341b1b8563e02436fa5f6d80d9763932
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
15
lua/app/ui/activity/common/cell/ferrule_preview_cell.lua
Normal file
15
lua/app/ui/activity/common/cell/ferrule_preview_cell.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local PreviewCell = class("PreviewCell", BaseCell)
|
||||
|
||||
function PreviewCell:refresh(petId)
|
||||
local config = ConfigManager:getConfig("pet")[petId]
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
uiMap["preview_cell.img_qlt"]:setSprite(GConst.ATLAS_PATH.ICON_PET, "frame_" .. DataManager.PetData:getGlobalQltByPetQlt(config.qlt))
|
||||
uiMap["preview_cell.img_icon"]:setSprite(GConst.ATLAS_PATH.ICON_PET, config.icon_id)
|
||||
|
||||
-- self:getBaseObject():addClickListener(function()
|
||||
-- ModuleManager.PetManager:showInfoUI(petId, GConst.PetConst.INFO_SHOW_STYLE.TIPS)
|
||||
-- end)
|
||||
end
|
||||
|
||||
return PreviewCell
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2086f5412c4fd4ccb974b81af688cd52
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
29
lua/app/ui/activity/common/cell/fish_preview_cell.lua
Normal file
29
lua/app/ui/activity/common/cell/fish_preview_cell.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local PreviewCell = class("PreviewCell", BaseCell)
|
||||
|
||||
function PreviewCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.rewardCell = uiMap["preview_cell.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.arrow = uiMap["preview_cell.arrow"]
|
||||
self.num = uiMap["preview_cell.img_bg.num_tx"]
|
||||
end
|
||||
|
||||
function PreviewCell:refresh(parentUI, dataKey, id, islast)
|
||||
local data = DataManager[dataKey]
|
||||
local received = data:getGameScoreRewardGot(id)
|
||||
local reward = data:getGameScoreReward(id)
|
||||
self.num:setText(data:getGameScoreRewardNeed(id))
|
||||
self.arrow:setVisible(not islast)
|
||||
|
||||
if reward then
|
||||
self.rewardCell:refreshByConfig(reward, received, received)
|
||||
self.rewardCell:setVisible(true)
|
||||
else
|
||||
self.rewardCell:setVisible(false)
|
||||
end
|
||||
end
|
||||
|
||||
function PreviewCell:setVisible(visible, scale)
|
||||
self.baseObject:setVisible(visible, scale)
|
||||
end
|
||||
|
||||
return PreviewCell
|
||||
10
lua/app/ui/activity/common/cell/fish_preview_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/fish_preview_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc6d7fef9779a45cdb9b1f699b6003fe
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
191
lua/app/ui/activity/common/cell/gift_cell.lua
Normal file
191
lua/app/ui/activity/common/cell/gift_cell.lua
Normal file
@ -0,0 +1,191 @@
|
||||
local GiftCell = class("GiftCell", BaseCell)
|
||||
|
||||
function GiftCell:onClose()
|
||||
if self.sid then
|
||||
self.txTime:unscheduleGlobal(self.sid)
|
||||
self.sid = nil
|
||||
end
|
||||
end
|
||||
|
||||
function GiftCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.txTitle = uiMap["gift_cell.tx_title"]
|
||||
self.rewardNode = uiMap["gift_cell.reward_node"]
|
||||
self.rewards = {}
|
||||
for i = 1, 3 do
|
||||
table.insert(self.rewards, uiMap["gift_cell.reward_node.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL))
|
||||
end
|
||||
self.btnGet = uiMap["gift_cell.btn_get"]
|
||||
self.txGetDesc = uiMap["gift_cell.btn_get.tx_desc"]
|
||||
self.txLimit = uiMap["gift_cell.btn_get.tx_limit"]
|
||||
self.costNode = uiMap["gift_cell.btn_get.cost"]
|
||||
self.imgCost = uiMap["gift_cell.btn_get.cost.img_cost"]
|
||||
self.txCost = uiMap["gift_cell.btn_get.cost.tx_cost"]
|
||||
self.imgAd = uiMap["gift_cell.btn_get.cost.img_ad"]
|
||||
self.txTime = uiMap["gift_cell.btn_get.tx_time"]
|
||||
self.tagNode = uiMap["gift_cell.tag"]
|
||||
self.txTag = uiMap["gift_cell.tag.tx_tag"]
|
||||
|
||||
self.sid = self.txTime:scheduleGlobal(function ()
|
||||
self:updateTime()
|
||||
end, 1)
|
||||
|
||||
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_10))
|
||||
end
|
||||
|
||||
function GiftCell:updateTime()
|
||||
if self.cfg == nil then
|
||||
return
|
||||
end
|
||||
if not DataManager.ActGiftData:isFreeGift(self.data:getActId(), self.cfg.id) then
|
||||
return
|
||||
end
|
||||
local totalNum = self.cfg.limit
|
||||
local curNum = DataManager.ActGiftData:getGiftBuyCount(self.cfg.id)
|
||||
if totalNum - curNum > 0 then
|
||||
self.txTime:setText("")
|
||||
return
|
||||
end
|
||||
self.txTime:setText(Time:formatNumTime(Time:getTodaySurplusTime()))
|
||||
end
|
||||
|
||||
function GiftCell:refresh(parentUI, dataKey, id)
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.data = DataManager[dataKey]
|
||||
|
||||
self.cfg = DataManager.ActGiftData:getGiftConfig(self.data:getActId(), id)
|
||||
self:updateTime()
|
||||
|
||||
self.txTitle:setText(I18N:getText("act_gift", self.cfg.id, "value"))
|
||||
|
||||
local rewards = self.cfg.reward
|
||||
for i, cell in ipairs(self.rewards) do
|
||||
if rewards and rewards[i] then
|
||||
cell:showCell()
|
||||
cell:refreshByConfig(rewards[i])
|
||||
else
|
||||
cell:hideCell()
|
||||
end
|
||||
end
|
||||
|
||||
local value = self.cfg.value
|
||||
if value then
|
||||
self.tagNode:setActive(true)
|
||||
self.txTag:setText("-" .. value .. "%")
|
||||
else
|
||||
self.tagNode:setActive(false)
|
||||
end
|
||||
|
||||
local totalNum = self.cfg.limit
|
||||
local curNum = DataManager.ActGiftData:getGiftBuyCount(self.cfg.id)
|
||||
local remainNum = totalNum - curNum
|
||||
local costItems = self.cfg.item_cost
|
||||
local costRecharge = self.cfg.recharge_id
|
||||
if costItems then
|
||||
-- 道具购买
|
||||
self.imgAd:setActive(false)
|
||||
self.imgCost:setActive(true)
|
||||
self.txTime:setActive(false)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_7")
|
||||
self.imgCost:setSprite(GFunc.getRewardIconRes(costItems[1]))
|
||||
|
||||
if totalNum >= 9999 then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_21))
|
||||
elseif DataManager.ActGiftData:isDailyGift(self.data:getActId(), self.cfg.id) then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.WORLDBOSS_DESC_16, remainNum, totalNum))
|
||||
else
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_8).. ":" .. remainNum .. "/" .. totalNum)
|
||||
end
|
||||
|
||||
if remainNum > 0 then
|
||||
self.costNode:setActive(true)
|
||||
self.txGetDesc:setActive(false)
|
||||
self.btnGet:setTouchEnable(true)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_4")
|
||||
self.txCost:setText("<size=30>" .. GFunc.getRewardNum(costItems[1]) .. "</size>")
|
||||
GFunc.centerImgAndTx(self.imgCost, self.txCost, -8)
|
||||
else
|
||||
self.costNode:setActive(false)
|
||||
self.txGetDesc:setActive(true)
|
||||
self.btnGet:setTouchEnable(false)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.txGetDesc:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_10))
|
||||
end
|
||||
self.btnGet:removeRedPoint()
|
||||
|
||||
self.btnGet:addClickListener(function()
|
||||
if not GFunc.checkCost(GFunc.getRewardId(costItems[1]), GFunc.getRewardNum(costItems[1]), true) then
|
||||
return
|
||||
end
|
||||
local params = {}
|
||||
params.content = I18N:getGlobalText(I18N.GlobalConst.MALL_DESC_13)
|
||||
params.boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL
|
||||
params.showToday = GConst.MESSAGE_BOX_SHOW_TODAY.ACT_DREAM_GIFT
|
||||
params.okFunc = function()
|
||||
ModuleManager.ActivityManager:onGiftBuy(self.cfg.id)
|
||||
end
|
||||
GFunc.showMessageBox(params)
|
||||
end)
|
||||
elseif costRecharge then
|
||||
-- 充值购买
|
||||
self.costNode:setActive(false)
|
||||
self.txGetDesc:setActive(true)
|
||||
self.txTime:setActive(false)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_7")
|
||||
|
||||
if totalNum >= 9999 then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_21))
|
||||
else
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_8).. ":" .. remainNum .. "/" .. totalNum)
|
||||
end
|
||||
|
||||
if remainNum > 0 then
|
||||
self.btnGet:setTouchEnable(true)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_4")
|
||||
self.txGetDesc:setText(GFunc.getFormatPrice(self.cfg.recharge_id))
|
||||
else
|
||||
self.btnGet:setTouchEnable(false)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.txGetDesc:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_10))
|
||||
end
|
||||
self.btnGet:removeRedPoint()
|
||||
|
||||
self.btnGet:addClickListener(function()
|
||||
ModuleManager.ActivityManager:onGiftBuy(self.cfg.id)
|
||||
end)
|
||||
else
|
||||
-- 免费购买
|
||||
self.costNode:setActive(true)
|
||||
self.txGetDesc:setActive(false)
|
||||
self.imgAd:setActive(true)
|
||||
self.imgCost:setActive(false)
|
||||
self.txTime:setActive(true)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_6")
|
||||
GFunc.setAdsSprite(self.imgAd, remainNum <= 0)
|
||||
self.txCost:setText("<size=24>" .. I18N:getGlobalText(I18N.GlobalConst.FREE_DESC) .. "</size>")
|
||||
GFunc.centerImgAndTx(self.imgAd, self.txCost)
|
||||
if remainNum > 0 then
|
||||
self.btnGet:setTouchEnable(true)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_blue_4")
|
||||
self.btnGet:addRedPoint(80, 30, 0.9)
|
||||
else
|
||||
self.btnGet:setTouchEnable(false)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.btnGet:removeRedPoint()
|
||||
end
|
||||
|
||||
if totalNum >= 9999 then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_21))
|
||||
else
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.WORLDBOSS_DESC_16, remainNum, totalNum))
|
||||
end
|
||||
|
||||
self.btnGet:addClickListener(function()
|
||||
SDKManager:showFullScreenAds(self.parentUI:getGiftAdType(), function ()
|
||||
ModuleManager.ActivityManager:onGiftBuy(self.cfg.id)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
return GiftCell
|
||||
10
lua/app/ui/activity/common/cell/gift_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/gift_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdfa4c0a9c14840e3a18057f5ce0bf09
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
190
lua/app/ui/activity/common/cell/gift_cell_v2.lua
Normal file
190
lua/app/ui/activity/common/cell/gift_cell_v2.lua
Normal file
@ -0,0 +1,190 @@
|
||||
local ActGiftCell = class("ActGiftCell", BaseCell)
|
||||
|
||||
function ActGiftCell:onClose()
|
||||
if self.sid then
|
||||
self.txTime:unscheduleGlobal(self.sid)
|
||||
self.sid = nil
|
||||
end
|
||||
end
|
||||
|
||||
function ActGiftCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.txTitle = uiMap["act_gift_cell.tx_title"]
|
||||
self.rewardNode = uiMap["act_gift_cell.reward_node"]
|
||||
self.rewards = {}
|
||||
for i = 1, 3 do
|
||||
table.insert(self.rewards, uiMap["act_gift_cell.reward_node.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL))
|
||||
end
|
||||
self.btnGet = uiMap["act_gift_cell.btn_get"]
|
||||
self.txGetDesc = uiMap["act_gift_cell.btn_get.tx_desc"]
|
||||
self.txLimit = uiMap["act_gift_cell.btn_get.tx_limit"]
|
||||
self.costNode = uiMap["act_gift_cell.btn_get.cost"]
|
||||
self.imgCost = uiMap["act_gift_cell.btn_get.cost.img_cost"]
|
||||
self.txCost = uiMap["act_gift_cell.btn_get.cost.tx_cost"]
|
||||
self.imgAd = uiMap["act_gift_cell.btn_get.cost.img_ad"]
|
||||
self.txTime = uiMap["act_gift_cell.btn_get.tx_time"]
|
||||
self.tagNode = uiMap["act_gift_cell.tag"]
|
||||
self.txTag = uiMap["act_gift_cell.tag.tx_tag"]
|
||||
|
||||
self.sid = self.txTime:scheduleGlobal(function ()
|
||||
self:updateTime()
|
||||
end, 1)
|
||||
|
||||
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_10))
|
||||
end
|
||||
|
||||
function ActGiftCell:updateTime()
|
||||
if self.cfg == nil then
|
||||
return
|
||||
end
|
||||
if not DataManager.ActGiftData:isFreeGift(self.actId, self.cfg.id) then
|
||||
return
|
||||
end
|
||||
local totalNum = self.cfg.limit
|
||||
local curNum = DataManager.ActGiftData:getGiftBuyCount(self.cfg.id)
|
||||
if totalNum - curNum > 0 then
|
||||
self.txTime:setText("")
|
||||
return
|
||||
end
|
||||
self.txTime:setText(Time:formatNumTime(Time:getTodaySurplusTime()))
|
||||
end
|
||||
|
||||
function ActGiftCell:refresh(actId, giftId, biAd)
|
||||
self.actId = actId
|
||||
self.cfg = DataManager.ActGiftData:getGiftConfig(self.actId, giftId)
|
||||
self:updateTime()
|
||||
|
||||
self.txTitle:setText(I18N:getText("act_gift", self.cfg.id, "value"))
|
||||
|
||||
local rewards = self.cfg.reward
|
||||
for i, cell in ipairs(self.rewards) do
|
||||
if rewards and rewards[i] then
|
||||
cell:showCell()
|
||||
cell:refreshByConfig(rewards[i])
|
||||
else
|
||||
cell:hideCell()
|
||||
end
|
||||
end
|
||||
|
||||
local value = self.cfg.value
|
||||
if value then
|
||||
self.tagNode:setActive(true)
|
||||
self.txTag:setText("-" .. value .. "%")
|
||||
else
|
||||
self.tagNode:setActive(false)
|
||||
end
|
||||
|
||||
local totalNum = self.cfg.limit
|
||||
local curNum = DataManager.ActGiftData:getGiftBuyCount(self.cfg.id)
|
||||
local remainNum = totalNum - curNum
|
||||
local costItems = self.cfg.item_cost
|
||||
local costRecharge = self.cfg.recharge_id
|
||||
|
||||
if costItems then
|
||||
-- 道具购买
|
||||
self.imgAd:setActive(false)
|
||||
self.imgCost:setActive(true)
|
||||
self.txTime:setActive(false)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_13")
|
||||
self.imgCost:setSprite(GFunc.getRewardIconRes(costItems[1]))
|
||||
|
||||
if totalNum >= 9999 then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_21))
|
||||
elseif DataManager.ActGiftData:isDailyGift(self.actId, self.cfg.id) then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.WORLDBOSS_DESC_16, remainNum, totalNum))
|
||||
else
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_8).. ":" .. remainNum .. "/" .. totalNum)
|
||||
end
|
||||
|
||||
if remainNum > 0 then
|
||||
self.costNode:setActive(true)
|
||||
self.txGetDesc:setActive(false)
|
||||
self.btnGet:setTouchEnable(true)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_4")
|
||||
self.txCost:setText("<size=30>" .. GFunc.getRewardNum(costItems[1]) .. "</size>")
|
||||
GFunc.centerImgAndTx(self.imgCost, self.txCost, -8)
|
||||
else
|
||||
self.costNode:setActive(false)
|
||||
self.txGetDesc:setActive(true)
|
||||
self.btnGet:setTouchEnable(false)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.txGetDesc:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_10))
|
||||
end
|
||||
self.btnGet:removeRedPoint()
|
||||
|
||||
self.btnGet:addClickListener(function()
|
||||
if not GFunc.checkCost(GFunc.getRewardId(costItems[1]), GFunc.getRewardNum(costItems[1]), true) then
|
||||
return
|
||||
end
|
||||
local params = {}
|
||||
params.content = I18N:getGlobalText(I18N.GlobalConst.MALL_DESC_13)
|
||||
params.boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL
|
||||
params.showToday = GConst.MESSAGE_BOX_SHOW_TODAY.ACT_DREAM_GIFT
|
||||
params.okFunc = function()
|
||||
ModuleManager.ActivityManager:onGiftBuy(self.cfg.id)
|
||||
end
|
||||
GFunc.showMessageBox(params)
|
||||
end)
|
||||
elseif costRecharge then
|
||||
-- 充值购买
|
||||
self.costNode:setActive(false)
|
||||
self.txGetDesc:setActive(true)
|
||||
self.txTime:setActive(false)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_13")
|
||||
|
||||
if totalNum >= 9999 then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_21))
|
||||
else
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_8).. ":" .. remainNum .. "/" .. totalNum)
|
||||
end
|
||||
|
||||
if remainNum > 0 then
|
||||
self.btnGet:setTouchEnable(true)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_4")
|
||||
self.txGetDesc:setText(GFunc.getFormatPrice(self.cfg.recharge_id))
|
||||
else
|
||||
self.btnGet:setTouchEnable(false)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.txGetDesc:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_10))
|
||||
end
|
||||
self.btnGet:removeRedPoint()
|
||||
|
||||
self.btnGet:addClickListener(function()
|
||||
ModuleManager.ActivityManager:onGiftBuy(self.cfg.id)
|
||||
end)
|
||||
else
|
||||
-- 免费购买
|
||||
self.costNode:setActive(true)
|
||||
self.txGetDesc:setActive(false)
|
||||
self.imgAd:setActive(true)
|
||||
self.imgCost:setActive(false)
|
||||
self.txTime:setActive(true)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_14")
|
||||
GFunc.setAdsSprite(self.imgAd, remainNum <= 0)
|
||||
self.txCost:setText("<size=24>" .. I18N:getGlobalText(I18N.GlobalConst.FREE_DESC) .. "</size>")
|
||||
GFunc.centerImgAndTx(self.imgAd, self.txCost)
|
||||
if remainNum > 0 then
|
||||
self.btnGet:setTouchEnable(true)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_blue_4")
|
||||
self.btnGet:addRedPoint(65, 30, 0.9)
|
||||
else
|
||||
self.btnGet:setTouchEnable(false)
|
||||
self.btnGet:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.btnGet:removeRedPoint()
|
||||
end
|
||||
|
||||
if totalNum >= 9999 then
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.GIFT_ROUTINE_DESC_21))
|
||||
else
|
||||
self.txLimit:setText(I18N:getGlobalText(I18N.GlobalConst.WORLDBOSS_DESC_16, remainNum, totalNum))
|
||||
end
|
||||
|
||||
self.btnGet:addClickListener(function()
|
||||
SDKManager:showFullScreenAds(biAd, function ()
|
||||
ModuleManager.ActivityManager:onGiftBuy(self.cfg.id)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
return ActGiftCell
|
||||
10
lua/app/ui/activity/common/cell/gift_cell_v2.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/gift_cell_v2.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d29de8eb0aa7244259fafd0eeae1a281
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
25
lua/app/ui/activity/common/cell/target_cell.lua
Normal file
25
lua/app/ui/activity/common/cell/target_cell.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local TargetCell = class("TargetCell", BaseCell)
|
||||
|
||||
function TargetCell:refresh(parentUI, dataKey, cfg, func)
|
||||
local data = DataManager[dataKey]
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
if not self.rewardCell then
|
||||
self.rewardCell = CellManager:addCellComp(uiMap["target_cell.reward_cell"], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
|
||||
local reward = cfg.reward[1]
|
||||
local got = data:getGameScoreRewardGot(cfg.id)
|
||||
local canget = data:getGameScoreRewardCanGet(cfg.id)
|
||||
|
||||
self.rewardCell:refreshByConfig(reward, got, got)
|
||||
if canget then
|
||||
self.rewardCell:showFrameAnimation()
|
||||
self.rewardCell:addClickListener(func)
|
||||
else
|
||||
self.rewardCell:hideFrameAnimation()
|
||||
end
|
||||
uiMap["target_cell.tx_idx"]:setText(cfg.point)
|
||||
end
|
||||
|
||||
return TargetCell
|
||||
10
lua/app/ui/activity/common/cell/target_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/target_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7144b3358f20d418a94f21c951b2fbb8
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
41
lua/app/ui/activity/common/cell/target_preview_cell.lua
Normal file
41
lua/app/ui/activity/common/cell/target_preview_cell.lua
Normal file
@ -0,0 +1,41 @@
|
||||
local PreviewCell = class("PreviewCell", BaseCell)
|
||||
|
||||
function PreviewCell:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.rewardCell = uiMap["target_preview_cell.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.arrow = uiMap["target_preview_cell.arrow"]
|
||||
self.imgIcon = uiMap["target_preview_cell.img_bg.icon"]
|
||||
self.numTx = uiMap["target_preview_cell.img_bg.num_tx"]
|
||||
end
|
||||
|
||||
function PreviewCell:refresh(dataKey, id, islast)
|
||||
local data = DataManager[dataKey]
|
||||
local received = data:getGameScoreRewardGot(id)
|
||||
local reward = data:getGameScoreReward(id)
|
||||
self.numTx:setText(data:getGameScoreRewardNeed(id))
|
||||
self.arrow:setVisible(not islast)
|
||||
|
||||
if reward then
|
||||
self.rewardCell:setVisible(true)
|
||||
self.rewardCell:refreshByConfig(reward, received, received)
|
||||
else
|
||||
self.rewardCell:setVisible(false)
|
||||
end
|
||||
|
||||
self:refreshIcon()
|
||||
end
|
||||
|
||||
function PreviewCell:refreshIcon(atlas, icon)
|
||||
if atlas and icon then
|
||||
self.imgIcon:setActive(true)
|
||||
self.imgIcon:setSprite(atlas, icon)
|
||||
else
|
||||
self.imgIcon:setActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
function PreviewCell:setVisible(visible, scale)
|
||||
self.baseObject:setVisible(visible, scale)
|
||||
end
|
||||
|
||||
return PreviewCell
|
||||
10
lua/app/ui/activity/common/cell/target_preview_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/target_preview_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c70efa465cd34857b138ba9ac785338
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
64
lua/app/ui/activity/common/cell/task_cell.lua
Normal file
64
lua/app/ui/activity/common/cell/task_cell.lua
Normal file
@ -0,0 +1,64 @@
|
||||
local TaskCell = class("TaskCell", BaseCell)
|
||||
|
||||
function TaskCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.bg = uiMap['task_cell.bg']
|
||||
self.txDesc = uiMap['task_cell.tx_desc']
|
||||
self.btn = uiMap['task_cell.btn']
|
||||
self.txBtn = uiMap['task_cell.btn.tx_btn']
|
||||
self.imgPoint = uiMap['task_cell.point']
|
||||
self.rewardCell = uiMap['task_cell.reward_cell']:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.imgProg = uiMap['task_cell.prog.img_prog']:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.txProg = uiMap['task_cell.prog.tx_prog']
|
||||
self.mask = uiMap['task_cell.mask']
|
||||
|
||||
self.btn:addClickListener(function()
|
||||
if DataManager.ActTaskData:canClaimTask(self.data:getActId(), self.taskId) then
|
||||
self.parentUI:reqTask(self.taskId)
|
||||
elseif self.taskType == GConst.TaskConst.TASK_TYPE.ACT_NEWBIE_ST_TURNTABLE_NUM then
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_ACTIVITY_PAGE, 1)
|
||||
else
|
||||
ModuleManager.TaskManager:goToTask(self.taskType)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function TaskCell:refresh(parentUI, dataKey, taskId)
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.data = dataKey and DataManager[dataKey] or self.data
|
||||
self.taskId = taskId
|
||||
self.taskType = DataManager.ActTaskData:getTaskType(self.taskId)
|
||||
local actId = self.data:getActId()
|
||||
|
||||
local taskTarget = DataManager.ActTaskData:getTaskTarget(self.taskId)
|
||||
local taskProg = DataManager.ActTaskData:getTaskProg(actId, self.taskId)
|
||||
local taskReward = DataManager.ActTaskData:getTaskReward(self.taskId)
|
||||
taskProg = taskProg > taskTarget and taskTarget or taskProg
|
||||
|
||||
self.rewardCell:refreshByConfig(taskReward)
|
||||
|
||||
self.imgProg.value = taskProg / taskTarget
|
||||
self.txProg:setText(taskProg.."/"..taskTarget)
|
||||
|
||||
if DataManager.ActTaskData:isTaskReceived(actId, self.taskId) then
|
||||
-- 已完成
|
||||
self.mask:setActive(true)
|
||||
self.txBtn:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_GOT_DESC))
|
||||
self.btn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.txDesc:setText("<color=#574A40>" .. GFunc.getTaskDesc(self.taskType, taskTarget) .. "</color>")
|
||||
else
|
||||
-- 未完成 or 可领取
|
||||
self.mask:setActive(false)
|
||||
self.txDesc:setText("<color=#5C3A2D>" .. GFunc.getTaskDesc(self.taskType, taskTarget) .. "</color>")
|
||||
|
||||
if DataManager.ActTaskData:isTaskFinished(actId, self.taskId) then
|
||||
self.txBtn:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CLAIM))
|
||||
self.btn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_4")
|
||||
else
|
||||
self.txBtn:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_GO))
|
||||
self.btn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_blue_4")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return TaskCell
|
||||
10
lua/app/ui/activity/common/cell/task_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/task_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1378313a2e6248fdb1ada122c6cdffe
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
55
lua/app/ui/activity/common/cell/task_cell_v2.lua
Normal file
55
lua/app/ui/activity/common/cell/task_cell_v2.lua
Normal file
@ -0,0 +1,55 @@
|
||||
local ActTaskCell = class("ActTaskCell", BaseCell)
|
||||
|
||||
function ActTaskCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.txDesc = uiMap["act_task_cell.tx_desc"]
|
||||
self.btn = uiMap["act_task_cell.btn"]
|
||||
self.txBtn = uiMap["act_task_cell.btn.tx_btn"]
|
||||
self.imgProg = uiMap["act_task_cell.prog.img_prog"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.txProg = uiMap["act_task_cell.prog.tx_prog"]
|
||||
self.rewardCell = uiMap["act_task_cell.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
|
||||
self.btn:addClickListener(function()
|
||||
if DataManager.ActTaskData:canClaimTask(self.actId, self.taskId) then
|
||||
ModuleManager.ActivityManager:reqTaskReward(self.actId, self.taskId)
|
||||
else
|
||||
ModuleManager.TaskManager:goToTask(self.taskType)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ActTaskCell:refresh(actId, taskId)
|
||||
self.actId = actId
|
||||
self.taskId = taskId
|
||||
self.taskType = DataManager.ActTaskData:getTaskType(self.taskId)
|
||||
local taskTarget = DataManager.ActTaskData:getTaskTarget(self.taskId)
|
||||
local taskProg = DataManager.ActTaskData:getTaskProg(self.actId, self.taskId)
|
||||
taskProg = taskProg > taskTarget and taskTarget or taskProg
|
||||
|
||||
self.imgProg.value = taskProg / taskTarget
|
||||
self.txProg:setText(taskProg.."/"..taskTarget)
|
||||
|
||||
self.rewardCell:refreshByConfig(DataManager.ActTaskData:getTaskReward(self.taskId))
|
||||
|
||||
if DataManager.ActTaskData:isTaskReceived(self.actId, self.taskId) then
|
||||
-- 已完成
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_11")
|
||||
self.txBtn:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_GOT_DESC))
|
||||
self.btn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_4")
|
||||
self.txDesc:setText("<color=#574A40>" .. GFunc.getTaskDesc(self.taskType, taskTarget) .. "</color>")
|
||||
else
|
||||
-- 未完成 or 可领取
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_bg_10")
|
||||
self.txDesc:setText("<color=#5C3A2D>" .. GFunc.getTaskDesc(self.taskType, taskTarget) .. "</color>")
|
||||
|
||||
if DataManager.ActTaskData:isTaskFinished(self.actId, self.taskId) then
|
||||
self.txBtn:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CLAIM))
|
||||
self.btn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_4")
|
||||
else
|
||||
self.txBtn:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_GO))
|
||||
self.btn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_blue_4")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return ActTaskCell
|
||||
10
lua/app/ui/activity/common/cell/task_cell_v2.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/task_cell_v2.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2e800c7ac9bc46bea0499ded1527080
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
99
lua/app/ui/activity/common/cell/turntable_cell.lua
Normal file
99
lua/app/ui/activity/common/cell/turntable_cell.lua
Normal file
@ -0,0 +1,99 @@
|
||||
local TurntableCell = class("TurntableCell", BaseCell)
|
||||
|
||||
function TurntableCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.reawrdBg = uiMap["turntable_cell.reward_bg"]
|
||||
self.rewardCell = uiMap["turntable_cell.reward_bg.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.txBig = uiMap["turntable_cell.reward_bg.tx_big"]
|
||||
self.selectEffect = uiMap["turntable_cell.effect_node.vfx_b10_ui_hhzp_b01"]
|
||||
self.imgSelect = uiMap["turntable_cell.effect_node.img_select"]
|
||||
self.itemEffect = uiMap["turntable_cell.reward_bg.vfx_b10_ui_xnzp_b02"]
|
||||
|
||||
if self.selectEffect == nil then
|
||||
self.selectEffect = uiMap["turntable_cell.effect_node.vfx_b10_ui_mfzp_b01"]
|
||||
end
|
||||
if self.itemEffect == nil then
|
||||
self.itemEffect = uiMap["turntable_cell.effect_node.vfx_b10_ui_mfzp_b02"]
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableCell:refresh(parentUI, dataKey, id)
|
||||
local data = DataManager[dataKey]
|
||||
|
||||
local uiOrder = parentUI:getUIOrder()
|
||||
local cfgInfo = data:getTurntableCfg(id)
|
||||
local isBig = cfgInfo.color_x == 1
|
||||
local reward = cfgInfo.reward
|
||||
|
||||
-- 特殊处理
|
||||
if dataKey == "ActSailingData" and self.selectEffect ~= nil then
|
||||
self.bigEffect = self.selectEffect
|
||||
self.selectEffect = nil
|
||||
end
|
||||
if dataKey == "ActValentineData" then
|
||||
self.selectEffect = nil
|
||||
end
|
||||
|
||||
if self.txBig then
|
||||
if isBig then
|
||||
self.txBig:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_MAGIC_DESC_17))
|
||||
else
|
||||
self.txBig:setText(GConst.EMPTY_STRING)
|
||||
end
|
||||
end
|
||||
if self.bigEffect then
|
||||
if isBig then
|
||||
self.bigEffect:setActive(true)
|
||||
self.bigEffect:play()
|
||||
self.bigEffect:setSortingOrder(uiOrder, 10)
|
||||
else
|
||||
self.bigEffect:setActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
self.rewardCell:refreshByConfig(reward)
|
||||
|
||||
-- 奖励摆正
|
||||
local rotationZ = self:getBaseObject():getLocalEulerAnglesZ()
|
||||
self.reawrdBg:setLocalEulerAnglesZ(-rotationZ)
|
||||
|
||||
-- 默认不选中
|
||||
self:setSelectEffect(false)
|
||||
self:setSelectFlowEffect(false)
|
||||
self:setItemEffect(false)
|
||||
end
|
||||
|
||||
function TurntableCell:setSelectEffect(isSelect, uiOrder)
|
||||
if self.selectEffect then
|
||||
if isSelect then
|
||||
self.selectEffect:setActive(true)
|
||||
self.selectEffect:play()
|
||||
self.selectEffect:setSortingOrder(uiOrder, 10)
|
||||
else
|
||||
self.selectEffect:setActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
if self.imgSelect then
|
||||
if isSelect then
|
||||
self.imgSelect:setActive(true)
|
||||
self.imgSelect:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).overrideSorting = true
|
||||
self.imgSelect:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).sortingOrder = uiOrder + 10
|
||||
else
|
||||
self.imgSelect:setActive(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableCell:setSelectFlowEffect(isSelect, uiOrder)
|
||||
end
|
||||
|
||||
function TurntableCell:setItemEffect(isSelect, uiOrder)
|
||||
self.itemEffect:setActive(isSelect)
|
||||
if isSelect then
|
||||
self.itemEffect:play()
|
||||
self.itemEffect:setSortingOrder(uiOrder, 13)
|
||||
end
|
||||
end
|
||||
|
||||
return TurntableCell
|
||||
10
lua/app/ui/activity/common/cell/turntable_cell.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/turntable_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f97e392ba8f246ddae0304839c7b479
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
130
lua/app/ui/activity/common/cell/turntable_cell_v2.lua
Normal file
130
lua/app/ui/activity/common/cell/turntable_cell_v2.lua
Normal file
@ -0,0 +1,130 @@
|
||||
local TurntableCell = class("TurntableCell", BaseCell)
|
||||
|
||||
local IMG_QLT_NAME = {
|
||||
[1] = "act_newbie_bg_21",
|
||||
[2] = "act_newbie_bg_22",
|
||||
[3] = "act_newbie_bg_20",
|
||||
[4] = "act_newbie_bg_19",
|
||||
}
|
||||
|
||||
function TurntableCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.imgFill = self:getBaseObject():getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE)
|
||||
self.bigRewardNode = uiMap["turntable_cell.big_reward"]
|
||||
self.bigBg = uiMap["turntable_cell.big_reward.img_bg"]
|
||||
self.bigRewardCell = uiMap["turntable_cell.big_reward.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.commonRewardNode = uiMap["turntable_cell.common_reward"]
|
||||
self.commonBg = uiMap["turntable_cell.common_reward.img_bg"]
|
||||
self.commonRewardCell = uiMap["turntable_cell.common_reward.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
self.txTime = uiMap["turntable_cell.common_reward.time_node.tx_time"]
|
||||
|
||||
self.lineNode = uiMap["turntable_cell.line_node"]
|
||||
self.lineLeft = uiMap["turntable_cell.line_node.line_left"]
|
||||
self.lineRight = uiMap["turntable_cell.line_node.line_right"]
|
||||
|
||||
self.effectBig = uiMap["turntable_cell.big_reward.vfx_b10_ui_zhixu_zp_b02"]
|
||||
self.effectCommon = uiMap["turntable_cell.common_reward.vfx_b10_ui_zhixu_zp_b01"]
|
||||
self.effectBigFix1 = uiMap["turntable_cell.big_reward.vfx_b10_ui_zhixu_zp_b06"]
|
||||
self.effectBigFix2 = uiMap["turntable_cell.big_reward.vfx_b10_ui_zhixu_zp_b07"]
|
||||
self.effectCommonSelect = uiMap["turntable_cell.common_reward.vfx_b10_ui_zhixu_zp_b08"]
|
||||
end
|
||||
|
||||
function TurntableCell:refresh(parentUI, dataKey, id, angleInfo, flag)
|
||||
self.id = id
|
||||
self.data = DataManager[dataKey]
|
||||
local uiOrder = parentUI:getUIOrder()
|
||||
local isBig = self.data:isTurntableBigReward(self.id)
|
||||
local weight = self.data:getTurntableWeightById(self.id)
|
||||
local qlt = self.data:getTurntableQltById(self.id)
|
||||
local angle = weight * 360
|
||||
local reward = self.data:getTurntableRewardById(self.id)
|
||||
local rotationZ = angleInfo.angleStart
|
||||
|
||||
self.imgFill.fillAmount = weight
|
||||
self:getBaseObject():setLocalEulerAnglesZ(rotationZ)
|
||||
|
||||
if isBig then
|
||||
self.bigRewardNode:setActive(true)
|
||||
self.commonRewardNode:setActive(false)
|
||||
self.bigRewardCell:refreshByConfig(reward)
|
||||
self.bigRewardCell:showQlt(false)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_NEWBIE_ST, "act_newbie_bg_12")
|
||||
self.lineLeft:setSprite(GConst.ATLAS_PATH.UI_ACT_NEWBIE_ST, "act_newbie_bg_23")
|
||||
self.lineRight:setSprite(GConst.ATLAS_PATH.UI_ACT_NEWBIE_ST, "act_newbie_bg_23")
|
||||
self.lineNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).overrideSorting = true
|
||||
self.lineNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).sortingOrder = uiOrder + 11
|
||||
self.bigRewardNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).overrideSorting = true
|
||||
self.bigRewardNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).sortingOrder = uiOrder + 15
|
||||
self.effectBigFix1:play()
|
||||
self.effectBigFix1:setSortingOrder(uiOrder, 10)
|
||||
self.effectBigFix2:play()
|
||||
self.effectBigFix2:setSortingOrder(uiOrder, 15)
|
||||
else
|
||||
self.bigRewardNode:setActive(false)
|
||||
self.commonRewardNode:setActive(true)
|
||||
self.commonRewardCell:refreshByConfig(reward)
|
||||
self.commonRewardCell:showQlt(false)
|
||||
self:getBaseObject():setSprite(GConst.ATLAS_PATH.UI_ACT_NEWBIE_ST, flag and "act_newbie_bg_10" or "act_newbie_bg_11")
|
||||
self.lineLeft:setSprite(GConst.ATLAS_PATH.UI_ACT_NEWBIE_ST, "act_newbie_bg_13")
|
||||
self.lineRight:setSprite(GConst.ATLAS_PATH.UI_ACT_NEWBIE_ST, "act_newbie_bg_13")
|
||||
self.commonBg:setSprite(GConst.ATLAS_PATH.UI_ACT_NEWBIE_ST, IMG_QLT_NAME[qlt])
|
||||
self.lineNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).overrideSorting = true
|
||||
self.lineNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).sortingOrder = uiOrder + 10
|
||||
end
|
||||
|
||||
local localAngleCenter = -angle / 2
|
||||
local localRotationCenter = -rotationZ + angle / 2
|
||||
|
||||
self.lineLeft:setLocalEulerAnglesZ(0)
|
||||
self.lineRight:setLocalEulerAnglesZ(-angle)
|
||||
|
||||
-- 奖励摆正
|
||||
self.bigRewardNode:setLocalEulerAnglesZ(localAngleCenter)
|
||||
self.bigBg:setLocalEulerAnglesZ(localRotationCenter)
|
||||
self.bigRewardCell:getBaseObject():setLocalEulerAnglesZ(localRotationCenter)
|
||||
self.commonRewardNode:setLocalEulerAnglesZ(localAngleCenter)
|
||||
self.commonBg:setLocalEulerAnglesZ(localRotationCenter)
|
||||
self.commonRewardCell:getBaseObject():setLocalEulerAnglesZ(localRotationCenter)
|
||||
self.txTime:setLocalEulerAnglesZ(localRotationCenter)
|
||||
self.txTime:setText(self.data:getTurntableSpareCount(self.id))
|
||||
|
||||
-- 默认不选中
|
||||
self:setSelectEffect(false)
|
||||
self:setSelectFlowEffect(false)
|
||||
self:setItemEffect(false)
|
||||
end
|
||||
|
||||
-- 选中结束闪烁
|
||||
function TurntableCell:setSelectEffect(isSelect, uiOrder)
|
||||
self.effectCommonSelect:setActive(isSelect)
|
||||
if isSelect then
|
||||
self.effectCommonSelect:play()
|
||||
self.effectCommonSelect:setSortingOrder(uiOrder, 10)
|
||||
end
|
||||
end
|
||||
|
||||
-- 选中过程拖尾
|
||||
function TurntableCell:setSelectFlowEffect(isSelect, uiOrder)
|
||||
end
|
||||
|
||||
function TurntableCell:setItemEffect(isSelect, uiOrder)
|
||||
self.effectBig:setActive(false)
|
||||
self.effectCommon:setActive(false)
|
||||
if not isSelect then
|
||||
return
|
||||
end
|
||||
local isBig = self.data:isTurntableBigReward(self.id)
|
||||
if isBig then
|
||||
self.effectBig:setActive(true)
|
||||
self.effectCommon:setActive(false)
|
||||
self.effectBig:play()
|
||||
self.effectBig:setSortingOrder(uiOrder, 10)
|
||||
else
|
||||
self.effectBig:setActive(false)
|
||||
self.effectCommon:setActive(true)
|
||||
self.effectCommon:play()
|
||||
self.effectCommon:setSortingOrder(uiOrder, 10)
|
||||
end
|
||||
end
|
||||
|
||||
return TurntableCell
|
||||
10
lua/app/ui/activity/common/cell/turntable_cell_v2.lua.meta
Normal file
10
lua/app/ui/activity/common/cell/turntable_cell_v2.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7652370f9f2b42cfb61f26f0dc614fd
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
32
lua/app/ui/activity/common/cell/turntable_target_cell.lua
Normal file
32
lua/app/ui/activity/common/cell/turntable_target_cell.lua
Normal file
@ -0,0 +1,32 @@
|
||||
local TargetCell = class("TargetCell", BaseCell)
|
||||
|
||||
function TargetCell:refresh(parentUI, dataKey, cfg, func)
|
||||
local data = DataManager[dataKey]
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
if not self.rewardCell then
|
||||
self.rewardCell = CellManager:addCellComp(uiMap["target_cell.reward_cell"], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||
end
|
||||
|
||||
local reward = cfg.reward[1]
|
||||
local got = data:getTurntableTargetGot(cfg.id)
|
||||
local canget = data:getCanGetTurntableTargetReward(cfg.id)
|
||||
|
||||
self.rewardCell:refreshByConfig(reward, got, got)
|
||||
if canget then
|
||||
self.rewardCell:showFrameAnimation()
|
||||
self.rewardCell:addClickListener(func)
|
||||
else
|
||||
self.rewardCell:hideFrameAnimation()
|
||||
end
|
||||
|
||||
uiMap["target_cell.tx_idx"]:setText(cfg.target)
|
||||
|
||||
self:setRewardScale(0.6)
|
||||
end
|
||||
|
||||
function TargetCell:setRewardScale(scale)
|
||||
self.rewardCell:setLocalScale(scale, scale, scale)
|
||||
end
|
||||
|
||||
return TargetCell
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6022333ad5e8f4276b3d4554222b664e
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
8
lua/app/ui/activity/common/comp.meta
Normal file
8
lua/app/ui/activity/common/comp.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75249f38221cd4f258d02a859af319ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
123
lua/app/ui/activity/common/comp/act_bounty_comp_v1.lua
Normal file
123
lua/app/ui/activity/common/comp/act_bounty_comp_v1.lua
Normal file
@ -0,0 +1,123 @@
|
||||
local ActBountyComp = class("ActBountyComp", LuaComponent)
|
||||
|
||||
local CELL = "app/ui/activity/common/cell/bounty_cell"
|
||||
|
||||
function ActBountyComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.bg = uiMap["act_bounty_comp.bg"]
|
||||
self.imgBanner = uiMap["act_bounty_comp.img_banner"]
|
||||
self.imgBannerLine1 = uiMap["act_bounty_comp.img_banner.img_line_1"]
|
||||
self.imgBannerLine2 = uiMap["act_bounty_comp.img_banner.img_line_2"]
|
||||
self.titleTx = uiMap["act_bounty_comp.top.title_tx"]
|
||||
self.helpBtn = uiMap["act_bounty_comp.top.title_tx.help_btn"]
|
||||
self.timeTx = uiMap["act_bounty_comp.top.time_bg.time_tx"]
|
||||
self.tipsTx1 = uiMap["act_bounty_comp.top.tips_bg.tips_tx_1"]
|
||||
self.tipsTx2 = uiMap["act_bounty_comp.top.tips_bg.tips_tx_2"]
|
||||
self.scrollrect = uiMap["act_bounty_comp.scrollrect"]
|
||||
self.levelTx = uiMap["act_bounty_comp.scrollrect.title_bg.level_tx"]
|
||||
self.descTx1 = uiMap["act_bounty_comp.scrollrect.title_bg.desc_tx_1"]
|
||||
self.descTx2 = uiMap["act_bounty_comp.scrollrect.title_bg.desc_tx_2"]
|
||||
self.buyBtn1 = uiMap["act_bounty_comp.btns.buy_btn_1"]
|
||||
self.buyBtnTx1 = uiMap["act_bounty_comp.btns.buy_btn_1.text"]
|
||||
self.buyBtn2 = uiMap["act_bounty_comp.btns.buy_btn_2"]
|
||||
self.buyBtnTx2 = uiMap["act_bounty_comp.btns.buy_btn_2.text"]
|
||||
|
||||
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.parentUI, self.dataKey, index, self.cfgList[index])
|
||||
end)
|
||||
|
||||
self.buyBtn1:addClickListener(function()
|
||||
self.parentUI:onClaimAllRewards()
|
||||
end)
|
||||
|
||||
self.buyBtn2:addClickListener(function()
|
||||
if not self.data:isUnlockProReward() then
|
||||
self.parentUI:onUnlockProReward()
|
||||
end
|
||||
end)
|
||||
self.helpBtn:addClickListener(function()
|
||||
ModuleManager.TipsManager:showDescTips(I18N:getGlobalText(I18N.GlobalConst.ACT_BOUNTY_SIGNIN_DESC_2), self.helpBtn)
|
||||
end)
|
||||
end
|
||||
|
||||
function ActBountyComp:updateTime()
|
||||
if not self.data then
|
||||
return
|
||||
end
|
||||
self.timeTx:setText(Time:formatNumTimeStr(self.data:getNormalRemainTime()))
|
||||
end
|
||||
|
||||
function ActBountyComp:refresh(parentUI, dataKey)
|
||||
self.tipsTx1:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_2))
|
||||
self.levelTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_BOUNTY_SIGNIN_DESC_8))
|
||||
self.descTx1:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_5))
|
||||
self.descTx2:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_6))
|
||||
self.buyBtnTx1:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CLAIMALL))
|
||||
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.dataKey = dataKey or self.dataKey
|
||||
self.data = DataManager[self.dataKey]
|
||||
|
||||
if self.parentUI.getShowBountyBg then
|
||||
local showBg, bgPath = self.parentUI:getShowBountyBg()
|
||||
if showBg then
|
||||
self.bg:setActive(true)
|
||||
self.bg:setSprite(GConst.ATLAS_PATH.COMMON, bgPath)
|
||||
else
|
||||
self.bg:setActive(false)
|
||||
end
|
||||
end
|
||||
if self.parentUI.getBountyBanner then
|
||||
self.imgBanner:setTexture(self.parentUI:getBountyBanner())
|
||||
end
|
||||
if self.parentUI.getBountyBannerSize then
|
||||
self.imgBanner:setSizeDelta(self.parentUI:getBountyBannerSize())
|
||||
end
|
||||
if self.imgBannerLine1 then
|
||||
if self.parentUI.isShowBannerLine1 then
|
||||
self.imgBannerLine1:setActive(self.parentUI:isShowBannerLine1())
|
||||
else
|
||||
self.imgBannerLine1:setActive(false)
|
||||
end
|
||||
end
|
||||
if self.imgBannerLine2 then
|
||||
if self.parentUI.isShowBannerLine2 then
|
||||
self.imgBannerLine2:setActive(self.parentUI:isShowBannerLine2())
|
||||
else
|
||||
self.imgBannerLine2:setActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
-- Logger.printTable(DataManager.PaymentData:getActGiftMap())
|
||||
local gift1 = ConfigManager:getConfig("act_gift")[self.data:getProRewardGiftId()]
|
||||
self.buyBtnTx2:setText(GFunc.getFormatPrice(gift1.recharge_id))
|
||||
self.tipsTx2:setText((gift1.value or 0) .. "%")
|
||||
self.buyBtn2:setActive(not self.data:isUnlockProReward())
|
||||
self.titleTx:setText(self.parentUI:getCellName())
|
||||
self.titleTx:setSizeDeltaX(300)
|
||||
local width = self.titleTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
|
||||
width = math.min(300, width)
|
||||
self.titleTx:setSizeDeltaX(width)
|
||||
|
||||
-- 基础滑动窗
|
||||
self.cfgList = self.data:getBountyCfgList()
|
||||
local maxDay = self.data:getBountyMaxDay()
|
||||
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
|
||||
self.scrollRect:refillCells(maxDay)
|
||||
elseif self.scrollRect:getTotalCount() ~= maxDay then
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(maxDay)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
local idx = self.data:getBountyMinIdx()
|
||||
self.scrollRect:moveToIndex(idx)
|
||||
|
||||
self.buyBtn1:setActive(self.data:hasBountyRp())
|
||||
end
|
||||
|
||||
return ActBountyComp
|
||||
10
lua/app/ui/activity/common/comp/act_bounty_comp_v1.lua.meta
Normal file
10
lua/app/ui/activity/common/comp/act_bounty_comp_v1.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95975f5edb4424a3d89bf0df72c8e69c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
66
lua/app/ui/activity/common/comp/act_exchange_comp_v1.lua
Normal file
66
lua/app/ui/activity/common/comp/act_exchange_comp_v1.lua
Normal file
@ -0,0 +1,66 @@
|
||||
local ActExchangeComp = class("ActExchangeComp", LuaComponent)
|
||||
|
||||
local EXCHANGE_CELL = "app/ui/activity/common/cell/exchange_cell"
|
||||
|
||||
function ActExchangeComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.bg = uiMap["act_exchange_comp.bg"]
|
||||
self.topBg = uiMap["act_exchange_comp.bg_top"]
|
||||
self.timeTx = uiMap["act_exchange_comp.time_bg.time_tx"]
|
||||
self.scrollrect = uiMap["act_exchange_comp.scrollrect"]
|
||||
end
|
||||
|
||||
function ActExchangeComp:updateTime()
|
||||
if not self.data then
|
||||
return
|
||||
end
|
||||
self.timeTx:setText(I18N:getGlobalText(I18N.GlobalConst.TIME_END_DESC_1, Time:formatNumTimeStr(self.data:getNormalRemainTime())))
|
||||
end
|
||||
|
||||
function ActExchangeComp:refresh(parentUI, dataKey)
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.dataKey = dataKey or self.dataKey
|
||||
self.data = DataManager[self.dataKey]
|
||||
|
||||
self.cfg = self.data:getExchangeCfgList()
|
||||
if not self.scrollRect then
|
||||
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return EXCHANGE_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(parentUI, self.dataKey, self.cfg[index])
|
||||
end)
|
||||
local showTopBg, topBgStr = self.parentUI:getExchangeTopBg()
|
||||
if showTopBg then
|
||||
self.topBg:setActive(true)
|
||||
self.topBg:setTexture(topBgStr)
|
||||
|
||||
else
|
||||
self.topBg:setActive(false)
|
||||
end
|
||||
local showBg, bgStr = self.parentUI:getShowExchangeBg()
|
||||
if showBg then
|
||||
self.bg:setActive(true)
|
||||
self.bg:setTexture(bgStr)
|
||||
else
|
||||
self.bg:setActive(false)
|
||||
end
|
||||
end
|
||||
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
|
||||
self.scrollRect:refillCells(#self.cfg)
|
||||
elseif self.scrollRect:getTotalCount() ~= #self.cfg then
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.cfg)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
|
||||
self.data:setExchangeRp()
|
||||
end
|
||||
|
||||
function ActExchangeComp:setActive(active)
|
||||
self.baseObject:setActive(active)
|
||||
end
|
||||
|
||||
return ActExchangeComp
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9be4a23a45ed4a518947112ddd2a991
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
101
lua/app/ui/activity/common/comp/act_exchange_comp_v2.lua
Normal file
101
lua/app/ui/activity/common/comp/act_exchange_comp_v2.lua
Normal file
@ -0,0 +1,101 @@
|
||||
local ActExchangeComp = class("ActExchangeComp", LuaComponent)
|
||||
|
||||
local EXCHANGE_CELL = "app/ui/activity/common/cell/exchange_cell"
|
||||
|
||||
function ActExchangeComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
|
||||
self.bg = uiMap["act_exchange_comp_v2.bg"]
|
||||
self.topBg = uiMap["act_exchange_comp_v2.bg_top"]
|
||||
self.timeTx = uiMap["act_exchange_comp_v2.time_bg.time_tx"]
|
||||
self.scrollrect = uiMap["act_exchange_comp_v2.scrollrect"]
|
||||
|
||||
self.selBg = uiMap["act_exchange_comp_v2.sel_bg"]
|
||||
self.pageBtns = {}
|
||||
self.pageBtnTxs = {}
|
||||
for i = 1, 2 do
|
||||
self.pageBtns[i] = uiMap["act_exchange_comp_v2.sel_bg.page_btn_" .. i]
|
||||
self.pageBtnTxs[i] = uiMap["act_exchange_comp_v2.sel_bg.page_btn_" .. i .. ".text"]
|
||||
self.pageBtns[i]:addClickListener(function()
|
||||
if self.page == i then
|
||||
return
|
||||
end
|
||||
self.page = i
|
||||
self:refresh()
|
||||
end)
|
||||
end
|
||||
self.page = 1
|
||||
end
|
||||
|
||||
function ActExchangeComp:updateTime()
|
||||
if not self.data then
|
||||
return
|
||||
end
|
||||
self.timeTx:setText(I18N:getGlobalText(I18N.GlobalConst.TIME_END_DESC_1, Time:formatNumTimeStr(self.data:getNormalRemainTime())))
|
||||
end
|
||||
|
||||
function ActExchangeComp:refresh(parentUI, dataKey)
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.dataKey = dataKey or self.dataKey
|
||||
self.data = DataManager[self.dataKey]
|
||||
|
||||
self:refreshData()
|
||||
self:refreshPageBtn()
|
||||
|
||||
|
||||
if not self.scrollRect then
|
||||
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return EXCHANGE_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(parentUI, self.dataKey, self.cfg[index])
|
||||
end)
|
||||
local showTopBg, topBgStr = self.parentUI:getExchangeTopBg()
|
||||
if showTopBg then
|
||||
self.topBg:setActive(true)
|
||||
self.topBg:setTexture(topBgStr)
|
||||
|
||||
else
|
||||
self.topBg:setActive(false)
|
||||
end
|
||||
local showBg, bgStr = self.parentUI:getShowExchangeBg()
|
||||
if showBg then
|
||||
self.bg:setActive(true)
|
||||
self.bg:setTexture(bgStr)
|
||||
else
|
||||
self.bg:setActive(false)
|
||||
end
|
||||
end
|
||||
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
|
||||
self.scrollRect:refillCells(#self.cfg)
|
||||
elseif self.scrollRect:getTotalCount() ~= #self.cfg then
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.cfg)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
|
||||
self.data:setExchangeRp()
|
||||
end
|
||||
|
||||
function ActExchangeComp:refreshData()
|
||||
self.cfg = self.data:getExchangeCfgList(self.page)
|
||||
end
|
||||
|
||||
function ActExchangeComp:refreshPageBtn()
|
||||
for i = 1, 2 do
|
||||
self.pageBtnTxs[i]:setText(self.parentUI:getExchangeBtnName(i))
|
||||
if i == self.page then
|
||||
self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_set_2")
|
||||
else
|
||||
self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_set_1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActExchangeComp:setActive(active)
|
||||
self.baseObject:setActive(active)
|
||||
end
|
||||
|
||||
return ActExchangeComp
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c27eb51fe4a194ef9b43c63283cebc56
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
590
lua/app/ui/activity/common/comp/act_game_cook_comp.lua
Normal file
590
lua/app/ui/activity/common/comp/act_game_cook_comp.lua
Normal file
@ -0,0 +1,590 @@
|
||||
local ActGameComp = class("ActGameComp", LuaComponent)
|
||||
|
||||
local FOOD_INGREDIENTS_COUNT = 5
|
||||
local TARGET_CELL = "app/ui/activity/common/cell/target_cell"
|
||||
local SETTLEMENT_CELL = "app/ui/activity/common/cell/cook_settlement_cell"
|
||||
|
||||
local TARGET_CELL_WIDTH = 100
|
||||
|
||||
local GAME_STEP = {
|
||||
DEFAULT = 1, -- 默认阶段 可以开始游戏
|
||||
PREPARE = 2, -- 准备
|
||||
MAKE_1 = 3, -- 做菜
|
||||
MAKE_2 = 4, -- 上菜
|
||||
END = 5, -- 结束
|
||||
SETTLEMENT = 6, -- 展示结果
|
||||
}
|
||||
local PREPARE_TIME = 0.5
|
||||
local GAME_FOOD_ANI_TIME = 0.15
|
||||
local GAME_INGREDIENTS_ANI_TIME = 0.15
|
||||
local END_TIME = 1
|
||||
local GAME_TIME = GFunc.getConstIntValue("act_active_time")
|
||||
|
||||
function ActGameComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
|
||||
self.spineObj = uiMap["act_game_comp.ui_spine_obj"]
|
||||
self.mainNode = uiMap["act_game_comp.main_node"]
|
||||
self.todayScoreDescTx = uiMap["act_game_comp.main_node.tx_desc"]
|
||||
self.mainDesc2Tx = uiMap["act_game_comp.main_node.tx_desc_2"]
|
||||
self.mainScrollRectPrefab = uiMap["act_game_comp.main_node.scroll_rect"]
|
||||
self.scoreBtn = uiMap["act_game_comp.main_node.img_score"]
|
||||
self.scoreDescTx = uiMap["act_game_comp.main_node.img_score.tx_desc"]
|
||||
self.scoreNumTx = uiMap["act_game_comp.main_node.img_score.tx_num"]
|
||||
self.startBtn = uiMap["act_game_comp.main_node.img_start"]
|
||||
self.startBtnTx = uiMap["act_game_comp.main_node.img_start.tx_desc"]
|
||||
self.foodBtns = {}
|
||||
self.foodHighlights = {}
|
||||
for i = 1, FOOD_INGREDIENTS_COUNT do
|
||||
table.insert(self.foodBtns, uiMap["act_game_comp.main_node.food_btn_" .. i])
|
||||
table.insert(self.foodHighlights, uiMap["act_game_comp.main_node.food_btn_" .. i .. ".highlight"])
|
||||
end
|
||||
|
||||
self.gameNode = uiMap["act_game_comp.game_node"]
|
||||
self.gameTimeNode = uiMap["act_game_comp.game_node.time_node"]
|
||||
self.gameTimeTx = uiMap["act_game_comp.game_node.time_node.tx_time"]
|
||||
self.gameFoodNode = uiMap["act_game_comp.game_node.food_node"]
|
||||
self.gameFoodTitleTx = uiMap["act_game_comp.game_node.food_node.title_bg.title_tx"]
|
||||
self.gameFoodIcon = uiMap["act_game_comp.game_node.food_node.icon"]
|
||||
self.gameFoodNameTx = uiMap["act_game_comp.game_node.food_node.name_tx"]
|
||||
self.gameMake1Node = uiMap["act_game_comp.game_node.make_1_node"]
|
||||
self.gameMake1TitleTx = uiMap["act_game_comp.game_node.make_1_node.title_tx"]
|
||||
self.gameMake1Btns = {}
|
||||
self.gameMake1Icons = {}
|
||||
self.gameMake1Flags = {}
|
||||
for i = 1, FOOD_INGREDIENTS_COUNT do
|
||||
table.insert(self.gameMake1Btns, uiMap["act_game_comp.game_node.make_1_node.food_btn_" .. i])
|
||||
table.insert(self.gameMake1Icons, uiMap["act_game_comp.game_node.make_1_node.food_btn_" .. i .. ".icon"])
|
||||
table.insert(self.gameMake1Flags, uiMap["act_game_comp.game_node.make_1_node.food_btn_" .. i .. ".flag"])
|
||||
end
|
||||
self.gameMake2Node = uiMap["act_game_comp.game_node.make_2_node"]
|
||||
self.gameMake2TitleTx = uiMap["act_game_comp.game_node.make_2_node.title_tx"]
|
||||
self.gameMake2Slider = uiMap["act_game_comp.game_node.make_2_node.slider"]
|
||||
self.gameMake2SliderFlag = uiMap["act_game_comp.game_node.make_2_node.slider.flag"]
|
||||
self.gameMake2SliderBestTx = uiMap["act_game_comp.game_node.make_2_node.slider.best.best_tx"]
|
||||
self.gameFuncBtn = uiMap["act_game_comp.game_node.make_2_node.func_btn"]
|
||||
self.gameFuncTx = uiMap["act_game_comp.game_node.make_2_node.func_btn.tx_desc"]
|
||||
self.gameLastDescTips = uiMap["act_game_comp.game_node.last_desc_tips"]
|
||||
self.gameLastDescTipsCanvasGroup = self.gameLastDescTips:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
|
||||
self.gameLastDescTx = uiMap["act_game_comp.game_node.last_desc_tips.tx_desc"]
|
||||
|
||||
self.settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
self.settlementTitleTx = uiMap["act_game_comp.settlement_node.bg.tx_title"]
|
||||
self.settlementScoreTitleTx = uiMap["act_game_comp.settlement_node.bg.score_tx"]
|
||||
self.settlementScoreNumTx = uiMap["act_game_comp.settlement_node.bg.score_num_tx"]
|
||||
self.settlementScrollRectPrefab = uiMap["act_game_comp.settlement_node.bg.scrollrect"]
|
||||
|
||||
self.tipsNode = uiMap["act_game_comp.tips_node"]
|
||||
self.prepareTips = uiMap["act_game_comp.tips_node.prepare_tips"]
|
||||
self.prepareTx = uiMap["act_game_comp.tips_node.prepare_tips.tx_desc"]
|
||||
self.endTips = uiMap["act_game_comp.tips_node.end_tips"]
|
||||
self.endTx = uiMap["act_game_comp.tips_node.end_tips.tx_desc"]
|
||||
|
||||
self.scrollRectContent = uiMap["act_game_comp.main_node.scroll_rect.viewport.content"]
|
||||
self.rewardSliderBg = uiMap["act_game_comp.main_node.scroll_rect.viewport.content.slider_bg"]
|
||||
self.rewardSlider = uiMap["act_game_comp.main_node.scroll_rect.viewport.content.slider_bg.slider"]
|
||||
|
||||
self.scoreDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_16))
|
||||
self.startBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_26))
|
||||
self.mainDesc2Tx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_7))
|
||||
|
||||
self.gameFoodTitleTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_13))
|
||||
self.gameMake1TitleTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_14))
|
||||
self.gameMake2TitleTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_15))
|
||||
self.gameMake2SliderBestTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_16))
|
||||
self.gameFuncTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_17))
|
||||
|
||||
self.settlementTitleTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_18))
|
||||
self.settlementScoreTitleTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_19))
|
||||
|
||||
self.prepareTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_20))
|
||||
self.endTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_12))
|
||||
|
||||
-- 初始化数据
|
||||
self.step = GAME_STEP.DEFAULT
|
||||
self.lastFoodToastPosY = self.gameLastDescTips:getAnchoredPositionY()
|
||||
self:_addListeners()
|
||||
end
|
||||
|
||||
function ActGameComp:_addListeners()
|
||||
self.scoreBtn:addClickListener(function()
|
||||
self.parentUI:showGamePreviewUI()
|
||||
end)
|
||||
|
||||
self.startBtn:addClickListener(function()
|
||||
self:clickStart()
|
||||
end, GConst.CLICK_SOUND.NONE)
|
||||
|
||||
self.settlementNode:addClickListener(function()
|
||||
self:changeGameStep(GAME_STEP.DEFAULT)
|
||||
end)
|
||||
|
||||
for i = 1, FOOD_INGREDIENTS_COUNT do
|
||||
self.foodBtns[i]:addClickListener(function()
|
||||
self:clickFood(i)
|
||||
end)
|
||||
end
|
||||
|
||||
self.gameFuncBtn:addClickListener(function()
|
||||
self:clickUpFood()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:setParentUI(parentUI, dataKey)
|
||||
self.parentUI = parentUI
|
||||
self.dataKey = dataKey
|
||||
self.data = DataManager[dataKey]
|
||||
self.targetCfgs = self.data:getGameTargetCfgList()
|
||||
|
||||
-- local screenW, screenH = GFunc.getUIExpandScreenSize()
|
||||
-- local count = math.max(#self.targetCfgs, 0)
|
||||
-- local bestW = TARGET_CELL_WIDTH * count
|
||||
-- local maxW = screenW - SCROLL_DEFAULT_INFO.smallThanScreen
|
||||
-- local w = math.max(math.min(bestW, maxW), SCROLL_DEFAULT_INFO.width)
|
||||
-- self.rewardScoreImg:setAnchoredPositionX(SCROLL_DEFAULT_INFO.posX - w / 2 - 50)
|
||||
-- self.scrollrect:setSizeDeltaX(w)
|
||||
end
|
||||
|
||||
function ActGameComp:clickFood(index)
|
||||
if self.step == GAME_STEP.MAKE_1 then
|
||||
local rightIdx = self.shuffleFoodIngredients[self.curShuffleIndex]
|
||||
if index == rightIdx then
|
||||
self.curShuffleIndex = self.curShuffleIndex + 1
|
||||
if self.curShuffleIndex > #self.shuffleFoodIngredients then
|
||||
self:changeGameStep(GAME_STEP.MAKE_2)
|
||||
else
|
||||
self:refreshIngredients()
|
||||
end
|
||||
self:refreshMainIngredients()
|
||||
end
|
||||
elseif self.step == GAME_STEP.DEFAULT then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_8))
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:refresh(parentUI)
|
||||
self.parentUI = parentUI
|
||||
|
||||
-- 刷新主积分
|
||||
self:refreshStepRewardScrollrect()
|
||||
-- 默认阶段
|
||||
self:changeGameStep(GAME_STEP.DEFAULT, true)
|
||||
end
|
||||
|
||||
function ActGameComp:refreshStepRewardScrollrect()
|
||||
self.scoreNumTx:setText(self.data:getGameTotalScore())
|
||||
self.todayScoreDescTx:setText(self.data:getGameTodayLimitScoreStr())
|
||||
|
||||
local totalTimes = self.data:getGameTotalScore()
|
||||
self.rewardSliderBg:setSizeDeltaX(TARGET_CELL_WIDTH * #self.targetCfgs)
|
||||
self.rewardSlider.value = GFunc.getUnevenSliderValue(self.data:getGameTargetList(), totalTimes, 0.5)
|
||||
|
||||
if self.stepScrollrect then
|
||||
self.stepScrollrect:updateAllCell()
|
||||
-- self.stepScrollrect:moveToIndex(self.data:getGameMinIdx())
|
||||
return
|
||||
end
|
||||
|
||||
self.stepScrollrect = self.mainScrollRectPrefab:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.stepScrollrect:addInitCallback(function()
|
||||
return TARGET_CELL
|
||||
end)
|
||||
self.stepScrollrect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.parentUI, self.dataKey, self.targetCfgs[index], function()
|
||||
self:onClickTarget(self.targetCfgs[index])
|
||||
end)
|
||||
end)
|
||||
self.stepScrollrect:clearCells()
|
||||
self.stepScrollrect:refillCells(#self.targetCfgs, nil, self.data:getGameMinIdx())
|
||||
end
|
||||
|
||||
-- 点击特定积分奖励
|
||||
function ActGameComp:onClickTarget(id)
|
||||
self.parentUI:reqActivityGameTarget(id)
|
||||
end
|
||||
|
||||
-- 开始游戏
|
||||
function ActGameComp:clickStart()
|
||||
if not self.data:getIsOpen() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ADVENTURE_CLOSED))
|
||||
return
|
||||
end
|
||||
|
||||
if self.step == GAME_STEP.DEFAULT then
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_FARMPARTY_COOK_BEGIN)
|
||||
self:changeGameStep(GAME_STEP.PREPARE)
|
||||
end
|
||||
end
|
||||
|
||||
-- 上菜
|
||||
function ActGameComp:clickUpFood()
|
||||
if self.step == GAME_STEP.MAKE_2 then
|
||||
-- 判断当前位置
|
||||
local sliderFlagMaxX = self.gameMake2Slider:getSizeDeltaX()
|
||||
local curPosX = self.gameMake2SliderFlag:fastGetAnchoredPositionX()
|
||||
local percent = curPosX / sliderFlagMaxX
|
||||
local score = self:_getGameScoreByMake2Percent(percent)
|
||||
-- 记录
|
||||
self:recordSettlement(self.randomFood, percent, score)
|
||||
-- 切换下一场
|
||||
self:changeGameStep(GAME_STEP.MAKE_1)
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_FARMPARTY_COOK_QTE)
|
||||
end
|
||||
end
|
||||
|
||||
-- 分为3档 写死判定条件
|
||||
function ActGameComp:_getGameScoreByMake2Percent(percent)
|
||||
return self.data:getGameScoreByMake2Percent(percent)
|
||||
end
|
||||
|
||||
-- 变更游戏阶段
|
||||
function ActGameComp:changeGameStep(step, force)
|
||||
if step == self.step and not force then
|
||||
return
|
||||
end
|
||||
|
||||
self.step = step
|
||||
if self.step == GAME_STEP.DEFAULT then -- 默认状态
|
||||
self.startBtn:setActive(true)
|
||||
self.gameNode:setVisible(false)
|
||||
self.settlementNode:setVisible(false)
|
||||
self.tipsNode:setVisible(false)
|
||||
|
||||
self.mainDesc2Tx:setVisible(true)
|
||||
self:hideLastDesc()
|
||||
self:refreshMainIngredients()
|
||||
-- 重置结算数据
|
||||
self.settlementFoodList = {}
|
||||
-- spine动画
|
||||
self.spineObj:setActive(true)
|
||||
self.spineObj:playAnim("idle", true, true)
|
||||
|
||||
elseif self.step == GAME_STEP.PREPARE then -- 预备状态
|
||||
self.startBtn:setActive(false)
|
||||
self.gameNode:setVisible(false)
|
||||
self.settlementNode:setVisible(false)
|
||||
self.tipsNode:setVisible(true)
|
||||
|
||||
self.prepareTips:setVisible(true)
|
||||
self.endTips:setVisible(false)
|
||||
|
||||
self:showPrepareTipsAni()
|
||||
-- spine动画
|
||||
self.spineObj:setActive(false)
|
||||
|
||||
elseif self.step == GAME_STEP.MAKE_1 then
|
||||
self.startBtn:setActive(false)
|
||||
self.gameNode:setVisible(true)
|
||||
self.settlementNode:setVisible(false)
|
||||
self.tipsNode:setVisible(false)
|
||||
|
||||
self.gameFoodNode:setVisible(true)
|
||||
self.gameMake1Node:setVisible(true)
|
||||
self.gameMake2Node:setVisible(false)
|
||||
|
||||
self.mainDesc2Tx:setVisible(true)
|
||||
-- 随机生成一道菜和他的随机食材顺序
|
||||
self.randomFood = self.data:getGameRandomCookId()
|
||||
self.shuffleFoodIngredients = self.data:getGameShuffleFoodIngredients(self.randomFood)
|
||||
self.curShuffleIndex = 1
|
||||
-- 刷新食物和食材图标
|
||||
self:refreshFood(true)
|
||||
self:refreshIngredients(true)
|
||||
self:refreshMainIngredients()
|
||||
self:refreshLastDesc()
|
||||
-- spine动画
|
||||
self.spineObj:setActive(false)
|
||||
|
||||
elseif self.step == GAME_STEP.MAKE_2 then
|
||||
self.startBtn:setActive(false)
|
||||
self.gameNode:setVisible(true)
|
||||
self.settlementNode:setVisible(false)
|
||||
self.tipsNode:setVisible(false)
|
||||
|
||||
self.gameFoodNode:setVisible(false)
|
||||
self.gameMake1Node:setVisible(false)
|
||||
self.gameMake2Node:setVisible(true)
|
||||
|
||||
self.mainDesc2Tx:setVisible(false)
|
||||
self:hideLastDesc()
|
||||
self:refreshMainIngredients()
|
||||
-- 开始播放动画
|
||||
self:playMake2Ani()
|
||||
-- spine动画
|
||||
self.spineObj:setActive(true)
|
||||
self.spineObj:playAnim("serving", true, true)
|
||||
|
||||
elseif self.step == GAME_STEP.END then
|
||||
self.startBtn:setActive(false)
|
||||
self.gameNode:setVisible(false)
|
||||
self.settlementNode:setVisible(false)
|
||||
self.tipsNode:setVisible(true)
|
||||
|
||||
self.prepareTips:setVisible(false)
|
||||
self.endTips:setVisible(true)
|
||||
self.mainDesc2Tx:setVisible(true)
|
||||
|
||||
self:refreshMainIngredients()
|
||||
-- 等待一定时间后,通知服务器结算,结算成功后会切换到结算界面
|
||||
self:send2Server()
|
||||
elseif self.step == GAME_STEP.SETTLEMENT then
|
||||
self.startBtn:setActive(false)
|
||||
self.startBtn:setActive(false)
|
||||
self.gameNode:setVisible(false)
|
||||
self.settlementNode:setVisible(true)
|
||||
self.tipsNode:setVisible(false)
|
||||
self.mainDesc2Tx:setVisible(true)
|
||||
|
||||
self:showSettlement()
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:showPrepareTipsAni()
|
||||
if self.prepareTipsSeq then
|
||||
self.prepareTipsSeq:Kill()
|
||||
self.prepareTipsSeq = nil
|
||||
end
|
||||
self.prepareTipsSeq = self.prepareTips:createBindTweenSequence()
|
||||
self.prepareTipsSeq:AppendInterval(PREPARE_TIME)
|
||||
self.prepareTipsSeq:AppendCallback(function()
|
||||
self:changeGameStep(GAME_STEP.MAKE_1)
|
||||
-- 标记游戏结束时间
|
||||
self:setGameEndTime(Time:getServerTime() + GAME_TIME)
|
||||
self:updateTime()
|
||||
end)
|
||||
end
|
||||
|
||||
-- 刷新食物
|
||||
function ActGameComp:refreshFood(playAni)
|
||||
self.gameFoodIcon:setSprite(self.parentUI:getAtlasPath(), self.parentUI.ActConst.FOOD_ICON[self.randomFood])
|
||||
self.gameFoodNameTx:setText(I18N:getText("act_active_cook", self.randomFood, "value"))
|
||||
if playAni then
|
||||
-- 进入动画(<-)
|
||||
if self.gameFoodSeq then
|
||||
self.gameFoodSeq:Kill()
|
||||
self.gameFoodSeq = nil
|
||||
end
|
||||
self.gameFoodNode:setAnchoredPositionX(GConst.UI_SCREEN_WIDTH)
|
||||
self.gameFoodSeq = self.gameFoodNode:createBindTweenSequence()
|
||||
self.gameFoodSeq:AppendInterval(GAME_FOOD_ANI_TIME)
|
||||
self.gameFoodSeq:Append(self.gameFoodNode:getTransform():DOAnchorPosX(0, GAME_FOOD_ANI_TIME))
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新食材(Make1阶段)
|
||||
function ActGameComp:refreshIngredients(playAni)
|
||||
for i = 1, FOOD_INGREDIENTS_COUNT do
|
||||
if self.shuffleFoodIngredients[i] then
|
||||
self.gameMake1Btns[i]:setActive(true)
|
||||
self.gameMake1Icons[i]:setSprite(self.parentUI:getAtlasPath(), self.parentUI.ActConst.INGREDIENTS_ICON[self.shuffleFoodIngredients[i]])
|
||||
self.gameMake1Flags[i]:setVisible(self.curShuffleIndex > i)
|
||||
else
|
||||
self.gameMake1Btns[i]:setActive(false)
|
||||
end
|
||||
end
|
||||
if playAni then
|
||||
-- 进入动画(->)
|
||||
if self.gameIngredientsSeq then
|
||||
self.gameIngredientsSeq:Kill()
|
||||
self.gameIngredientsSeq = nil
|
||||
end
|
||||
self.gameMake1Node:setAnchoredPositionX(-GConst.UI_SCREEN_WIDTH)
|
||||
self.gameIngredientsSeq = self.gameMake1Node:createBindTweenSequence()
|
||||
self.gameIngredientsSeq:AppendInterval(GAME_INGREDIENTS_ANI_TIME)
|
||||
self.gameIngredientsSeq:Append(self.gameMake1Node:getTransform():DOAnchorPosX(0, GAME_INGREDIENTS_ANI_TIME))
|
||||
end
|
||||
end
|
||||
|
||||
-- 根据阶段 刷新主面板食材的动画
|
||||
function ActGameComp:refreshMainIngredients()
|
||||
if self.step == GAME_STEP.MAKE_1 then
|
||||
local remainIngredientsMap = {}
|
||||
if self.shuffleFoodIngredients and #self.shuffleFoodIngredients > 0 then
|
||||
for i = self.curShuffleIndex, #self.shuffleFoodIngredients do
|
||||
remainIngredientsMap[self.shuffleFoodIngredients[i]] = true
|
||||
end
|
||||
end
|
||||
for i = 1, FOOD_INGREDIENTS_COUNT do
|
||||
if remainIngredientsMap[i] then
|
||||
self.foodHighlights[i]:setVisible(true)
|
||||
else
|
||||
self.foodHighlights[i]:setVisible(false)
|
||||
end
|
||||
end
|
||||
else
|
||||
for i = 1, FOOD_INGREDIENTS_COUNT do
|
||||
self.foodHighlights[i]:setVisible(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新上一道菜的评价
|
||||
function ActGameComp:refreshLastDesc()
|
||||
if self.settlementFoodList and #self.settlementFoodList > 0 then
|
||||
local showToast = false
|
||||
self.gameLastDescTips:setVisible(true)
|
||||
local lastScore = self.settlementFoodList[#self.settlementFoodList].score
|
||||
if lastScore == self.data:getGameScoreConstValue(1) then
|
||||
showToast = true
|
||||
self.gameLastDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_9))
|
||||
elseif lastScore == self.data:getGameScoreConstValue(2) then
|
||||
showToast = true
|
||||
self.gameLastDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_10))
|
||||
elseif lastScore == self.data:getGameScoreConstValue(3) then
|
||||
showToast = true
|
||||
self.gameLastDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_11))
|
||||
else
|
||||
self.gameLastDescTips:setVisible(false)
|
||||
end
|
||||
|
||||
if showToast then
|
||||
if self.lastDescSeq then
|
||||
self.lastDescSeq:Kill()
|
||||
self.lastDescSeq = nil
|
||||
end
|
||||
self.lastDescSeq = self.gameLastDescTips:createBindTweenSequence()
|
||||
self.gameLastDescTips:setAnchoredPositionY(self.lastFoodToastPosY)
|
||||
self.gameLastDescTipsCanvasGroup.alpha = 1
|
||||
self.lastDescSeq:Append(self.gameLastDescTips:getTransform():DOAnchorPosY(self.lastFoodToastPosY + 180, 0.6))
|
||||
self.lastDescSeq:Append(self.gameLastDescTipsCanvasGroup:DOFade(0, 0.5))
|
||||
end
|
||||
else
|
||||
self.gameLastDescTips:setVisible(false)
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:hideLastDesc()
|
||||
self.gameLastDescTips:setVisible(false)
|
||||
end
|
||||
|
||||
-- 播放上菜滑动条动画
|
||||
function ActGameComp:playMake2Ani()
|
||||
-- 初始化数据
|
||||
self.sliderFlagPosX = 0
|
||||
local sliderFlagMaxX = self.gameMake2Slider:getSizeDeltaX()
|
||||
local minSpdP = self.data:getGameMinSpd()
|
||||
local maxSpdP = self.data:getGameMaxSpd()
|
||||
local randomSpdP = math.random(minSpdP, maxSpdP)
|
||||
self.sliderFlagMoveSpd = randomSpdP * sliderFlagMaxX / 100
|
||||
local moveTime = sliderFlagMaxX / self.sliderFlagMoveSpd
|
||||
-- 动画
|
||||
if self.sliderSeq then
|
||||
self.sliderSeq:Kill()
|
||||
self.sliderSeq = nil
|
||||
end
|
||||
self.sliderSeq = self.gameMake2Slider:createBindTweenSequence()
|
||||
self.gameMake2SliderFlag:setAnchoredPositionX(0)
|
||||
self.sliderSeq:Append(self.gameMake2SliderFlag:getTransform():DOAnchorPosX(sliderFlagMaxX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
self.sliderSeq:Append(self.gameMake2SliderFlag:getTransform():DOAnchorPosX(0, moveTime):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
self.sliderSeq:SetLoops(-1)
|
||||
end
|
||||
|
||||
function ActGameComp:send2Server()
|
||||
if self.endSeq then
|
||||
self.endSeq:Kill()
|
||||
self.endSeq = nil
|
||||
end
|
||||
self.endSeq = self.prepareTips:createBindTweenSequence()
|
||||
self.endSeq:AppendInterval(END_TIME)
|
||||
self.endSeq:AppendCallback(function()
|
||||
self.parentUI:reqActivityGameDo(self:_calculateTotalScore())
|
||||
end)
|
||||
end
|
||||
|
||||
-- 收到服务器消息后调用 展示结算
|
||||
function ActGameComp:settlementGame()
|
||||
self:changeGameStep(GAME_STEP.SETTLEMENT)
|
||||
end
|
||||
|
||||
-- 展示总数据
|
||||
function ActGameComp:showSettlement()
|
||||
local totalScore = self:_calculateTotalScore()
|
||||
self.settlementScoreNumTx:setText(totalScore)
|
||||
|
||||
self.settlementScrollrect = self.settlementScrollRectPrefab:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.settlementScrollrect:addInitCallback(function()
|
||||
return SETTLEMENT_CELL
|
||||
end)
|
||||
self.settlementScrollrect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.parentUI, self.dataKey, self.settlementFoodList[index])
|
||||
end)
|
||||
self.settlementScrollrect:clearCells()
|
||||
self.settlementScrollrect:refillCells(#self.settlementFoodList)
|
||||
end
|
||||
|
||||
-- 记录做菜得分
|
||||
function ActGameComp:recordSettlement(foodId, percent, score)
|
||||
if not self.settlementFoodList then
|
||||
self.settlementFoodList = {}
|
||||
end
|
||||
table.insert(self.settlementFoodList, {food = foodId, percent = percent, score = score})
|
||||
end
|
||||
|
||||
function ActGameComp:_calculateTotalScore()
|
||||
local score = 0
|
||||
if self.settlementFoodList then
|
||||
for _, v in ipairs(self.settlementFoodList) do
|
||||
score = score + v.score
|
||||
end
|
||||
end
|
||||
return score
|
||||
end
|
||||
|
||||
-- 标记游戏结束时间
|
||||
function ActGameComp:setGameEndTime(endGameTime)
|
||||
self.endGameTime = endGameTime
|
||||
end
|
||||
|
||||
function ActGameComp:updateTime()
|
||||
if self.step == GAME_STEP.MAKE_1 or self.step == GAME_STEP.MAKE_2 then
|
||||
local remainTime = (self.endGameTime or Time:getServerTime()) - Time:getServerTime()
|
||||
local str = 0
|
||||
if remainTime <= 0 then
|
||||
self:changeGameStep(GAME_STEP.END)
|
||||
else
|
||||
str = remainTime
|
||||
end
|
||||
|
||||
self.gameTimeTx:setText(str)
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:isGameStep()
|
||||
return self.step == GAME_STEP.MAKE_1 or self.step == GAME_STEP.MAKE_2
|
||||
end
|
||||
|
||||
function ActGameComp:onClose()
|
||||
self:changeGameStep(GAME_STEP.DEFAULT, true)
|
||||
|
||||
if self.prepareTipsSeq then
|
||||
self.prepareTipsSeq:Kill()
|
||||
self.prepareTipsSeq = nil
|
||||
end
|
||||
|
||||
if self.gameFoodSeq then
|
||||
self.gameFoodSeq:Kill()
|
||||
self.gameFoodSeq = nil
|
||||
end
|
||||
|
||||
if self.gameIngredientsSeq then
|
||||
self.gameIngredientsSeq:Kill()
|
||||
self.gameIngredientsSeq = nil
|
||||
end
|
||||
|
||||
if self.lastDescSeq then
|
||||
self.lastDescSeq:Kill()
|
||||
self.lastDescSeq = nil
|
||||
end
|
||||
|
||||
if self.sliderSeq then
|
||||
self.sliderSeq:Kill()
|
||||
self.sliderSeq = nil
|
||||
end
|
||||
|
||||
if self.endSeq then
|
||||
self.endSeq:Kill()
|
||||
self.endSeq = nil
|
||||
end
|
||||
end
|
||||
|
||||
return ActGameComp
|
||||
10
lua/app/ui/activity/common/comp/act_game_cook_comp.lua.meta
Normal file
10
lua/app/ui/activity/common/comp/act_game_cook_comp.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8811dd743c92f447b959a97e4e708e55
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
827
lua/app/ui/activity/common/comp/act_game_ferrule_comp.lua
Normal file
827
lua/app/ui/activity/common/comp/act_game_ferrule_comp.lua
Normal file
@ -0,0 +1,827 @@
|
||||
local ActGameComp = class("ActGameComp", LuaComponent)
|
||||
|
||||
local TARGET_CELL = "app/ui/activity/common/cell/target_cell"
|
||||
local PREVIEW_CELL = "app/ui/activity/common/cell/ferrule_preview_cell"
|
||||
|
||||
local TARGET_CELL_WIDTH = 100
|
||||
|
||||
local HERO_SPINE_ASSET_PATH = "assets/arts/spines/characters/%s/%s_skeletondata.asset"
|
||||
local MOVE_LINE_PARAMS = 3 -- 贝塞尔曲线参数
|
||||
|
||||
local ANI_TIME = {
|
||||
0.833,
|
||||
0.833,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
}
|
||||
|
||||
local ANI_NAME = {
|
||||
"out01",
|
||||
"out01",
|
||||
"out02",
|
||||
"out02",
|
||||
"out03",
|
||||
"out03",
|
||||
}
|
||||
|
||||
local DIE_TIME = 0.396
|
||||
|
||||
local YONGQUAN_ORDER = {
|
||||
100, -- 最高层
|
||||
15, -- 宠物影子中间
|
||||
}
|
||||
|
||||
local SCROLL_DEFAULT_INFO = {
|
||||
width = 589,
|
||||
posX = 64.5,
|
||||
smallThanScreen = 720 - 589
|
||||
}
|
||||
|
||||
local QLT_VFX = {
|
||||
[2] = "assets/prefabs/effects/ui/vfx_ui_b9_summer_b02.prefab",
|
||||
[3] = "assets/prefabs/effects/ui/vfx_ui_b9_summer_b03.prefab",
|
||||
[4] = "assets/prefabs/effects/ui/vfx_ui_b9_summer_b04.prefab",
|
||||
[5] = "assets/prefabs/effects/ui/vfx_ui_b9_summer_b05.prefab",
|
||||
}
|
||||
|
||||
function ActGameComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.todayScoreDescTx = uiMap["act_game_comp.main_node.tx_desc"]
|
||||
self.scoreNumTx = uiMap["act_game_comp.main_node.img_score.tx_num"]
|
||||
|
||||
uiMap["act_game_comp.img_preview"]:addClickListener(function()
|
||||
self.parentUI:showGamePreviewUI()
|
||||
end)
|
||||
|
||||
uiMap["act_game_comp.main_node.img_start"]:addClickListener(function()
|
||||
self:clickStart()
|
||||
end, GConst.CLICK_SOUND.NONE)
|
||||
|
||||
uiMap["act_game_comp.game_node.node_spine_start"]:addClickListener(function()
|
||||
self:doFly()
|
||||
end, GConst.CLICK_SOUND.NONE)
|
||||
|
||||
uiMap["act_game_comp.settlement_node"]:addClickListener(function()
|
||||
if #self.captureIds and #self.captureIds > 0 then
|
||||
self:showScoreFly(true)
|
||||
end
|
||||
self:exitHideMainNode()
|
||||
end)
|
||||
|
||||
uiMap["act_game_comp.main_node.img_score.img_help"]:addClickListener(function()
|
||||
self.parentUI:showTargetPreviewUI()
|
||||
end)
|
||||
|
||||
self.timeNode = uiMap["act_game_comp.tx_time_node.tx_time"]
|
||||
self:onClose()
|
||||
|
||||
local startSpine = uiMap["act_game_comp.game_node.spine_start"]
|
||||
startSpine:setVisible(false)
|
||||
uiMap["act_game_comp.game_node.spine_start.tx_start"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_21))
|
||||
uiMap["act_game_comp.settlement_node.bg.tx_title"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_10))
|
||||
uiMap["act_game_comp.settlement_node.bg.tx_score_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_11))
|
||||
uiMap["act_game_comp.game_node.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_9))
|
||||
|
||||
local settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
settlementNode:setActive(false)
|
||||
|
||||
self.isPlaying = false
|
||||
self.captureIds = {}
|
||||
self.petEffects = {}
|
||||
|
||||
local weight = GFunc.getConstIntValue("act_valentine_road")
|
||||
uiMap["act_game_comp.tips_node"]:setSizeDeltaX(weight)
|
||||
|
||||
self.scrollRectContent = uiMap["act_game_comp.main_node.scroll_rect.viewport.content"]
|
||||
self.rewardSliderBg = uiMap["act_game_comp.main_node.scroll_rect.viewport.content.slider_bg"]
|
||||
self.rewardSlider = uiMap["act_game_comp.main_node.scroll_rect.viewport.content.slider_bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
|
||||
self:showAddScore(nil, true)
|
||||
self:showTipsLine(false)
|
||||
self:showScoreFly(false)
|
||||
|
||||
self.scrollrect = uiMap["act_game_comp.main_node.scroll_rect"]
|
||||
self.scoreImg = uiMap["act_game_comp.main_node.img_score"]
|
||||
self.startNumTx = uiMap["act_game_comp.game_node.spine_start.tx_start_num"]
|
||||
|
||||
self.quanShuiHuaVfx = uiMap["act_game_comp.game_node.spine_yingzi.vfx_ui_b10_valentine_b01"] -- 套圈水花
|
||||
self.quanShuiHuaVfx:setActive(false)
|
||||
end
|
||||
|
||||
function ActGameComp:setParentUI(parentUI, dataKey)
|
||||
self.parentUI = parentUI
|
||||
self.dataKey = dataKey
|
||||
self.data = DataManager[dataKey]
|
||||
self.targetCfgs = self.data:getGameTargetCfgList()
|
||||
|
||||
self.isPlaying = false
|
||||
self.captureIds = {}
|
||||
self.petEffects = {}
|
||||
|
||||
self:initPets()
|
||||
self:setYongquanOrder(YONGQUAN_ORDER[1])
|
||||
self:showAddScore(nil, true)
|
||||
self:showTipsLine(false)
|
||||
self:showScoreFly(false)
|
||||
self.quanShuiHuaVfx:setActive(false)
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
local mainNode = uiMap["act_game_comp.main_node"]
|
||||
local gameNode = uiMap["act_game_comp.game_node"]
|
||||
local settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
settlementNode:setActive(false)
|
||||
mainNode:setAnchoredPositionY(0)
|
||||
gameNode:setAnchoredPositionY(-400)
|
||||
-- self.timeParentNode:setAnchoredPositionY(80)
|
||||
local startSpine = uiMap["act_game_comp.game_node.spine_start"]
|
||||
startSpine:setVisible(false)
|
||||
|
||||
local screenW, screenH = GFunc.getUIExpandScreenSize()
|
||||
local count = math.max(#self.targetCfgs, 0)
|
||||
local bestW = TARGET_CELL_WIDTH * count
|
||||
local maxW = screenW - SCROLL_DEFAULT_INFO.smallThanScreen
|
||||
local w = math.max(math.min(bestW, maxW), SCROLL_DEFAULT_INFO.width)
|
||||
self.scrollrect:setSizeDeltaX(w)
|
||||
self.scoreImg:setAnchoredPositionX(SCROLL_DEFAULT_INFO.posX - w / 2 - 60)
|
||||
self.startNumTx:setText(self.data:getGameTime() .. "S")
|
||||
end
|
||||
|
||||
function ActGameComp:onClose()
|
||||
if self.hideMainNodeSeq then
|
||||
self.hideMainNodeSeq:Kill()
|
||||
self.hideMainNodeSeq = nil
|
||||
end
|
||||
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
|
||||
if self.aniSeq then
|
||||
self.aniSeq:Kill()
|
||||
self.aniSeq = nil
|
||||
end
|
||||
|
||||
self.isPlaying = false
|
||||
self.timeAni = false
|
||||
self.timeNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = false
|
||||
self.timeNode:setLocalScale(1, 1, 1)
|
||||
self.captureIds = {}
|
||||
|
||||
if self.petSpineObjs then
|
||||
for _, objs in ipairs(self.petSpineObjs) do
|
||||
local node = objs.node
|
||||
if node.moveSeq then
|
||||
node.moveSeq:Kill()
|
||||
node.moveSeq = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
local node = uiMap["act_game_comp.tips_score_node"]
|
||||
if node.showSeq then
|
||||
node.showSeq:Kill()
|
||||
node.showSeq = nil
|
||||
end
|
||||
|
||||
if self.petEffects then
|
||||
for index, list in pairs(self.petEffects) do
|
||||
for qlt, obj in pairs(list) do
|
||||
obj:destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
self.petEffects = {}
|
||||
|
||||
self.nextPurpleTime = nil
|
||||
self.nextOrangeTime = nil
|
||||
end
|
||||
|
||||
function ActGameComp:refresh(parentUI)
|
||||
self.parentUI = parentUI
|
||||
local uiMap = self:getUIMap()
|
||||
|
||||
uiMap["act_game_comp.main_node.img_score.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_VALENTINE_DESC_12))
|
||||
uiMap["act_game_comp.img_preview.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_11))
|
||||
uiMap["act_game_comp.main_node.img_start.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_26))
|
||||
self:refreshStepRewardScrollrect()
|
||||
end
|
||||
|
||||
function ActGameComp:refreshStepRewardScrollrect()
|
||||
local uiMap = self:getUIMap()
|
||||
self.scoreNumTx:setText(self.data:getGameTotalScore())
|
||||
self.todayScoreDescTx:setText(self.data:getGameTodayLimitScoreStr())
|
||||
|
||||
local totalTimes = self.data:getGameTotalScore()
|
||||
self.rewardSliderBg:setSizeDeltaX(TARGET_CELL_WIDTH * #self.targetCfgs)
|
||||
self.rewardSlider.value = GFunc.getUnevenSliderValue(self.data:getGameTargetList(), totalTimes, 0.5)
|
||||
|
||||
if self.stepScrollrect then
|
||||
self.stepScrollrect:updateAllCell()
|
||||
return
|
||||
end
|
||||
|
||||
self.stepScrollrect = uiMap["act_game_comp.main_node.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.stepScrollrect:addInitCallback(function()
|
||||
return TARGET_CELL
|
||||
end)
|
||||
self.stepScrollrect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.parentUI, self.dataKey, self.targetCfgs[index], function()
|
||||
self:onClickTarget(self.targetCfgs[index])
|
||||
end)
|
||||
end)
|
||||
self.stepScrollrect:clearCells()
|
||||
self.stepScrollrect:refillCells(#self.targetCfgs, nil, self.data:getGameMinIdx())
|
||||
end
|
||||
|
||||
function ActGameComp:hideMainNode()
|
||||
self.timeAni = false
|
||||
self.timeNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = false
|
||||
self.timeNode:setLocalScale(1, 1, 1)
|
||||
|
||||
self:showTipsLine(true, true)
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
local mainNode = uiMap["act_game_comp.main_node"]
|
||||
local gameNode = uiMap["act_game_comp.game_node"]
|
||||
local timeNode = uiMap["act_game_comp.tx_time_node.tx_time"]
|
||||
local spineYouyongquan = uiMap["act_game_comp.game_node.spine_yingzi.spine_youyongquan"]
|
||||
local spineYingzi = uiMap["act_game_comp.game_node.spine_yingzi"]
|
||||
local spineStartNode = uiMap["act_game_comp.game_node.node_spine_start"]
|
||||
|
||||
if self.hideMainNodeSeq then
|
||||
self.hideMainNodeSeq:Kill()
|
||||
self.hideMainNodeSeq = nil
|
||||
end
|
||||
self.hideMainNodeSeq = self:getBaseObject():createBindTweenSequence()
|
||||
self.hideMainNodeSeq:AppendCallback(function()
|
||||
self.parentUI:disableUITouch()
|
||||
timeNode:setText(self.data:getGameTime())
|
||||
|
||||
local x, y = spineStartNode:fastGetAnchoredPosition()
|
||||
spineYingzi:setAnchoredPosition(x, y)
|
||||
spineYouyongquan:playAnimComplete("born", false, true, function()
|
||||
spineYouyongquan:playAnim("idle01", true, true)
|
||||
end)
|
||||
spineYingzi:playAnimComplete("born", false, true, function()
|
||||
spineYingzi:playAnim("idle01", true, true)
|
||||
end)
|
||||
end)
|
||||
local titleObj = self.parentUI:getTitleBg()
|
||||
|
||||
self.hideMainNodeSeq:Append(mainNode:getTransform():DOAnchorPosY(-300, 0.5))
|
||||
self.hideMainNodeSeq:Join(titleObj:getTransform():DOAnchorPosY(150, 0.5))
|
||||
self.hideMainNodeSeq:Append(gameNode:getTransform():DOAnchorPosY(0, 0.5))
|
||||
-- self.hideMainNodeSeq:Join(self.timeParentNode:getTransform():DOAnchorPosY(-185, 0.5))
|
||||
self.hideMainNodeSeq:AppendCallback(function()
|
||||
if self.hideMainNodeSeq then
|
||||
self.hideMainNodeSeq:Kill()
|
||||
self.hideMainNodeSeq = nil
|
||||
end
|
||||
local startSpine = uiMap["act_game_comp.game_node.spine_start"]
|
||||
startSpine:setVisible(true)
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_SUMMER_TIPS)
|
||||
startSpine:playAnimComplete("idle", false, true, function()
|
||||
startSpine:setVisible(false)
|
||||
self.parentUI:enableUITouch()
|
||||
self:startGame()
|
||||
end)
|
||||
end)
|
||||
|
||||
self:setYongquanOrder(YONGQUAN_ORDER[1])
|
||||
self.quanShuiHuaVfx:setActive(false)
|
||||
end
|
||||
|
||||
function ActGameComp:exitHideMainNode()
|
||||
if self.hideMainNodeSeq then
|
||||
self.hideMainNodeSeq:Kill()
|
||||
self.hideMainNodeSeq = nil
|
||||
end
|
||||
self:showTipsLine(false)
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
local mainNode = uiMap["act_game_comp.main_node"]
|
||||
local gameNode = uiMap["act_game_comp.game_node"]
|
||||
local timeNode = uiMap["act_game_comp.game_node.tx_time"]
|
||||
local titleObj = self.parentUI:getTitleBg()
|
||||
local settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
settlementNode:setActive(false)
|
||||
|
||||
self.hideMainNodeSeq = self:getBaseObject():createBindTweenSequence()
|
||||
self.hideMainNodeSeq:AppendCallback(function()
|
||||
self.parentUI:disableUITouch()
|
||||
end)
|
||||
|
||||
self.hideMainNodeSeq:Append(gameNode:getTransform():DOAnchorPosY(-400, 0.5))
|
||||
-- self.hideMainNodeSeq:Join(self.timeParentNode:getTransform():DOAnchorPosY(80, 0.5))
|
||||
self.hideMainNodeSeq:Append(mainNode:getTransform():DOAnchorPosY(0, 0.5))
|
||||
self.hideMainNodeSeq:Join(titleObj:getTransform():DOAnchorPosY(-143, 0.5))
|
||||
self.hideMainNodeSeq:AppendCallback(function()
|
||||
self.parentUI:enableUITouch()
|
||||
if self.hideMainNodeSeq then
|
||||
self.hideMainNodeSeq:Kill()
|
||||
self.hideMainNodeSeq = nil
|
||||
end
|
||||
end)
|
||||
|
||||
local startSpine = uiMap["act_game_comp.game_node.spine_start"]
|
||||
startSpine:setVisible(false)
|
||||
end
|
||||
|
||||
function ActGameComp:onClickTarget(id)
|
||||
self.parentUI:reqActivityGameTarget(id)
|
||||
end
|
||||
|
||||
function ActGameComp:clickStart()
|
||||
if not self.data:getIsOpen() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ADVENTURE_CLOSED))
|
||||
return
|
||||
end
|
||||
|
||||
BIReport:postActValentineGame(BIReport.ACT_OPT_TYPE.START_GAME)
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_SUMMER_START)
|
||||
|
||||
self:hideMainNode()
|
||||
end
|
||||
|
||||
function ActGameComp:startGame()
|
||||
self.endGameTime = Time:getServerTime() + self.data:getGameTime()
|
||||
self.timeNode:setText(self.data:getGameTime())
|
||||
self.isPlaying = true
|
||||
self.captureIds = {}
|
||||
end
|
||||
|
||||
function ActGameComp:exitGame()
|
||||
self.isPlaying = false
|
||||
|
||||
local score = 0
|
||||
for _, id in ipairs(self.captureIds) do
|
||||
score = score + self.data:getGameFerruleCfg(id).point
|
||||
end
|
||||
self.parentUI:reqActivityGameDo(score)
|
||||
end
|
||||
|
||||
function ActGameComp:settlementGame()
|
||||
self:refreshStepRewardScrollrect()
|
||||
self:refreshSettlement()
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
local settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
settlementNode:setActive(true)
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
|
||||
self.settlementNodeSeq = settlementNode:createBindTweenSequence()
|
||||
self.settlementNodeSeq:Append(settlementNode:getTransform():DOScale(1.05, 0.15))
|
||||
self.settlementNodeSeq:Append(settlementNode:getTransform():DOScale(1, 0.2))
|
||||
self.settlementNodeSeq:AppendCallback(function()
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:updateTime()
|
||||
if self.isPlaying then
|
||||
local remainTime = self.endGameTime - Time:getServerTime()
|
||||
local str = 0
|
||||
if remainTime <= 0 then
|
||||
self:exitGame()
|
||||
else
|
||||
str = remainTime
|
||||
end
|
||||
|
||||
if remainTime <= 3 then
|
||||
str = "<color=#FF534B>" .. str .. "</color>"
|
||||
if not self.timeAni then
|
||||
self.timeNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = true
|
||||
self.timeNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR):Play("ui_act_summer_time", -1, 0)
|
||||
end
|
||||
self.timeAni = true
|
||||
end
|
||||
|
||||
self.timeNode:setText(str)
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:refreshSettlement()
|
||||
local count = #self.captureIds
|
||||
local score = 0
|
||||
for _, id in ipairs(self.captureIds) do
|
||||
score = score + self.data:getGameFerruleCfg(id).point
|
||||
end
|
||||
local line = math.max((count - 1) // 5 + 1, 1)
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
uiMap["act_game_comp.settlement_node.bg"]:setSizeDeltaY(line * 118 + 282)
|
||||
local txScore = uiMap["act_game_comp.settlement_node.bg.tx_score"]
|
||||
txScore:setText(score)
|
||||
|
||||
if self.settlementScrollRect then
|
||||
self.settlementScrollRect:clearCells()
|
||||
self.settlementScrollRect:refillCells(count)
|
||||
return
|
||||
end
|
||||
|
||||
local scrollRectObj = uiMap["act_game_comp.settlement_node.bg.scrollrect"]
|
||||
self.settlementScrollRect = scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.settlementScrollRect:addInitCallback(function()
|
||||
return PREVIEW_CELL
|
||||
end)
|
||||
self.settlementScrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.data:getGameFerruleCfg(self.captureIds[index]).pet)
|
||||
end)
|
||||
self.settlementScrollRect:clearCells()
|
||||
self.settlementScrollRect:refillCells(count)
|
||||
end
|
||||
|
||||
function ActGameComp:initPets()
|
||||
local uiMap = self:getUIMap()
|
||||
self.petList = {}
|
||||
self.petWeightList = {}
|
||||
self.noPurpleList = {}
|
||||
self.noPurpleWeightList = {}
|
||||
self.noOrangeList = {}
|
||||
self.noOrangeWeightList = {}
|
||||
self.noBothList = {}
|
||||
self.noBothWeightList = {}
|
||||
self.purpleList = {}
|
||||
self.orangeList = {}
|
||||
for id, cfg in pairs(self.data:getGameFerruleCfg()) do
|
||||
table.insert(self.petList, id)
|
||||
table.insert(self.petWeightList, cfg.weight)
|
||||
if cfg.qlt ~= 3 then
|
||||
table.insert(self.noPurpleList, id)
|
||||
table.insert(self.noPurpleWeightList, cfg.weight)
|
||||
else
|
||||
table.insert(self.purpleList, id)
|
||||
end
|
||||
if cfg.qlt ~= 4 then
|
||||
table.insert(self.noOrangeList, id)
|
||||
table.insert(self.noOrangeWeightList, cfg.weight)
|
||||
else
|
||||
table.insert(self.orangeList, id)
|
||||
end
|
||||
if cfg.qlt ~= 4 and cfg.qlt ~= 3 then
|
||||
table.insert(self.noBothList, id)
|
||||
table.insert(self.noBothWeightList, cfg.weight)
|
||||
end
|
||||
end
|
||||
|
||||
if not self.petSpineObjs then
|
||||
self.petSpineObjs = {}
|
||||
for i = 1, 6 do
|
||||
self.petSpineObjs[i] = {
|
||||
index = i,
|
||||
node = uiMap["act_game_comp.spine_node.pet_node_" .. i],
|
||||
shadow = uiMap["act_game_comp.spine_node.pet_node_" .. i .. ".spine_shadow_" .. i],
|
||||
spinePet = uiMap["act_game_comp.spine_node.pet_node_" .. i .. ".spine_shadow_" .. i .. ".pet_node.spine_pet"],
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
self.screenW, self.screenH = GFunc.getUIExpandScreenSize()
|
||||
self.halfScreenW = self.screenW / 2 + 100
|
||||
|
||||
for _, objs in ipairs(self.petSpineObjs) do
|
||||
self:changePet(objs)
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:changePet(objs)
|
||||
local id = self:getPetRandomId() or 101
|
||||
objs.randomId = id
|
||||
local config = self.data:getGameFerruleCfg(id)
|
||||
local pId = DataManager.PetData:getPetModelName(config.pet)
|
||||
local path = string.format(HERO_SPINE_ASSET_PATH, pId, pId)
|
||||
local spineObj = objs.spinePet
|
||||
spineObj:setVisible(false)
|
||||
local direct = math.random(1, 2) == 1 and -1 or 1
|
||||
objs.direct = direct
|
||||
if pId and path then
|
||||
spineObj:loadAssetAsync(path, function()
|
||||
spineObj:setVisible(true)
|
||||
spineObj:setLocalScale(-0.6 * direct, 0.6)
|
||||
spineObj:playAnimOnUpdate("idle", true, true, true, math.random())
|
||||
end, path)
|
||||
end
|
||||
|
||||
local node = objs.node
|
||||
if node.moveSeq then
|
||||
node.moveSeq:Kill()
|
||||
node.moveSeq = nil
|
||||
end
|
||||
node.moveSeq = node:createBindTweenSequence()
|
||||
local speed = config.speed
|
||||
objs.speed = config.speed
|
||||
local distance = self.halfScreenW --* 2
|
||||
if direct == -1 then -- 向右
|
||||
node:setAnchoredPositionX(-self.halfScreenW)
|
||||
node.moveSeq:Append(node:getTransform():DOAnchorPosX(distance, distance * 2 / speed):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
else -- 向左
|
||||
node:setAnchoredPositionX(self.halfScreenW)
|
||||
node.moveSeq:Append(node:getTransform():DOAnchorPosX(-distance, distance * 2 / speed):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
end
|
||||
node.moveSeq:AppendCallback(function()
|
||||
if node.moveSeq then
|
||||
node.moveSeq:Kill()
|
||||
node.moveSeq = nil
|
||||
end
|
||||
self:changePet(objs)
|
||||
end)
|
||||
|
||||
if not self.petEffects[objs.index] then
|
||||
self.petEffects[objs.index] = {}
|
||||
end
|
||||
|
||||
local petCfg = DataManager.PetData:getPetConfig(config.pet)
|
||||
if not petCfg then
|
||||
return
|
||||
end
|
||||
|
||||
local qlt = DataManager.PetData:getGlobalQltByPetQlt(petCfg.qlt)
|
||||
for q, obj in pairs(self.petEffects[objs.index]) do
|
||||
obj:setActive(false)
|
||||
end
|
||||
|
||||
if self.petEffects[objs.index][qlt] then
|
||||
self.petEffects[objs.index][qlt]:setActive(true)
|
||||
self.petEffects[objs.index][qlt]:play()
|
||||
return
|
||||
end
|
||||
|
||||
local path = QLT_VFX[qlt]
|
||||
if not path then
|
||||
return
|
||||
end
|
||||
|
||||
EffectManager:loadUIEffectAsync(path, self.parentUI, node, 11, function(obj)
|
||||
if self.petEffects[objs.index][qlt] then
|
||||
obj:destroy()
|
||||
return
|
||||
end
|
||||
self.petEffects[objs.index][qlt] = obj
|
||||
obj:setLocalScale(1, 1, 1)
|
||||
obj:setAnchoredPosition(0, 0, 0)
|
||||
obj:play()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:getPetRandomId()
|
||||
local time = Time:getServerTime()
|
||||
|
||||
if self.nextOrangeTime and self.nextOrangeTime <= time then -- 必选橙色
|
||||
self.nextOrangeTime = time + GFunc.getConstIntValue("act_valentine_orange")
|
||||
return self.orangeList[math.random(1, #self.orangeList)]
|
||||
end
|
||||
|
||||
if self.nextPurpleTime and self.nextPurpleTime <= time then -- 必选紫色
|
||||
self.nextPurpleTime = time + GFunc.getConstIntValue("act_valentine_purple")
|
||||
return self.purpleList[math.random(1, #self.purpleList)]
|
||||
end
|
||||
|
||||
local canChoosePurple = not self.nextPurpleTime
|
||||
local canChooseOrange = not self.nextOrangeTime
|
||||
local id
|
||||
if canChoosePurple and canChooseOrange then
|
||||
local index = GFunc.getRandomIndex(self.petWeightList)
|
||||
id = self.petList[index]
|
||||
elseif canChoosePurple then
|
||||
local index = GFunc.getRandomIndex(self.noOrangeWeightList)
|
||||
id = self.noOrangeList[index]
|
||||
elseif canChooseOrange then
|
||||
local index = GFunc.getRandomIndex(self.noPurpleWeightList)
|
||||
id = self.noPurpleList[index]
|
||||
else
|
||||
local index = GFunc.getRandomIndex(self.noBothWeightList)
|
||||
id = self.noBothList[index]
|
||||
end
|
||||
|
||||
local config = self.data:getGameFerruleCfg(id)
|
||||
if config.qlt == 3 then
|
||||
self.nextPurpleTime = time + GFunc.getConstIntValue("act_valentine_purple")
|
||||
elseif config.qlt == 4 then
|
||||
self.nextOrangeTime = time + GFunc.getConstIntValue("act_valentine_orange")
|
||||
end
|
||||
return id
|
||||
end
|
||||
|
||||
function ActGameComp:doFly()
|
||||
self.quanShuiHuaVfx:setActive(false)
|
||||
|
||||
self:showTipsLine(true, false)
|
||||
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_SUMMER_THROW)
|
||||
local uiMap = self:getUIMap()
|
||||
local spineStartNode = uiMap["act_game_comp.game_node.node_spine_start"]
|
||||
local startPos = spineStartNode:getAnchoredPosition()
|
||||
local endPos = {x = startPos.x, y = startPos.y + 500}
|
||||
local time = ANI_TIME[3] - DIE_TIME
|
||||
|
||||
local captureIndex, capturePos = self:calCapturePet()
|
||||
if capturePos then
|
||||
endPos = capturePos
|
||||
time = ANI_TIME[captureIndex] - DIE_TIME
|
||||
end
|
||||
|
||||
-- 计算路径
|
||||
local biasValue = math.floor((startPos.y / 2) * MOVE_LINE_PARAMS)-- 贝塞尔曲线参数
|
||||
local controlPosition = BF.Vector3(((startPos.x - endPos.y / 2) - biasValue) / 4, (startPos.y + endPos.y) / 2, 0) -- 位移控制曲线
|
||||
local path = {endPos, controlPosition, endPos}
|
||||
|
||||
if self.aniSeq then
|
||||
self.aniSeq:Kill()
|
||||
self.aniSeq = nil
|
||||
end
|
||||
|
||||
local spineQuan = uiMap["act_game_comp.game_node.spine_yingzi.spine_youyongquan"]
|
||||
local spineYingzi = uiMap["act_game_comp.game_node.spine_yingzi"]
|
||||
local x, y = spineStartNode:fastGetAnchoredPosition()
|
||||
spineYingzi:setAnchoredPosition(x, y)
|
||||
|
||||
self.parentUI:disableUITouch()
|
||||
self.aniSeq = spineQuan:createBindTweenSequence()
|
||||
local aniName = captureIndex and ANI_NAME[captureIndex] or "out02"
|
||||
spineQuan:playAnim(aniName, false, true, false)
|
||||
spineYingzi:playAnim(aniName, false, true, false)
|
||||
self.aniSeq:Append(spineYingzi:getTransform():DOLocalPath(path, time, CS.DG.Tweening.PathType.CubicBezier, CS.DG.Tweening.PathMode.TopDown2D))
|
||||
-- self.aniSeq:Join(spineQuan:getTransform():DOLocalPath(path, 1, CS.DG.Tweening.PathType.CubicBezier, CS.DG.Tweening.PathMode.TopDown2D))
|
||||
self.aniSeq:InsertCallback(time - 0.1, function()
|
||||
local order = self.parentUI._baseRootCanvas.sortingOrder
|
||||
local addOrder = YONGQUAN_ORDER[1] - 10
|
||||
if captureIndex then
|
||||
addOrder = 20 + (captureIndex - 1) * 5 - 5
|
||||
end
|
||||
self.quanShuiHuaVfx:setActive(true)
|
||||
self.quanShuiHuaVfx:play()
|
||||
self.quanShuiHuaVfx:setSortingOrder(order + addOrder)
|
||||
end)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
if captureIndex then
|
||||
local objs = self.petSpineObjs[captureIndex]
|
||||
if objs then
|
||||
if objs.node.moveSeq then
|
||||
objs.node.moveSeq:Kill()
|
||||
objs.node.moveSeq = nil
|
||||
end
|
||||
end
|
||||
if objs.randomId then
|
||||
table.insert(self.captureIds, objs.randomId)
|
||||
end
|
||||
self:showAddScore(objs)
|
||||
self:setYongquanOrder(nil, captureIndex)
|
||||
else
|
||||
self:setYongquanOrder(YONGQUAN_ORDER[1])
|
||||
end
|
||||
end)
|
||||
|
||||
self.aniSeq:AppendInterval(DIE_TIME)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.parentUI:enableUITouch()
|
||||
if self.aniSeq then
|
||||
self.aniSeq:Kill()
|
||||
self.aniSeq = nil
|
||||
end
|
||||
local x, y = spineStartNode:fastGetAnchoredPosition()
|
||||
spineYingzi:setAnchoredPosition(x, y)
|
||||
spineQuan:playAnim("idle01", true, true)
|
||||
spineYingzi:playAnim("idle01", true, true)
|
||||
self:setYongquanOrder(YONGQUAN_ORDER[1])
|
||||
|
||||
if captureIndex then
|
||||
local objs = self.petSpineObjs[captureIndex]
|
||||
if objs then
|
||||
self:changePet(objs)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:calCapturePet()
|
||||
local capture_w = GFunc.getConstIntValue("act_valentine_road") / 2
|
||||
|
||||
local captureIndex
|
||||
local capturePos
|
||||
for index, objs in ipairs(self.petSpineObjs) do
|
||||
local time = ANI_TIME[index] - DIE_TIME
|
||||
local direct = objs.direct
|
||||
local futureX = 0
|
||||
|
||||
local x, y = objs.node:fastGetAnchoredPosition()
|
||||
if direct == -1 then -- 向左
|
||||
futureX = x + objs.speed * time
|
||||
else
|
||||
futureX = x - objs.speed * time
|
||||
end
|
||||
|
||||
if futureX <= capture_w and futureX >= -capture_w then
|
||||
captureIndex = index
|
||||
capturePos = {x = futureX, y = y}
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return captureIndex, capturePos
|
||||
end
|
||||
|
||||
function ActGameComp:setYongquanOrder(addOrder, index)
|
||||
local uiMap = self:getUIMap()
|
||||
local spineYingzi = uiMap["act_game_comp.game_node.spine_yingzi"]
|
||||
local uiHelper = spineYingzi:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_BASE_SORTING_ORDER_HELPER)
|
||||
local order = self.parentUI._baseRootCanvas.sortingOrder
|
||||
if index then
|
||||
addOrder = 20 + (6 - index) * 5 - 1 -- 比宠物低1个order
|
||||
end
|
||||
addOrder = addOrder or 1
|
||||
if uiHelper then
|
||||
uiHelper:SetSortingOrder(order + addOrder)
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:showAddScore(objs, hide)
|
||||
local uiMap = self:getUIMap()
|
||||
local node = uiMap["act_game_comp.tips_score_node"]
|
||||
if hide then
|
||||
node:setVisible(false)
|
||||
return
|
||||
end
|
||||
|
||||
local txNum = uiMap["act_game_comp.tips_score_node.tx_add_score"]
|
||||
local imgIcon = uiMap["act_game_comp.tips_score_node.img_icon"]
|
||||
if objs and objs.randomId then
|
||||
txNum:setText("+" .. self.data:getGameFerruleCfg(objs.randomId).point)
|
||||
end
|
||||
GFunc.centerImgAndTx(imgIcon, txNum, 5)
|
||||
local x, y = objs.node:fastGetAnchoredPosition()
|
||||
node:setAnchoredPosition(x - 50, y + 50)
|
||||
if node.showSeq then
|
||||
node.showSeq:Kill()
|
||||
node.showSeq = nil
|
||||
end
|
||||
node.showSeq = node:createBindTweenSequence()
|
||||
node.showSeq:AppendCallback(function()
|
||||
node:setVisible(false)
|
||||
end)
|
||||
node.showSeq:Append(node:getTransform():DOScale(1, 0.3))
|
||||
node.showSeq:AppendInterval(0.2)
|
||||
node.showSeq:Append(node:getTransform():DOScale(0, 0.3))
|
||||
node.showSeq:AppendCallback(function()
|
||||
node:setVisible(false)
|
||||
if node.showSeq then
|
||||
node.showSeq:Kill()
|
||||
node.showSeq = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:showTipsLine(show, showArrow)
|
||||
local uiMap = self:getUIMap()
|
||||
uiMap["act_game_comp.tips_node"]:setVisible(show)
|
||||
uiMap["act_game_comp.tips_node.spine"]:setVisible(showArrow == true)
|
||||
end
|
||||
|
||||
function ActGameComp:showScoreFly(show)
|
||||
local uiMap = self:getUIMap()
|
||||
local node = uiMap["act_game_comp.fly_node"]
|
||||
if not show then
|
||||
node:setActive(false)
|
||||
return
|
||||
end
|
||||
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.UI_GET_PTS)
|
||||
|
||||
if not self.imgFlys then
|
||||
self.imgFlys = {}
|
||||
for i = 1, 5 do
|
||||
self.imgFlys[i] = uiMap["act_game_comp.fly_node.img_fly_" .. i]
|
||||
self.imgFlys[i]:setVisible(false)
|
||||
end
|
||||
end
|
||||
|
||||
local startObj = uiMap["act_game_comp.tips_score_node.img_icon"]
|
||||
local targetObj = uiMap["act_game_comp.main_node.img_score"]
|
||||
local endPos = GFunc.getTargetAnchoredPosition(targetObj, node)
|
||||
local startPos = GFunc.getTargetAnchoredPosition(startObj, node)
|
||||
endPos.y = endPos.y + 300
|
||||
|
||||
node:setActive(true)
|
||||
local count = #self.imgFlys
|
||||
for index, flyImg in ipairs(self.imgFlys) do
|
||||
|
||||
local posX, posY = GFunc.randomPos(index, startPos)
|
||||
GFunc.imgDropAndFly(flyImg, {x = posX, y = posY}, endPos, function()
|
||||
count = count - 1
|
||||
if count <= 0 then
|
||||
node:setActive(false)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
return ActGameComp
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d00734d675b924464bccdf5e9cdaa897
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
501
lua/app/ui/activity/common/comp/act_game_fish_comp.lua
Normal file
501
lua/app/ui/activity/common/comp/act_game_fish_comp.lua
Normal file
@ -0,0 +1,501 @@
|
||||
local ActGameComp = class("ActGameComp", LuaComponent)
|
||||
|
||||
local TARGET_CELL = "app/ui/activity/common/cell/target_cell"
|
||||
|
||||
local TARGET_CELL_WIDTH = 100
|
||||
|
||||
local SCROLL_DEFAULT_INFO = {
|
||||
width = 589,
|
||||
posX = 64.5,
|
||||
smallThanScreen = 720 - 589
|
||||
}
|
||||
|
||||
local MAX_FILL_AMOUNT = 0.1694444
|
||||
local ANGLE = 30.5
|
||||
local MAX_RANGE = ANGLE * 2
|
||||
local MAX_ANGLE = BF.Vector3(0, 0, 30.5)
|
||||
local MIN_ANGLE = BF.Vector3(0, 0, -30.5)
|
||||
local TIME = GFunc.getConstValue("act_newnew_spd")
|
||||
|
||||
function ActGameComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
uiMap["act_game_comp.img_preview"]:addClickListener(function()
|
||||
self.parentUI:showGamePreviewUI()
|
||||
end)
|
||||
|
||||
uiMap["act_game_comp.main_node.img_start"]:addClickListener(function()
|
||||
self:clickStart()
|
||||
end, GConst.CLICK_SOUND.NONE)
|
||||
|
||||
uiMap["act_game_comp.settlement_node"]:addClickListener(function()
|
||||
uiMap["act_game_comp.settlement_node"]:setActive(false)
|
||||
self:hideGameNode()
|
||||
self:showScoreFly(true)
|
||||
end)
|
||||
|
||||
uiMap["act_game_comp.main_node.img_score.img_help"]:addClickListener(function()
|
||||
self.parentUI:showGamePreviewUI()
|
||||
end)
|
||||
|
||||
self.timeNode = uiMap["act_game_comp.game_node.tx_time"]
|
||||
self:onClose()
|
||||
|
||||
uiMap["act_game_comp.settlement_node.bg.tx_title"]:setText(I18N:getGlobalText(I18N.GlobalConst.PAUSE_DESC_12))
|
||||
local settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
settlementNode:setActive(false)
|
||||
|
||||
self.isPlaying = false
|
||||
self.captureIds = {}
|
||||
self.angleRange = {}
|
||||
|
||||
self.scrollrect = uiMap["act_game_comp.main_node.scroll_rect"]
|
||||
self.rewardScoreImg = uiMap["act_game_comp.main_node.img_score"]
|
||||
self.spineHezi = uiMap["act_game_comp.spine_node.spine_hezi"]
|
||||
self.spineHezi:playAnim("idle", true, false, false)
|
||||
|
||||
self.spineYugan = uiMap["act_game_comp.spine_node.spine_yugan"]
|
||||
self.spineYugan:playAnim("idle", true, false, false)
|
||||
self.imgYu = uiMap["act_game_comp.spine_node.yu_node.img_yu"]
|
||||
self.imgYu:setVisible(false)
|
||||
|
||||
self.startTx = uiMap["act_game_comp.main_node.img_start.tx_desc"]
|
||||
self.startTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_26))
|
||||
self.arrowNode = uiMap["act_game_comp.game_node.arrow_node"]
|
||||
self.imgLeft = uiMap["act_game_comp.game_node.bg.img_left"]
|
||||
self.imgRight = uiMap["act_game_comp.game_node.bg.img_right"]
|
||||
self.imgHl = uiMap["act_game_comp.game_node.bg.img_hl"]
|
||||
|
||||
self.scrollRectContent = uiMap["act_game_comp.main_node.scroll_rect.viewport.content"]
|
||||
self.rewardSliderBg = uiMap["act_game_comp.main_node.scroll_rect.viewport.content.slider_bg"]
|
||||
self.rewardSlider = uiMap["act_game_comp.main_node.scroll_rect.viewport.content.slider_bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
|
||||
self:showFailTips(false)
|
||||
self:hideGameNode()
|
||||
self:showScoreFly(false)
|
||||
end
|
||||
|
||||
function ActGameComp:onClose()
|
||||
if self.showGameNodeSeq then
|
||||
self.showGameNodeSeq:Kill()
|
||||
self.showGameNodeSeq = nil
|
||||
end
|
||||
|
||||
if self.startPreSeq then
|
||||
self.startPreSeq:Kill()
|
||||
self.startPreSeq = nil
|
||||
end
|
||||
|
||||
if self.arrowSeq then
|
||||
self.arrowSeq:Kill()
|
||||
self.arrowSeq = nil
|
||||
end
|
||||
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
|
||||
if self.scoreFlySeq then
|
||||
self.scoreFlySeq:Kill()
|
||||
self.scoreFlySeq = nil
|
||||
end
|
||||
|
||||
self.isPlaying = false
|
||||
self.timeAni = false
|
||||
self.timeNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = false
|
||||
self.timeNode:setLocalScale(1, 1, 1)
|
||||
self.captureIds = {}
|
||||
end
|
||||
|
||||
function ActGameComp:setParentUI(parentUI, dataKey)
|
||||
self.parentUI = parentUI
|
||||
self.dataKey = dataKey
|
||||
self.data = DataManager[dataKey]
|
||||
self.targetCfgs = self.data:getGameTargetCfgList()
|
||||
|
||||
local screenW, screenH = GFunc.getUIExpandScreenSize()
|
||||
local count = math.max(#self.targetCfgs, 0)
|
||||
local bestW = TARGET_CELL_WIDTH * count
|
||||
local maxW = screenW - SCROLL_DEFAULT_INFO.smallThanScreen
|
||||
local w = math.max(math.min(bestW, maxW), SCROLL_DEFAULT_INFO.width)
|
||||
self.rewardScoreImg:setAnchoredPositionX(SCROLL_DEFAULT_INFO.posX - w / 2 - 50)
|
||||
self.scrollrect:setSizeDeltaX(w)
|
||||
end
|
||||
|
||||
function ActGameComp:refresh(parentUI, dataKey)
|
||||
self.parentUI = self.parentUI or parentUI
|
||||
self.dataKey = dataKey
|
||||
self.data = DataManager[dataKey]
|
||||
self.targetCfgs = self.data:getGameTargetCfgList()
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
uiMap["act_game_comp.main_node.img_score.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_16))
|
||||
uiMap["act_game_comp.img_preview.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_11))
|
||||
self:refreshStepRewardScrollrect()
|
||||
end
|
||||
|
||||
function ActGameComp:refreshStepRewardScrollrect()
|
||||
local uiMap = self:getUIMap()
|
||||
uiMap["act_game_comp.main_node.img_score.tx_num"]:setText(self.data:getGameTotalScore())
|
||||
uiMap["act_game_comp.main_node.tx_desc"]:setText(self.data:getGameTodayLimitScoreStr())
|
||||
|
||||
local totalTimes = self.data:getGameTotalScore()
|
||||
self.rewardSliderBg:setSizeDeltaX(TARGET_CELL_WIDTH * #self.targetCfgs)
|
||||
self.rewardSlider.value = GFunc.getUnevenSliderValue(self.data:getGameTargetList(), totalTimes, 0.5)
|
||||
|
||||
if self.stepScrollrect then
|
||||
self.stepScrollrect:updateAllCell()
|
||||
-- self.stepScrollrect:moveToIndex(self.data:getGameMinIdx())
|
||||
return
|
||||
end
|
||||
|
||||
self.stepScrollrect = uiMap["act_game_comp.main_node.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.stepScrollrect:addInitCallback(function()
|
||||
return TARGET_CELL
|
||||
end)
|
||||
self.stepScrollrect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.parentUI, self.dataKey, self.targetCfgs[index], function()
|
||||
self:onClickTarget(self.targetCfgs[index])
|
||||
end)
|
||||
end)
|
||||
self.stepScrollrect:clearCells()
|
||||
self.stepScrollrect:refillCells(#self.targetCfgs, nil, self.data:getGameMinIdx())
|
||||
end
|
||||
|
||||
function ActGameComp:onClickTarget(id)
|
||||
self.parentUI:reqActivityGameTarget(id)
|
||||
end
|
||||
|
||||
function ActGameComp:clickStart()
|
||||
if not self.data:getIsOpen() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ADVENTURE_CLOSED))
|
||||
return
|
||||
end
|
||||
|
||||
if self.isSettlement then
|
||||
return
|
||||
end
|
||||
|
||||
if self.startPreSeq then
|
||||
return
|
||||
end
|
||||
|
||||
self.captured = false
|
||||
if self.isPlaying then -- 起吊
|
||||
if self.arrowSeq then
|
||||
self.arrowSeq:Kill()
|
||||
self.arrowSeq = nil
|
||||
end
|
||||
|
||||
local angle = self.arrowNode:getTransform().localEulerAngles.z
|
||||
if angle > ANGLE then
|
||||
angle = angle - 360
|
||||
end
|
||||
|
||||
if angle <= self.angleRange[1] and angle >= self.angleRange[2] then
|
||||
self.captured = true
|
||||
end
|
||||
|
||||
self:exitGame()
|
||||
else -- 开始
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_AUGUST_SHUAIGAN)
|
||||
self.imgYu:setVisible(false)
|
||||
self.startPreSeq = self.spineYugan:createBindTweenSequence()
|
||||
self.startPreSeq:AppendCallback(function()
|
||||
self.startTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_8))
|
||||
self.spineYugan:playAnimComplete("shake", false, false, function()
|
||||
self.spineYugan:playAnim("idle_water", true, false, false)
|
||||
end)
|
||||
end)
|
||||
|
||||
self.startPreSeq:InsertCallback(3.167 + (math.random() * 0.5) - 0.5, function()
|
||||
if self.startPreSeq then
|
||||
self.startPreSeq:Kill()
|
||||
self.startPreSeq = nil
|
||||
end
|
||||
self:startGame()
|
||||
end)
|
||||
|
||||
BIReport:postActIceGame(BIReport.ACT_AUGUST_OPT_TYPE.START_GAME)
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:showGameNode()
|
||||
local uiMap = self:getUIMap()
|
||||
local gameNode = uiMap["act_game_comp.game_node"]
|
||||
local aniNode = uiMap["act_game_comp.game_node.ani_node"]
|
||||
gameNode:setVisible(true)
|
||||
if self.showGameNodeSeq then
|
||||
self.showGameNodeSeq:Kill()
|
||||
self.showGameNodeSeq = nil
|
||||
end
|
||||
|
||||
self.showGameNodeSeq = aniNode:createBindTweenSequence()
|
||||
aniNode:setVisible(false)
|
||||
self.showGameNodeSeq:Append(aniNode:getTransform():DOScale(1.2, 0.3))
|
||||
self.showGameNodeSeq:Append(aniNode:getTransform():DOScale(1.0, 0.15))
|
||||
self.startTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_8))
|
||||
end
|
||||
|
||||
function ActGameComp:hideGameNode()
|
||||
if self.showGameNodeSeq then
|
||||
self.showGameNodeSeq:Kill()
|
||||
self.showGameNodeSeq = nil
|
||||
end
|
||||
|
||||
local uiMap = self:getUIMap()
|
||||
local gameNode = uiMap["act_game_comp.game_node"]
|
||||
gameNode:setVisible(false)
|
||||
self.startTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_LANTERN_DESC_26))
|
||||
end
|
||||
|
||||
function ActGameComp:startGame()
|
||||
local newInfo, index = self:getRandomFish()
|
||||
local qlt, artString, aniName = newInfo.qlt, newInfo.art[index], newInfo.aniName
|
||||
if not artString then -- 容错
|
||||
self.isPlaying = false
|
||||
return
|
||||
end
|
||||
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_AUGUST_YAOGOU)
|
||||
self.imgYu:setSprite(GConst.ATLAS_PATH.UI_ACT_NEW_NEW, artString)
|
||||
self.imgYu:setVisible(false)
|
||||
self.spineYugan:playAnimComplete(aniName, false, false, function()
|
||||
end, true, 0.33, function()
|
||||
self:showGameNode()
|
||||
self.endGameTime = Time:getServerTime() + self.data:getGameTime()
|
||||
self.timeNode:setText(self.data:getGameTime())
|
||||
self.isPlaying = true
|
||||
self.captureIds = {}
|
||||
self.captureIds = newInfo
|
||||
newInfo.curIndex = index -- 缓存一下
|
||||
|
||||
local randomAngle = (math.random(newInfo.weight[1], newInfo.weight[2]) / 100) * MAX_RANGE
|
||||
local startAngle = math.min(ANGLE - math.random(0, MAX_RANGE) + randomAngle, ANGLE)
|
||||
self.angleRange[1] = startAngle
|
||||
self.angleRange[2] = startAngle - randomAngle
|
||||
self.imgLeft:setVisible(startAngle == ANGLE)
|
||||
self.imgRight:setVisible(self.angleRange[2] == -ANGLE)
|
||||
self.imgHl:setEulerAngles(0, 0, startAngle)
|
||||
self.imgHl:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE).fillAmount = MAX_FILL_AMOUNT * randomAngle / MAX_RANGE
|
||||
|
||||
if self.arrowSeq then
|
||||
self.arrowSeq:Kill()
|
||||
self.arrowSeq = nil
|
||||
end
|
||||
self.arrowSeq = self.arrowNode:createBindTweenSequence()
|
||||
self.arrowNode:setEulerAngles(0, 0, ANGLE)
|
||||
self.arrowSeq:Append(self.arrowNode:getTransform():DOLocalRotate(MIN_ANGLE, TIME):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
self.arrowSeq:Append(self.arrowNode:getTransform():DOLocalRotate(MAX_ANGLE, TIME):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
self.arrowSeq:SetLoops(-1)
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:exitGame(overTime)
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_AUGUST_YAOGOU)
|
||||
|
||||
if self.startPreSeq then
|
||||
self.startPreSeq:Kill()
|
||||
self.startPreSeq = nil
|
||||
end
|
||||
|
||||
if self.arrowSeq then
|
||||
self.arrowSeq:Kill()
|
||||
self.arrowSeq = nil
|
||||
end
|
||||
|
||||
self.isPlaying = false
|
||||
|
||||
if self.captured then
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_AUGUST_QIGAN_1)
|
||||
else
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_AUGUST_QIGAN_2)
|
||||
end
|
||||
|
||||
self.isSettlement = true
|
||||
self.imgYu:setVisible(self.captured)
|
||||
self.spineYugan:playAnimComplete("harvest", false, false, function()
|
||||
self.spineYugan:playAnim("idle", true, false, false)
|
||||
self.imgYu:setVisible(false)
|
||||
end, false, 1.419, function()
|
||||
self.imgYu:setVisible(false)
|
||||
if self.captured then -- 抓到了
|
||||
local score = self.captureIds.point or 0
|
||||
self.parentUI:reqActivityGameDo(score)
|
||||
else
|
||||
self:showFailTips(true, overTime)
|
||||
end
|
||||
end)
|
||||
|
||||
self:hideGameNode()
|
||||
end
|
||||
|
||||
function ActGameComp:showFailTips(show, overTime)
|
||||
local uiMap = self:getUIMap()
|
||||
if overTime then
|
||||
uiMap["act_game_comp.main_node.img_tips.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_14))
|
||||
else
|
||||
uiMap["act_game_comp.main_node.img_tips.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_11))
|
||||
end
|
||||
local tipsNode = uiMap["act_game_comp.main_node.img_tips"]
|
||||
tipsNode:setVisible(show)
|
||||
if not show then
|
||||
return
|
||||
end
|
||||
local settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
settlementNode:setActive(false)
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
|
||||
tipsNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP).alpha = 1
|
||||
self.settlementNodeSeq = tipsNode:createBindTweenSequence()
|
||||
self.settlementNodeSeq:Append(tipsNode:getTransform():DOScale(1.05, 0.15))
|
||||
self.settlementNodeSeq:Append(tipsNode:getTransform():DOScale(1, 0.2))
|
||||
self.settlementNodeSeq:AppendInterval(0.5)
|
||||
self.settlementNodeSeq:Append(tipsNode:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP):DOFade(0, 0.2))
|
||||
self.settlementNodeSeq:AppendCallback(function()
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
self.isSettlement = false
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:settlementGame()
|
||||
self:refreshStepRewardScrollrect()
|
||||
self:refreshSettlement()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.UI_GET_PTS)
|
||||
|
||||
self.isSettlement = false
|
||||
local uiMap = self:getUIMap()
|
||||
local settlementNode = uiMap["act_game_comp.settlement_node"]
|
||||
settlementNode:setActive(true)
|
||||
local tipsNode = uiMap["act_game_comp.main_node.img_tips"]
|
||||
tipsNode:setVisible(false)
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
|
||||
self.settlementNodeSeq = settlementNode:createBindTweenSequence()
|
||||
self.settlementNodeSeq:Append(settlementNode:getTransform():DOScale(1.05, 0.15))
|
||||
self.settlementNodeSeq:Append(settlementNode:getTransform():DOScale(1, 0.2))
|
||||
self.settlementNodeSeq:AppendCallback(function()
|
||||
if self.settlementNodeSeq then
|
||||
self.settlementNodeSeq:Kill()
|
||||
self.settlementNodeSeq = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:updateTime()
|
||||
if self.isPlaying then
|
||||
local remainTime = self.endGameTime - Time:getServerTime()
|
||||
local str = 0
|
||||
if remainTime <= 0 then
|
||||
self:exitGame(true)
|
||||
else
|
||||
str = remainTime
|
||||
end
|
||||
|
||||
if remainTime <= 3 then
|
||||
str = "<color=#FF534B>" .. str .. "</color>"
|
||||
if not self.timeAni then
|
||||
self.timeNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = true
|
||||
self.timeNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR):Play("ui_act_summer_time", -1, 0)
|
||||
end
|
||||
self.timeAni = true
|
||||
end
|
||||
|
||||
self.timeNode:setText(str)
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:refreshSettlement()
|
||||
local newInfo = self.captureIds
|
||||
local index = newInfo.curIndex
|
||||
local qlt, artString, aniName = newInfo.qlt, newInfo.art[index], newInfo.aniName
|
||||
local uiMap = self:getUIMap()
|
||||
uiMap["act_game_comp.settlement_node.bg.img_fish"]:setSprite(GConst.ATLAS_PATH.UI_ACT_NEW_NEW, artString)
|
||||
uiMap["act_game_comp.spine_node.img_fish"]:setSprite(GConst.ATLAS_PATH.UI_ACT_NEW_NEW, artString)
|
||||
uiMap["act_game_comp.settlement_node.bg.tx_score_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_9))
|
||||
uiMap["act_game_comp.settlement_node.bg.tx_fish"]:setText(self.data:getFishName(qlt, index))
|
||||
local txScore = uiMap["act_game_comp.settlement_node.bg.tx_score"]
|
||||
local todayScore = self.data:getGameTodayScore()
|
||||
local full = (todayScore - (newInfo.point or 0)) >= self.data:getGameTodayLimitScore()
|
||||
if full then
|
||||
txScore:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWNEW_DESC_15))
|
||||
else
|
||||
txScore:setText(self.parentUI:getFishScoreDesc() .. "+" .. (newInfo.point or 0))
|
||||
end
|
||||
end
|
||||
|
||||
function ActGameComp:showScoreFly(show)
|
||||
local uiMap = self:getUIMap()
|
||||
local node = uiMap["act_game_comp.spine_node.img_fish"]
|
||||
node:setVisible(false)
|
||||
if not show then
|
||||
return
|
||||
end
|
||||
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_AUGUST_XIANGZI)
|
||||
|
||||
if self.scoreFlySeq then
|
||||
self.scoreFlySeq:Kill()
|
||||
self.scoreFlySeq = nil
|
||||
end
|
||||
|
||||
self.spineHezi:playAnimComplete("open", false, false, function()
|
||||
self.spineHezi:playAnim("idle", true, false, false)
|
||||
end)
|
||||
local startPos = GFunc.getTargetAnchoredPosition(uiMap["act_game_comp.settlement_node.bg.img_fish"], self.spineHezi)
|
||||
self.scoreFlySeq = node:createBindTweenSequence()
|
||||
node:setVisible(true)
|
||||
node:setAnchoredPositionY(startPos.y)
|
||||
self.scoreFlySeq:Append(node:getTransform():DOScale(0, 0.8):SetEase(CS.DG.Tweening.Ease.InCubic))
|
||||
self.scoreFlySeq:Join(node:getTransform():DOAnchorPosY(0, 0.8):SetEase(CS.DG.Tweening.Ease.InCubic))
|
||||
self.scoreFlySeq:AppendCallback(function()
|
||||
if self.scoreFlySeq then
|
||||
self.scoreFlySeq:Kill()
|
||||
self.scoreFlySeq = nil
|
||||
end
|
||||
node:setVisible(false)
|
||||
end)
|
||||
end
|
||||
|
||||
function ActGameComp:getRandomFish()
|
||||
if not self.randomFishInfo then
|
||||
self.randomFishInfo = {}
|
||||
for id, info in pairs(ConfigManager:getConfig("act_active_fish")) do
|
||||
local newInfo = GFunc.getTable(info)
|
||||
if newInfo.qlt == GConst.QLT_TYPE.LEGEND then
|
||||
newInfo.aniName = "attack04"
|
||||
elseif newInfo.qlt == GConst.QLT_TYPE.EPIC then
|
||||
newInfo.aniName = "attack03"
|
||||
elseif newInfo.qlt == GConst.QLT_TYPE.EXCELLENT then
|
||||
newInfo.aniName = "attack02"
|
||||
elseif newInfo.qlt == GConst.QLT_TYPE.RARE then
|
||||
newInfo.aniName = "attack01"
|
||||
else
|
||||
newInfo.aniName = "attack01"
|
||||
end
|
||||
table.insert(self.randomFishInfo, newInfo)
|
||||
end
|
||||
end
|
||||
|
||||
local newInfo = self.randomFishInfo[math.random(#self.randomFishInfo)]
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("随机得品质")
|
||||
Logger.printTable(newInfo)
|
||||
end
|
||||
local index = math.random(#newInfo.art)
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("随机的index" .. index .. " " .. newInfo.art[index])
|
||||
end
|
||||
return newInfo, index
|
||||
end
|
||||
|
||||
return ActGameComp
|
||||
10
lua/app/ui/activity/common/comp/act_game_fish_comp.lua.meta
Normal file
10
lua/app/ui/activity/common/comp/act_game_fish_comp.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c5bd32ab612945979d1ea44f8adac72
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
66
lua/app/ui/activity/common/comp/act_gift_comp_v1.lua
Normal file
66
lua/app/ui/activity/common/comp/act_gift_comp_v1.lua
Normal file
@ -0,0 +1,66 @@
|
||||
local ActGiftComp = class("ActGiftComp", LuaComponent)
|
||||
|
||||
local GIFT_CELL = "app/ui/activity/common/cell/gift_cell"
|
||||
|
||||
function ActGiftComp:onClose()
|
||||
if self.scrollRect then
|
||||
self.scrollRect:moveToIndex(1)
|
||||
end
|
||||
if self.cellList then
|
||||
for k, cell in pairs(self.cellList) do
|
||||
if cell and cell.onClose then
|
||||
cell:onClose()
|
||||
end
|
||||
end
|
||||
self.cellList = {}
|
||||
end
|
||||
end
|
||||
|
||||
function ActGiftComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.txTime = uiMap["act_gift_comp.time_node.tx_time"]
|
||||
self.scrollrect = uiMap["act_gift_comp.scrollrect"]
|
||||
|
||||
self.cellList = {}
|
||||
end
|
||||
|
||||
function ActGiftComp:updateTime()
|
||||
if not self.data then
|
||||
return
|
||||
end
|
||||
self.txTime:setText(I18N:getGlobalText(I18N.GlobalConst.TIME_END_DESC_1, Time:formatNumTimeStr(self.data:getNormalRemainTime())))
|
||||
end
|
||||
|
||||
function ActGiftComp:refresh(parentUI, dataKey)
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.dataKey = dataKey or self.dataKey
|
||||
self.data = DataManager[self.dataKey]
|
||||
|
||||
self.ids = DataManager.ActGiftData:getGiftIdsSort(self.data:getActId())
|
||||
if not self.scrollRect then
|
||||
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return GIFT_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
self.cellList[index] = cell
|
||||
cell:refresh(self.parentUI, self.dataKey, self.ids[index])
|
||||
end)
|
||||
end
|
||||
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
|
||||
self.scrollRect:refillCells(#self.ids)
|
||||
elseif self.scrollRect:getTotalCount() ~= #self.ids then
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.ids)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
|
||||
self.data:setGiftRp()
|
||||
end
|
||||
|
||||
function ActGiftComp:setActive(active)
|
||||
self.baseObject:setActive(active)
|
||||
end
|
||||
|
||||
return ActGiftComp
|
||||
10
lua/app/ui/activity/common/comp/act_gift_comp_v1.lua.meta
Normal file
10
lua/app/ui/activity/common/comp/act_gift_comp_v1.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c4307e914c7f457fa545efa58ed455f
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
90
lua/app/ui/activity/common/comp/act_task_comp_v1.lua
Normal file
90
lua/app/ui/activity/common/comp/act_task_comp_v1.lua
Normal file
@ -0,0 +1,90 @@
|
||||
local ActTaskComp = class("ActTaskComp", LuaComponent)
|
||||
|
||||
local TASK_CELL = "app/ui/activity/common/cell/task_cell"
|
||||
|
||||
function ActTaskComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.txTitle = uiMap["act_task_comp.top.tx_title"]
|
||||
self.txTips = uiMap["act_task_comp.top.tx_tips"]
|
||||
self.bgTitle = uiMap["act_task_comp.bg_top"]
|
||||
self.scrollrect = uiMap["act_task_comp.scrollrect"]
|
||||
self.btnDays = {}
|
||||
for i = 1, 5 do
|
||||
table.insert(self.btnDays, uiMap["act_task_comp.tag.btn_day_" .. i])
|
||||
end
|
||||
|
||||
self:bind(DataManager.ActTaskData, "isDirty", function()
|
||||
if self.parentUI == nil or self.data == nil then
|
||||
return
|
||||
end
|
||||
self:refresh()
|
||||
end)
|
||||
end
|
||||
|
||||
function ActTaskComp:refresh(parentUI, dataKey)
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.dataKey = dataKey or self.dataKey
|
||||
self.data = DataManager[self.dataKey]
|
||||
|
||||
if self.selectDay == nil then
|
||||
self.selectDay = self.data:getTaskDefaultSelectDay()
|
||||
end
|
||||
|
||||
self.txTitle:setText(self.parentUI:getTaskTitle())
|
||||
self.txTips:setText(self.parentUI:getTaskTips())
|
||||
self.bgTitle:setTexture(self.parentUI:getTaskBanner())
|
||||
if self.parentUI.getTaskBannerSize then
|
||||
self.bgTitle:setSizeDelta(self.parentUI:getTaskBannerSize())
|
||||
end
|
||||
|
||||
self.ids = self.data:getTaskIdsByDay(self.selectDay)
|
||||
if not self.scrollRect then
|
||||
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return TASK_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.parentUI, self.dataKey, self.ids[index])
|
||||
end)
|
||||
end
|
||||
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
|
||||
self.scrollRect:refillCells(#self.ids)
|
||||
elseif self.scrollRect:getTotalCount() ~= #self.ids then
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(#self.ids)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
|
||||
local curDay = self.data:getActivityDay()
|
||||
for i, item in ipairs(self.btnDays) do
|
||||
item:initPrefabHelper()
|
||||
local map = item:genAllChildren()
|
||||
local txDay = map["tx_day"]
|
||||
local imgLock = map["img_lock"]
|
||||
local imgFinish = map["img_finish"]
|
||||
local imgSelect = map["img_select"]
|
||||
|
||||
txDay:setText(i)
|
||||
imgLock:setActive(i > curDay)
|
||||
imgFinish:setActive(false)
|
||||
imgSelect:setActive(self.selectDay == i)
|
||||
|
||||
if self.data:hasTaskRp(i) then
|
||||
item:addRedPoint(30, 30, 0.9)
|
||||
else
|
||||
item:removeRedPoint()
|
||||
end
|
||||
|
||||
item:addClickListener(function()
|
||||
if i > curDay then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.PRISON_DESC_6, i - curDay))
|
||||
return
|
||||
end
|
||||
self.selectDay = i
|
||||
self:refresh()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
return ActTaskComp
|
||||
10
lua/app/ui/activity/common/comp/act_task_comp_v1.lua.meta
Normal file
10
lua/app/ui/activity/common/comp/act_task_comp_v1.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c22d240f12624e198affa365f854585
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
667
lua/app/ui/activity/common/comp/act_turntable_comp_v1.lua
Normal file
667
lua/app/ui/activity/common/comp/act_turntable_comp_v1.lua
Normal file
@ -0,0 +1,667 @@
|
||||
local TurntableComp = class("TurntableComp", LuaComponent)
|
||||
local TURNTABLE_CELL = "app/ui/activity/common/cell/turntable_cell"
|
||||
local TURNTABLE_TARGET_CELL = "app/ui/activity/common/cell/turntable_target_cell"
|
||||
|
||||
local TARGET_CELL_WIDTH = 100
|
||||
local TURNTABLE_REWARD_MAX_COUNT = 12
|
||||
|
||||
function TurntableComp:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.btnProb = uiMap["act_turntable_comp.top.btn_prob"]
|
||||
self.txProb = uiMap["act_turntable_comp.top.btn_prob.tx_prob"]
|
||||
self.bg = uiMap["act_turntable_comp.turntable_node.bg"]
|
||||
|
||||
self.turntableCells = {}
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
table.insert(self.turntableCells, CellManager:addCellComp(uiMap["act_turntable_comp.turntable_node.turntable_cell_" .. i], TURNTABLE_CELL))
|
||||
end
|
||||
self.arrow = uiMap["act_turntable_comp.turntable_node.arrow"]
|
||||
self.txBigCount = uiMap["act_turntable_comp.turntable_node.big.tx_big_count"]
|
||||
self.txBigDesc = uiMap["act_turntable_comp.turntable_node.big.tx_big_desc"]
|
||||
|
||||
self.quickTg = uiMap["act_turntable_comp.quick_tg"]
|
||||
self.quickTgFlag = uiMap["act_turntable_comp.quick_tg.select_flag"]
|
||||
self.quickTgTx = uiMap["act_turntable_comp.quick_tg.text"]
|
||||
|
||||
self.scrollrect = uiMap["act_turntable_comp.reward_node.scrollrect"]
|
||||
self.scrollRectContent = uiMap["act_turntable_comp.reward_node.scrollrect.viewport.content"]
|
||||
self.progressNode = uiMap["act_turntable_comp.reward_node.scrollrect.viewport.content.progress"]
|
||||
self.imgProg = uiMap["act_turntable_comp.reward_node.scrollrect.viewport.content.progress.img_prog"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.targetBigTargetCell = uiMap["act_turntable_comp.reward_node.target_cell"]:addLuaComponent(TURNTABLE_TARGET_CELL)
|
||||
|
||||
self.totalTimesTx = uiMap["act_turntable_comp.reward_node.left_node.total_times_tx"]
|
||||
self.totalTimesDescTx = uiMap["act_turntable_comp.reward_node.left_node.desc_tx"]
|
||||
|
||||
self.btnAd = uiMap["act_turntable_comp.btn_ad"]
|
||||
self.imgAd = uiMap["act_turntable_comp.btn_ad.img_ad"]
|
||||
self.txAdTime = uiMap["act_turntable_comp.btn_ad.tx_time"]
|
||||
|
||||
self.btnCosts = {}
|
||||
self.txCostDescs = {}
|
||||
self.imgCosts = {}
|
||||
self.txCosts = {}
|
||||
for k, count in pairs(GConst.ActivityConst.TURNTABLE_TIMES) do
|
||||
self.btnCosts[count] = uiMap["act_turntable_comp.btn_cost_" .. count]
|
||||
self.txCostDescs[count] = uiMap["act_turntable_comp.btn_cost_" .. count .. ".tx_desc"]
|
||||
self.imgCosts[count] = uiMap["act_turntable_comp.btn_cost_" .. count .. ".cost.img_icon"]
|
||||
self.txCosts[count] = uiMap["act_turntable_comp.btn_cost_" .. count .. ".cost.tx_num"]
|
||||
end
|
||||
self.txTips = uiMap["act_turntable_comp.tx_tips"]
|
||||
|
||||
self.txProb:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_FORCE_3))
|
||||
self.quickTgTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_TURNTABLE_DESC_5))
|
||||
|
||||
self.arrowAngle = 0 -- 箭头默认角度
|
||||
self.arrow:setEulerAnglesZ(self.arrowAngle)
|
||||
|
||||
self.btnAd:addClickListener(function()
|
||||
SDKManager:showFullScreenAds(self.parentUI:getTurntableAdType(), function ()
|
||||
self:onClickAdBtn()
|
||||
end)
|
||||
end)
|
||||
self.btnProb:addClickListener(function()
|
||||
-- 特殊处理
|
||||
if self.dataKey == "ActMagicData" then
|
||||
ModuleManager.ActMagicManager:showProbUI()
|
||||
return
|
||||
end
|
||||
|
||||
local cfgs = self.data:getTurntableCfgList()
|
||||
local params = {}
|
||||
params.rewardList = {}
|
||||
params.rewardWeight = {}
|
||||
for i,v in ipairs(cfgs) do
|
||||
table.insert(params.rewardList, v.reward)
|
||||
table.insert(params.rewardWeight, v.weight)
|
||||
end
|
||||
params.descStr = I18N:getGlobalText(I18N.GlobalConst.ACT_ICE_DESC_7, self.data:getTurntableBigRewardCount())
|
||||
ModuleManager.ActivityManager:showTurntablePreviewUI(params)
|
||||
end)
|
||||
self.quickTg:addClickListener(function()
|
||||
local isQuick = self.data:getSkipAniFlag()
|
||||
self.data:setSkipAniFlag(not isQuick)
|
||||
self.quickTgFlag:setVisible(not isQuick)
|
||||
end)
|
||||
for count, btn in pairs(self.btnCosts) do
|
||||
btn:addClickListener(function()
|
||||
self:onClickCostBtn(count)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:updateTime()
|
||||
if not self.data then
|
||||
return
|
||||
end
|
||||
if self.data:hasTurntableAd() then
|
||||
self.btnAd:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_blue_7")
|
||||
self.btnAd:setTouchEnable(true)
|
||||
local total = self.data:getTurntableAdDailyCount()
|
||||
local remain = total - self.data:getAdWatchCount()
|
||||
self.txAdTime:setText("(" .. remain .. "/" .. total .. ")")
|
||||
else
|
||||
self.btnAd:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_gray_7")
|
||||
self.btnAd:setTouchEnable(false)
|
||||
self.txAdTime:setText(Time:formatNumTimeStr(Time:getTodaySurplusTime()))
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:refresh(parentUI, dataKey)
|
||||
self.parentUI = parentUI
|
||||
self.dataKey = dataKey
|
||||
self.data = DataManager[self.dataKey]
|
||||
|
||||
-- 转盘奖励
|
||||
local ids = table.keys(self.data:getTurntableCfg())
|
||||
table.sort(ids)
|
||||
for i, cell in ipairs(self.turntableCells) do
|
||||
if ids and ids[i] then
|
||||
cell:getBaseObject():setLocalEulerAnglesZ((i - 1) * -30)
|
||||
cell:getBaseObject():setActive(true)
|
||||
cell:refresh(self.parentUI, self.dataKey, ids[i])
|
||||
else
|
||||
cell:getBaseObject():setActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 大奖剩余次数
|
||||
local num = self.data:getTurntableBigCount()
|
||||
local maxCount = self.data:getTurntableBigRewardCount()
|
||||
local curNum = math.floor(num % maxCount)
|
||||
self.txBigCount:setText(curNum .. "/" .. maxCount)
|
||||
self.txBigDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_ICE_DESC_5, self.data:getTurntableBigRewardCount()))
|
||||
self.txTips:setText(self.parentUI:getTurntableCostStr())
|
||||
|
||||
-- 特殊处理
|
||||
if self.dataKey == "ActMagicData" then
|
||||
self.txBigCount:setText(DataManager.ActMagicData:getTurntableBigCount() .. "/" .. DataManager.ActMagicData:getTurntableBigRewardCount())
|
||||
self.txBigDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_MAGIC_DESC_6))
|
||||
end
|
||||
|
||||
-- 快速抽取
|
||||
local showQuickTg = self.data:getCanChooseSkip()
|
||||
local isQuick = self.data:getSkipAniFlag()
|
||||
self.quickTg:setActive(showQuickTg)
|
||||
self.quickTgFlag:setVisible(isQuick)
|
||||
|
||||
-- 阶段奖励
|
||||
self.targetCfgs = self.data:getTurntableTargetCfgList()
|
||||
local showCount = #self.targetCfgs - 1 -- 列表不显示最后一个大奖
|
||||
if not self.scrollRect then
|
||||
self.scrollRect = self.scrollrect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRect:addInitCallback(function()
|
||||
return TURNTABLE_TARGET_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
if index > self.targetMaxShowIdx then
|
||||
self.targetMaxShowIdx = index
|
||||
self:refreshTargetBigReward()
|
||||
elseif index < self.targetMaxShowIdx - self.targetCellNum then
|
||||
self.targetMaxShowIdx = index + self.targetCellNum
|
||||
self:refreshTargetBigReward()
|
||||
elseif index == self.targetMaxShowIdx then
|
||||
-- 展示最后一个大奖处理
|
||||
self.targetMaxShowIdx = index + 1
|
||||
self:refreshTargetBigReward()
|
||||
end
|
||||
cell:refresh(self.parentUI, self.dataKey, self.targetCfgs[index], function()
|
||||
self.parentUI:reqActivityTarget(self.targetCfgs[index].id)
|
||||
end)
|
||||
end)
|
||||
self.targetMaxShowIdx = 1
|
||||
self.targetCellNum = math.ceil(self.scrollrect:getSizeDeltaX() / self.scrollRect:getCellWidth())
|
||||
end
|
||||
if self.scrollRect:getTotalCount() == nil or self.scrollRect:getTotalCount() <= 0 then
|
||||
self.scrollRect:refillCells(showCount)
|
||||
elseif self.scrollRect:getTotalCount() ~= showCount then
|
||||
self.scrollRect:clearCells()
|
||||
self.scrollRect:refillCells(showCount)
|
||||
else
|
||||
self.scrollRect:updateAllCell()
|
||||
end
|
||||
self.scrollRect:moveToIndex(self.data:getTurntableMinIdx())
|
||||
self:refreshTargetBigReward()
|
||||
|
||||
local totalTimes = self.data:getTurntableTotalCount()
|
||||
self.progressNode:setSizeDeltaX(TARGET_CELL_WIDTH * showCount + (TARGET_CELL_WIDTH / 2))
|
||||
self.scrollRectContent:setSizeDeltaX(TARGET_CELL_WIDTH * showCount + (TARGET_CELL_WIDTH / 2))
|
||||
self.imgProg.value = GFunc.getUnevenSliderValue(self.data:getTurntableTargetList(), totalTimes, 0.5)
|
||||
|
||||
-- 总次数
|
||||
self.totalTimesTx:setText(totalTimes)
|
||||
self.totalTimesDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_MAGIC_DESC_7))
|
||||
|
||||
-- 付费按钮
|
||||
local cost = self.data:getTurntableCost()
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
local hasNum = DataManager.BagData.ItemData:getItemNumById(costId)
|
||||
for count, btn in pairs(self.btnCosts) do
|
||||
self.imgCosts[count]:setSprite(GFunc.getIconRes(costId))
|
||||
|
||||
local showCount = count
|
||||
if not GFunc.checkCost(costId, costNum * count, false) then
|
||||
-- 不足
|
||||
if count > 1 then
|
||||
local hasCount = math.floor(hasNum / costNum)
|
||||
if hasCount >= 1 then
|
||||
showCount = math.min(hasCount, 10)
|
||||
else
|
||||
showCount = 10
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.txCostDescs[count]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_MAGIC_DESC_8, showCount))
|
||||
self.txCosts[count]:setText(costNum * showCount)
|
||||
GFunc.centerImgAndTx(self.imgCosts[count], self.txCosts[count], 0)
|
||||
end
|
||||
|
||||
local dailyAdCount = DataManager.ActivityData:getTurntableAdCount(self.data:getActId())
|
||||
self.btnAd:setActive(dailyAdCount and dailyAdCount > 0 and self.dataKey ~= "ActNewbieData")
|
||||
if self.data:hasTurntableAd() then
|
||||
self.btnAd:addRedPoint(40, 35, 0.9)
|
||||
GFunc.setAdsSprite(self.imgAd)
|
||||
else
|
||||
self.btnAd:removeRedPoint()
|
||||
GFunc.setAdsSprite(self.imgAd, true)
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:refreshTargetBigReward()
|
||||
local nextLevel, cfg = self.data:getTurntableNextRewardId(self.targetMaxShowIdx)
|
||||
self.bigShowIdx = nextLevel
|
||||
|
||||
self.targetBigTargetCell:refresh(self.parentUI, self.dataKey, cfg, function()
|
||||
self.parentUI:reqActivityTarget(self.targetCfgs[self.bigShowIdx].id)
|
||||
end)
|
||||
self.targetBigTargetCell:setRewardScale(0.9)
|
||||
end
|
||||
|
||||
-- 2-10连抽最终抽数(道具为0,1时为10,2-10时为对应值,大于10时为10)
|
||||
function TurntableComp:calculateRealCostCount(count, cost)
|
||||
if count == 1 then
|
||||
return count
|
||||
else
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
local hasNum = DataManager.BagData.ItemData:getItemNumById(costId)
|
||||
if hasNum < costNum or hasNum >= costNum * 10 then
|
||||
return 10
|
||||
else
|
||||
return hasNum // costNum
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:onClickAdBtn()
|
||||
if self.isPlayAni then
|
||||
return
|
||||
end
|
||||
|
||||
if self.data:hasTurntableAd() then
|
||||
self.parentUI:reqActivityPlay(0, true)
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:onClickCostBtn(count)
|
||||
if self.isPlayAni then
|
||||
return
|
||||
end
|
||||
|
||||
local cost = self.data:getTurntableCost()
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
|
||||
local realCount = self:calculateRealCostCount(count, cost)
|
||||
|
||||
if GFunc.checkCost(costId, costNum * realCount, true) then
|
||||
self.parentUI:reqActivityPlay(realCount, false)
|
||||
else
|
||||
-- 跳转活动礼包
|
||||
self.parentUI:refreshPage(self.parentUI.ActConst.BOTTOM_PAGE.GIFT)
|
||||
end
|
||||
end
|
||||
|
||||
-- 播放表现
|
||||
function TurntableComp:playAni(params)
|
||||
local ids = params.ids
|
||||
local rewards = params.rewards
|
||||
local formatIds = {} -- 唯一并排序后的ids
|
||||
local tmpIdMap = {}
|
||||
for _, id in ipairs(ids) do
|
||||
id = id % 100
|
||||
if not tmpIdMap[id] then
|
||||
table.insert(formatIds, id)
|
||||
tmpIdMap[id] = true
|
||||
end
|
||||
end
|
||||
table.sort(formatIds)
|
||||
|
||||
local showBigCallback = nil
|
||||
local bigRewards = nil
|
||||
for i, id in ipairs(ids) do
|
||||
if self.data:isTurntableBigReward(id) then
|
||||
rewards[i].isBig = true
|
||||
|
||||
if bigRewards == nil then
|
||||
bigRewards = {}
|
||||
end
|
||||
table.insert(bigRewards, rewards[i])
|
||||
|
||||
showBigCallback = function()
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.ACT_BIG_REWARD_SHOW)
|
||||
end
|
||||
end
|
||||
end
|
||||
if bigRewards and #bigRewards > 0 then
|
||||
self.data:saveBigRewards(bigRewards)
|
||||
end
|
||||
|
||||
self.parentUI:disableUITouchSelf()
|
||||
|
||||
-- 处理动画
|
||||
self.isPlayAni = true
|
||||
self.isShowState = false
|
||||
if self.aniSeq then
|
||||
self.aniSeq:Kill()
|
||||
self.aniSeq = nil
|
||||
end
|
||||
self.aniSeq = self.baseObject:createBindTweenSequence()
|
||||
|
||||
-- 每次播放归一化表现
|
||||
self.rewardSelectMap = table.clearOrCreate(self.rewardSelectMap) -- 记录select播放的状态
|
||||
self.rewardForceSelectMap = table.clearOrCreate(self.rewardForceSelectMap) -- 记录需要强制播放select
|
||||
self.rewardShowMap = table.clearOrCreate(self.rewardShowMap) -- 记录show播放的状态
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self.rewardSelectMap[i] = false
|
||||
self.rewardForceSelectMap[i] = false
|
||||
self.rewardShowMap[i] = false
|
||||
end
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
|
||||
local isQuick = self.data:getSkipAniFlag()
|
||||
if isQuick then -- 快速
|
||||
-- 转为show阶段
|
||||
self.aniSeq:AppendCallback(function()
|
||||
-- 标记show部分
|
||||
self.isShowState = true
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self.rewardShowMap[targetIndex] = true
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function() -- 播放item表现
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_LIGHTING)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardItemHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.75)
|
||||
-- 最终展示
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.isPlayAni = false
|
||||
self.isShowState = false
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
-- 如果还处于本界面页签
|
||||
if self.parentUI and not self.parentUI:isClosed() then
|
||||
self:onPlayAnimEnd(rewards, showBigCallback)
|
||||
end
|
||||
end)
|
||||
else -- 正常
|
||||
-- 开始旋转
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_RT)
|
||||
end)
|
||||
local totalRotateAngle = 720
|
||||
local moveSpeed = 720
|
||||
local moveTime = 1
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
local targetAngle = (targetIndex - 1) * -30 -- arrow的目标角度
|
||||
local rotateAngle = targetAngle - self.arrowAngle
|
||||
self.arrowAngle = targetAngle
|
||||
|
||||
if i == 1 then -- 首个旋转x圈后,闪烁2次
|
||||
totalRotateAngle = rotateAngle - 1440
|
||||
moveTime = -totalRotateAngle / (moveSpeed * 1.5)
|
||||
self.aniSeq:Append(self.arrow:getTransform():DOLocalRotate(BF.Vector3(0, 0, totalRotateAngle), moveTime, CS.DG.Tweening.RotateMode.WorldAxisAdd):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
-- 闪烁2次
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end)
|
||||
-- 标记常显
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.rewardForceSelectMap[targetIndex] = true -- 标记需要强制播放这个index对应cell的select特效
|
||||
end)
|
||||
elseif i == 2 or i == 3 then -- 第x个旋转1圈后,短暂停留
|
||||
totalRotateAngle = rotateAngle - 360
|
||||
moveTime = -totalRotateAngle / moveSpeed * 1.25
|
||||
self.aniSeq:Append(self.arrow:getTransform():DOLocalRotate(BF.Vector3(0, 0, totalRotateAngle), moveTime, CS.DG.Tweening.RotateMode.WorldAxisAdd):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
end)
|
||||
-- 短暂停留
|
||||
self.aniSeq:AppendInterval(0.25)
|
||||
-- 标记常显
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.rewardForceSelectMap[targetIndex] = true -- 标记需要强制播放这个index对应cell的select特效
|
||||
end)
|
||||
else -- 后面的不停留直接转完
|
||||
totalRotateAngle = rotateAngle
|
||||
moveTime = -totalRotateAngle / moveSpeed * 1.5
|
||||
self.aniSeq:Append(self.arrow:getTransform():DOLocalRotate(BF.Vector3(0, 0, totalRotateAngle), moveTime, CS.DG.Tweening.RotateMode.WorldAxisAdd):SetEase(CS.DG.Tweening.Ease.Linear))
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
end)
|
||||
-- 标记常显
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.rewardForceSelectMap[targetIndex] = true -- 标记需要强制播放这个index对应cell的select特效
|
||||
end)
|
||||
end
|
||||
end
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_RT)
|
||||
end)
|
||||
-- 转为show阶段
|
||||
self.aniSeq:AppendCallback(function()
|
||||
-- 标记show部分
|
||||
self.isShowState = true
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self.rewardShowMap[targetIndex] = true
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function() -- 播放item表现
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_LIGHTING)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardItemHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.75)
|
||||
-- 最终展示
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.isPlayAni = false
|
||||
self.isShowState = false
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
-- 如果还处于本界面页签
|
||||
if self.parentUI and not self.parentUI:isClosed() then
|
||||
self:onPlayAnimEnd(rewards, showBigCallback)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- 计算当前指针指向 并调整select特效
|
||||
function TurntableComp:updateAni()
|
||||
if self.isPlayAni and not self.isShowState then
|
||||
local angle = self.arrow:getEulerAnglesZ()
|
||||
-- 归一化到[0,360)
|
||||
while angle < 0 do
|
||||
angle = angle + 360
|
||||
end
|
||||
while angle >= 360 do
|
||||
angle = angle - 360
|
||||
end
|
||||
-- 根据angle计算出index
|
||||
local index = 1
|
||||
if 345 <= angle and angle < 360 then
|
||||
index = 1
|
||||
elseif 315 <= angle and angle < 345 then
|
||||
index = 2
|
||||
elseif 285 <= angle and angle < 315 then
|
||||
index = 3
|
||||
elseif 255 <= angle and angle < 285 then
|
||||
index = 4
|
||||
elseif 225 <= angle and angle < 255 then
|
||||
index = 5
|
||||
elseif 195 <= angle and angle < 225 then
|
||||
index = 6
|
||||
elseif 165 <= angle and angle < 195 then
|
||||
index = 7
|
||||
elseif 135 <= angle and angle < 165 then
|
||||
index = 8
|
||||
elseif 105 <= angle and angle < 135 then
|
||||
index = 9
|
||||
elseif 75 <= angle and angle < 105 then
|
||||
index = 10
|
||||
elseif 45 <= angle and angle < 75 then
|
||||
index = 11
|
||||
elseif 15 <= angle and angle < 45 then
|
||||
index = 12
|
||||
elseif 0 <= angle and angle < 15 then
|
||||
index = 1
|
||||
end
|
||||
-- 根据阶段和当前指向index,处理表现
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
if i == index then -- 当前指向该index
|
||||
if not self.rewardSelectMap[i] then -- 目前没有点亮
|
||||
if not self.rewardShowMap[i] then -- 不是处于show阶段
|
||||
self.rewardSelectMap[i] = true
|
||||
self:setRewardSelectHighlight(i, true)
|
||||
self:setRewardSelectFlowHighlight(i, true) -- 拖影
|
||||
end
|
||||
end
|
||||
else -- 未指向该index
|
||||
if self.rewardSelectMap[i] then -- 目前已经点亮
|
||||
if not self.rewardForceSelectMap[i] then -- 不是强制点亮的
|
||||
self.rewardSelectMap[i] = false
|
||||
self:setRewardSelectHighlight(i, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 选中效果
|
||||
function TurntableComp:setRewardSelectHighlight(index, active)
|
||||
if not self.parentUI then
|
||||
return
|
||||
end
|
||||
self.turntableCells[index]:setSelectEffect(active, self.parentUI:getUIOrder())
|
||||
end
|
||||
|
||||
function TurntableComp:disableAllRewardSelectHighlight()
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self:setRewardSelectHighlight(i, false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 选中拖影效果
|
||||
function TurntableComp:setRewardSelectFlowHighlight(index, active)
|
||||
if not self.parentUI then
|
||||
return
|
||||
end
|
||||
self.turntableCells[index]:setSelectFlowEffect(active, self.parentUI:getUIOrder())
|
||||
end
|
||||
|
||||
function TurntableComp:disableAllRewardSelectFlowHighlight()
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self:setRewardSelectFlowHighlight(i, false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 选中的最终道具表现效果
|
||||
function TurntableComp:setRewardItemHighlight(index, active)
|
||||
if not self.parentUI then
|
||||
return
|
||||
end
|
||||
self.turntableCells[index]:setItemEffect(active, self.parentUI:getUIOrder())
|
||||
end
|
||||
|
||||
function TurntableComp:disableAllRewardItemHighlight()
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self:setRewardItemHighlight(i, false)
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:onPlayAnimEnd(rewards, callback)
|
||||
GFunc.showRewardBox(rewards, {noMerge = true}, callback)
|
||||
self.parentUI:enableUITouchSelf()
|
||||
end
|
||||
|
||||
function TurntableComp:onClose()
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_LIGHTING)
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_RT)
|
||||
if self.aniSeq then
|
||||
self.aniSeq:Kill()
|
||||
self.aniSeq = nil
|
||||
end
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
self.isPlayAni = false
|
||||
self.isShowState = false
|
||||
|
||||
self.arrowAngle = 0 -- 箭头默认角度
|
||||
self.arrow:setEulerAnglesZ(self.arrowAngle)
|
||||
end
|
||||
|
||||
return TurntableComp
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a734bca778aa4465e94dc230f7b551da
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
637
lua/app/ui/activity/common/comp/act_turntable_comp_v2.lua
Normal file
637
lua/app/ui/activity/common/comp/act_turntable_comp_v2.lua
Normal file
@ -0,0 +1,637 @@
|
||||
local TurntableComp = class("TurntableComp", LuaComponent)
|
||||
local TURNTABLE_CELL = "app/ui/activity/common/cell/turntable_cell_v2"
|
||||
|
||||
local TURNTABLE_REWARD_MAX_COUNT = 9
|
||||
|
||||
function TurntableComp:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.btnProb = uiMap["act_turntable_comp.content.btn_prob"]
|
||||
self.txProb = uiMap["act_turntable_comp.content.btn_prob.tx_prob"]
|
||||
|
||||
self.turntableCells = {}
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
table.insert(self.turntableCells, CellManager:addCellComp(uiMap["act_turntable_comp.content.turntable_node.items.turntable_cell_" .. i], TURNTABLE_CELL))
|
||||
end
|
||||
self.arrow = uiMap["act_turntable_comp.content.turntable_node.center.arrow"]
|
||||
|
||||
self.quickTg = uiMap["act_turntable_comp.content.quick_tg"]
|
||||
self.quickTgFlag = uiMap["act_turntable_comp.content.quick_tg.select_flag"]
|
||||
self.quickTgTx = uiMap["act_turntable_comp.content.quick_tg.text"]
|
||||
|
||||
self.btnCosts = {}
|
||||
self.txCostDescs = {}
|
||||
self.imgCosts = {}
|
||||
self.txCosts = {}
|
||||
for k, count in pairs(GConst.ActivityConst.TURNTABLE_TIMES) do
|
||||
self.btnCosts[count] = uiMap["act_turntable_comp.content.btn_cost_" .. count]
|
||||
self.txCostDescs[count] = uiMap["act_turntable_comp.content.btn_cost_" .. count .. ".tx_desc"]
|
||||
self.imgCosts[count] = uiMap["act_turntable_comp.content.btn_cost_" .. count .. ".cost.img_icon"]
|
||||
self.txCosts[count] = uiMap["act_turntable_comp.content.btn_cost_" .. count .. ".cost.tx_num"]
|
||||
end
|
||||
self.txTips = uiMap["act_turntable_comp.content.tx_tips"]
|
||||
self.txTips2 = uiMap["act_turntable_comp.scrollview.viewport.content.tx_tips"]
|
||||
self.tipsContent = uiMap["act_turntable_comp.scrollview.viewport.content"]
|
||||
|
||||
self.btnGift = uiMap["act_turntable_comp.content.btn_gift"]
|
||||
self.txGiftTime = uiMap["act_turntable_comp.content.btn_gift.tx_time"]
|
||||
self.btnReset = uiMap["act_turntable_comp.content.btn_reset"]
|
||||
self.imgResetCost = uiMap["act_turntable_comp.content.btn_reset.cost.img_cost"]
|
||||
self.txResetCost = uiMap["act_turntable_comp.content.btn_reset.cost.tx_cost"]
|
||||
|
||||
self.effectAnim1 = uiMap["act_turntable_comp.vfx_b10_ui_zhixu_zp_b03"]
|
||||
self.effectAnim2 = uiMap["act_turntable_comp.content.turntable_node.vfx_b10_ui_zhixu_zp_b05"]
|
||||
|
||||
self.txProb:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_FORCE_3))
|
||||
self.quickTgTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_TURNTABLE_DESC_5))
|
||||
self.txTips2:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_NEWBIE_ST_RATE_6))
|
||||
local meshProComp = self.txTips2:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
|
||||
meshProComp:ForceMeshUpdate()
|
||||
self.tipsContent:setSizeDeltaY(meshProComp.renderedHeight + 10)
|
||||
self.tipsContent:setAnchoredPosition(0, 0)
|
||||
|
||||
self.effectAnim1:setActive(false)
|
||||
self.effectAnim2:setActive(false)
|
||||
|
||||
self.arrowAngle = 0 -- 箭头默认角度
|
||||
self.arrow:setEulerAnglesZ(self.arrowAngle)
|
||||
|
||||
self.btnReset:addClickListener(function()
|
||||
local cost = self.data:getTurntableResetCost()
|
||||
if not GFunc.checkCost(GFunc.getRewardId(cost), GFunc.getRewardNum(cost), true) then
|
||||
return
|
||||
end
|
||||
local params = {}
|
||||
params.content = I18N:getGlobalText(I18N.GlobalConst.MALL_DESC_13)
|
||||
params.boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL
|
||||
params.showToday = GConst.MESSAGE_BOX_SHOW_TODAY.ACT_TURNTABLE_RESET
|
||||
params.okFunc = function()
|
||||
self.parentUI:reqTurntableReset()
|
||||
end
|
||||
GFunc.showMessageBox(params)
|
||||
end)
|
||||
self.btnGift:addClickListener(function()
|
||||
self.parentUI:showGiftUI()
|
||||
end)
|
||||
self.btnProb:addClickListener(function()
|
||||
ModuleManager.ActNewbieStManager:showProbUI()
|
||||
end)
|
||||
self.quickTg:addClickListener(function()
|
||||
local isQuick = self.data:getSkipAniFlag()
|
||||
self.data:setSkipAniFlag(not isQuick)
|
||||
self.quickTgFlag:setVisible(not isQuick)
|
||||
end)
|
||||
for count, btn in pairs(self.btnCosts) do
|
||||
btn:addClickListener(function()
|
||||
self:onClickCostBtn(count)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:updateTime()
|
||||
if self.data == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if self.giftEndTime == nil then
|
||||
if self.triggerGiftIds and #self.triggerGiftIds > 0 then
|
||||
self.giftEndTime = DataManager.ActGiftData:getTriggerGiftEndTime(self.data:getActId(), self.triggerGiftIds[1])
|
||||
end
|
||||
elseif self.giftEndTime < Time:getServerTime() then
|
||||
self:updateTriggerGift()
|
||||
if self.triggerGiftIds and #self.triggerGiftIds > 0 then
|
||||
self.giftEndTime = DataManager.ActGiftData:getTriggerGiftEndTime(self.data:getActId(), self.triggerGiftIds[1])
|
||||
end
|
||||
end
|
||||
|
||||
if self.giftEndTime then
|
||||
local remain = self.giftEndTime - Time:getServerTime()
|
||||
if remain > 0 then
|
||||
self.txGiftTime:setText(Time:formatNumTime(remain))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新触发礼包
|
||||
function TurntableComp:updateTriggerGift()
|
||||
self.triggerGiftIds = DataManager.ActGiftData:getTriggerGiftIdsByActId(self.data:getActId())
|
||||
self.btnGift:setActive(self.triggerGiftIds and #self.triggerGiftIds > 0)
|
||||
end
|
||||
|
||||
-- 刷新转盘
|
||||
function TurntableComp:updateTurntable()
|
||||
self.turntableIds = self.data:getTurntableIds()
|
||||
self.angleMap = self.data:getTurntableAngleMap()
|
||||
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("更新转盘数据")
|
||||
Logger.printTable(self.turntableIds)
|
||||
Logger.printTable(self.angleMap)
|
||||
end
|
||||
|
||||
local count = #self.turntableIds
|
||||
local flag = false
|
||||
for i, cell in ipairs(self.turntableCells) do
|
||||
if i <= count then
|
||||
local id = self.turntableIds[i]
|
||||
if not self.data:isTurntableBigReward(id) then
|
||||
flag = not flag
|
||||
end
|
||||
cell:getBaseObject():setActive(true)
|
||||
cell:refresh(self.parentUI, self.dataKey, id, self.angleMap[i], flag)
|
||||
else
|
||||
cell:getBaseObject():setActive(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:refresh(parentUI, dataKey)
|
||||
self.parentUI = parentUI or self.parentUI
|
||||
self.dataKey = dataKey or self.dataKey
|
||||
self.data = DataManager[self.dataKey]
|
||||
|
||||
if self.turntableIds == nil or self.angleMap == nil then
|
||||
self:updateTurntable()
|
||||
end
|
||||
self:updateTriggerGift()
|
||||
|
||||
self.txTips:setText(self.parentUI:getTurntableCostStr())
|
||||
|
||||
-- 快速抽取
|
||||
local showQuickTg = self.data:getCanChooseSkip()
|
||||
local isQuick = self.data:getSkipAniFlag()
|
||||
self.quickTg:setActive(showQuickTg)
|
||||
self.quickTgFlag:setVisible(isQuick)
|
||||
|
||||
-- 付费按钮
|
||||
local cost = self.data:getTurntableCost()
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
local hasNum = DataManager.BagData.ItemData:getItemNumById(costId)
|
||||
for count, btn in pairs(self.btnCosts) do
|
||||
self.imgCosts[count]:setSprite(GFunc.getIconRes(costId))
|
||||
|
||||
local showCount = count
|
||||
if not GFunc.checkCost(costId, costNum * count, false) then
|
||||
-- 不足
|
||||
if count > 1 then
|
||||
local hasCount = math.floor(hasNum / costNum)
|
||||
if hasCount >= 1 then
|
||||
showCount = math.min(hasCount, 10)
|
||||
else
|
||||
showCount = 10
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.txCostDescs[count]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_MAGIC_DESC_8, showCount))
|
||||
self.txCosts[count]:setText(costNum * showCount)
|
||||
GFunc.centerImgAndTx(self.imgCosts[count], self.txCosts[count], 0)
|
||||
end
|
||||
|
||||
-- 重置按钮
|
||||
self.btnReset:setActive(self.data:isShowTurntableReset())
|
||||
local cost = self.data:getTurntableResetCost()
|
||||
self.imgResetCost:setSprite(GFunc.getIconRes(GFunc.getRewardId(cost)))
|
||||
self.txResetCost:setText(GFunc.getRewardNum(cost))
|
||||
end
|
||||
|
||||
-- 2-10连抽最终抽数(道具为0,1时为10,2-10时为对应值,大于10时为10)
|
||||
function TurntableComp:calculateRealCostCount(count, cost)
|
||||
if count == 1 then
|
||||
return count
|
||||
else
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
local hasNum = DataManager.BagData.ItemData:getItemNumById(costId)
|
||||
if hasNum < costNum or hasNum >= costNum * 10 then
|
||||
return 10
|
||||
else
|
||||
return hasNum // costNum
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:onClickCostBtn(count)
|
||||
if self.isPlayAni then
|
||||
return
|
||||
end
|
||||
|
||||
local cost = self.data:getTurntableCost()
|
||||
local costId = GFunc.getRewardId(cost)
|
||||
local costNum = GFunc.getRewardNum(cost)
|
||||
|
||||
local realCount = self:calculateRealCostCount(count, cost)
|
||||
|
||||
if GFunc.checkCost(costId, costNum * realCount, true) then
|
||||
self.parentUI:reqActivityPlay(realCount)
|
||||
else
|
||||
-- 跳转活动礼包
|
||||
self.parentUI:refreshPage(self.parentUI.ActConst.BOTTOM_PAGE.GIFT)
|
||||
end
|
||||
end
|
||||
|
||||
-- 播放表现
|
||||
function TurntableComp:playAni(params, showBigCallback)
|
||||
local ids = params.ids
|
||||
local rewards = params.rewards
|
||||
local formatIds = {} -- 唯一并排序后的ids
|
||||
local tmpIdMap = {}
|
||||
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("播放表现")
|
||||
Logger.printTable(ids)
|
||||
Logger.printTable(rewards)
|
||||
Logger.printTable(self.turntableIds)
|
||||
end
|
||||
|
||||
self.nextIds = nil
|
||||
for _, id in ipairs(ids) do
|
||||
if not tmpIdMap[id] then
|
||||
local findIdx = table.indexof(self.turntableIds, id)
|
||||
if findIdx then
|
||||
table.insert(formatIds, findIdx)
|
||||
tmpIdMap[id] = true
|
||||
elseif table.indexof(self.data:getTurntableIds(), id) then
|
||||
-- 抽到下一轮奖励
|
||||
if self.nextIds == nil then
|
||||
self.nextIds = {}
|
||||
end
|
||||
table.insert(self.nextIds, id)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(formatIds)
|
||||
if EDITOR_MODE then
|
||||
Logger.printTable(formatIds)
|
||||
end
|
||||
|
||||
local bigRewards = nil
|
||||
for i, id in ipairs(ids) do
|
||||
if self.data:isTurntableBigReward(id) then
|
||||
rewards[i].isBig = true
|
||||
|
||||
if bigRewards == nil then
|
||||
bigRewards = {}
|
||||
end
|
||||
table.insert(bigRewards, rewards[i])
|
||||
|
||||
showBigCallback = function()
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.ACT_BIG_REWARD_SHOW)
|
||||
end
|
||||
end
|
||||
end
|
||||
if bigRewards and #bigRewards > 0 then
|
||||
self.data:saveBigRewards(bigRewards)
|
||||
end
|
||||
|
||||
self.parentUI:disableUITouchSelf()
|
||||
|
||||
self.effectAnim1:setActive(true)
|
||||
self.effectAnim1:play()
|
||||
self.effectAnim2:setActive(true)
|
||||
self.effectAnim2:play()
|
||||
|
||||
-- 处理动画
|
||||
self.isPlayAni = true
|
||||
self.isShowState = false
|
||||
if self.aniSeq then
|
||||
self.aniSeq:Kill()
|
||||
self.aniSeq = nil
|
||||
end
|
||||
self.aniSeq = self.baseObject:createBindTweenSequence()
|
||||
|
||||
-- 每次播放归一化表现
|
||||
self.rewardSelectMap = table.clearOrCreate(self.rewardSelectMap) -- 记录select播放的状态
|
||||
self.rewardForceSelectMap = table.clearOrCreate(self.rewardForceSelectMap) -- 记录需要强制播放select
|
||||
self.rewardShowMap = table.clearOrCreate(self.rewardShowMap) -- 记录show播放的状态
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self.rewardSelectMap[i] = false
|
||||
self.rewardForceSelectMap[i] = false
|
||||
self.rewardShowMap[i] = false
|
||||
end
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
|
||||
local isQuick = self.data:getSkipAniFlag()
|
||||
if isQuick then -- 快速
|
||||
-- 转为show阶段
|
||||
self.aniSeq:AppendCallback(function()
|
||||
-- 标记show部分
|
||||
self.isShowState = true
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self.rewardShowMap[targetIndex] = true
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function() -- 播放item表现
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_LIGHTING)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardItemHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.75)
|
||||
-- 最终展示
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.isPlayAni = false
|
||||
self.isShowState = false
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
-- 如果还处于本界面页签
|
||||
if self.parentUI and not self.parentUI:isClosed() then
|
||||
self:onPlayAnimEnd(rewards, showBigCallback)
|
||||
end
|
||||
end)
|
||||
else -- 正常
|
||||
-- 开始旋转
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_RT)
|
||||
end)
|
||||
local totalRotateAngle = 720
|
||||
local moveSpeed = 720
|
||||
local moveTime = 1
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
local targetAngle = self.angleMap[targetIndex].angleCenter -- arrow的目标角度
|
||||
local rotateAngle = targetAngle - self.arrowAngle
|
||||
self.arrowAngle = targetAngle
|
||||
|
||||
if i == 1 then -- 首个旋转x圈后,闪烁2次
|
||||
totalRotateAngle = rotateAngle - 1440
|
||||
moveTime = -totalRotateAngle / (moveSpeed * 1.5)
|
||||
self.aniSeq:Append(self.arrow:getTransform():DOLocalRotate(BF.Vector3(0, 0, totalRotateAngle), moveTime, CS.DG.Tweening.RotateMode.WorldAxisAdd):SetEase(CS.DG.Tweening.Ease.InCubic))
|
||||
-- 闪烁2次
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end)
|
||||
-- 标记常显
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.rewardForceSelectMap[targetIndex] = true -- 标记需要强制播放这个index对应cell的select特效
|
||||
end)
|
||||
elseif i == 2 or i == 3 then -- 第x个旋转1圈后,短暂停留
|
||||
totalRotateAngle = rotateAngle - 360
|
||||
moveTime = -totalRotateAngle / moveSpeed * 1.25
|
||||
self.aniSeq:Append(self.arrow:getTransform():DOLocalRotate(BF.Vector3(0, 0, totalRotateAngle), moveTime, CS.DG.Tweening.RotateMode.WorldAxisAdd):SetEase(CS.DG.Tweening.Ease.InCubic))
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
end)
|
||||
-- 短暂停留
|
||||
self.aniSeq:AppendInterval(0.25)
|
||||
-- 标记常显
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.rewardForceSelectMap[targetIndex] = true -- 标记需要强制播放这个index对应cell的select特效
|
||||
end)
|
||||
else -- 后面的不停留直接转完
|
||||
totalRotateAngle = rotateAngle
|
||||
moveTime = -totalRotateAngle / moveSpeed * 1.5
|
||||
self.aniSeq:Append(self.arrow:getTransform():DOLocalRotate(BF.Vector3(0, 0, totalRotateAngle), moveTime, CS.DG.Tweening.RotateMode.WorldAxisAdd):SetEase(CS.DG.Tweening.Ease.InCubic))
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
end)
|
||||
-- 标记常显
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.rewardForceSelectMap[targetIndex] = true -- 标记需要强制播放这个index对应cell的select特效
|
||||
end)
|
||||
end
|
||||
end
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_RT)
|
||||
end)
|
||||
-- 转为show阶段
|
||||
self.aniSeq:AppendCallback(function()
|
||||
-- 标记show部分
|
||||
self.isShowState = true
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self.rewardShowMap[targetIndex] = true
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, false)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function()
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardSelectHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.15)
|
||||
self.aniSeq:AppendCallback(function() -- 播放item表现
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_LIGHTING)
|
||||
for i = 1, #formatIds do
|
||||
local targetIndex = formatIds[i]
|
||||
self:setRewardItemHighlight(targetIndex, true)
|
||||
end
|
||||
end)
|
||||
self.aniSeq:AppendInterval(0.5)
|
||||
-- 最终展示
|
||||
self.aniSeq:AppendCallback(function()
|
||||
self.isPlayAni = false
|
||||
self.isShowState = false
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
-- 如果还处于本界面页签
|
||||
if self.parentUI and not self.parentUI:isClosed() then
|
||||
self:onPlayAnimEnd(rewards, showBigCallback)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- 计算当前指针指向 并调整select特效
|
||||
function TurntableComp:updateAni()
|
||||
if self.isPlayAni and not self.isShowState then
|
||||
local angle = self.arrow:getEulerAnglesZ()
|
||||
-- 归一化到[0,360)
|
||||
while angle < 0 do
|
||||
angle = angle + 360
|
||||
end
|
||||
while angle >= 360 do
|
||||
angle = angle - 360
|
||||
end
|
||||
-- 根据angle计算出index
|
||||
local index = 1
|
||||
for i, angleInfo in ipairs(self.angleMap) do
|
||||
if angle <= angleInfo.angleEnd then
|
||||
index = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- 根据阶段和当前指向index,处理表现
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
if i == index then -- 当前指向该index
|
||||
if not self.rewardSelectMap[i] then -- 目前没有点亮
|
||||
if not self.rewardShowMap[i] then -- 不是处于show阶段
|
||||
self.rewardSelectMap[i] = true
|
||||
self:setRewardSelectHighlight(i, true)
|
||||
self:setRewardSelectFlowHighlight(i, true) -- 拖影
|
||||
end
|
||||
end
|
||||
else -- 未指向该index
|
||||
if self.rewardSelectMap[i] then -- 目前已经点亮
|
||||
if not self.rewardForceSelectMap[i] then -- 不是强制点亮的
|
||||
self.rewardSelectMap[i] = false
|
||||
self:setRewardSelectHighlight(i, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 选中效果
|
||||
function TurntableComp:setRewardSelectHighlight(index, active)
|
||||
if not self.parentUI then
|
||||
return
|
||||
end
|
||||
self.turntableCells[index]:setSelectEffect(active, self.parentUI:getUIOrder())
|
||||
end
|
||||
|
||||
function TurntableComp:disableAllRewardSelectHighlight()
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self:setRewardSelectHighlight(i, false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 选中拖影效果
|
||||
function TurntableComp:setRewardSelectFlowHighlight(index, active)
|
||||
if not self.parentUI then
|
||||
return
|
||||
end
|
||||
self.turntableCells[index]:setSelectFlowEffect(active, self.parentUI:getUIOrder())
|
||||
end
|
||||
|
||||
function TurntableComp:disableAllRewardSelectFlowHighlight()
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self:setRewardSelectFlowHighlight(i, false)
|
||||
end
|
||||
end
|
||||
|
||||
-- 选中的最终道具表现效果
|
||||
function TurntableComp:setRewardItemHighlight(index, active)
|
||||
if not self.parentUI then
|
||||
return
|
||||
end
|
||||
self.turntableCells[index]:setItemEffect(active, self.parentUI:getUIOrder())
|
||||
end
|
||||
|
||||
function TurntableComp:disableAllRewardItemHighlight()
|
||||
for i = 1, TURNTABLE_REWARD_MAX_COUNT do
|
||||
self:setRewardItemHighlight(i, false)
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:onPlayAnimEnd(rewards, callback)
|
||||
self:updateTurntable()
|
||||
|
||||
if self.nextIds and #self.nextIds > 0 then
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("触发新一轮奖励抽取")
|
||||
Logger.printTable(self.nextIds)
|
||||
end
|
||||
self:playAni({ids = self.nextIds, rewards = rewards}, callback)
|
||||
else
|
||||
GFunc.showRewardBox(rewards, {noMerge = true}, callback)
|
||||
self.effectAnim1:setActive(false)
|
||||
self.effectAnim2:setActive(false)
|
||||
self.parentUI:enableUITouchSelf()
|
||||
end
|
||||
end
|
||||
|
||||
function TurntableComp:onClose()
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_LIGHTING)
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_CHOSEN)
|
||||
AudioManager:stopEffect(AudioManager.EFFECT_ID.ACT_ZONGZI_RT)
|
||||
if self.aniSeq then
|
||||
self.aniSeq:Kill()
|
||||
self.aniSeq = nil
|
||||
end
|
||||
self:disableAllRewardSelectHighlight()
|
||||
self:disableAllRewardSelectFlowHighlight()
|
||||
self:disableAllRewardItemHighlight()
|
||||
self.isPlayAni = false
|
||||
self.isShowState = false
|
||||
|
||||
self.arrowAngle = 0 -- 箭头默认角度
|
||||
self.arrow:setEulerAnglesZ(self.arrowAngle)
|
||||
|
||||
self.parentUI = nil
|
||||
self.dataKey = nil
|
||||
self.data = nil
|
||||
self.turntableIds = nil
|
||||
self.angleMap = nil
|
||||
self.nextIds = nil
|
||||
end
|
||||
|
||||
return TurntableComp
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d373cf5142ef247f1a01271bdb20ce9f
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -1,6 +1,11 @@
|
||||
local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell"
|
||||
local ChapterComp = class("ChapterComp", MainCompBaseCell)
|
||||
local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
|
||||
local ChapterCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell"
|
||||
local ChapterComp = class("ChapterComp", ChapterCompBaseCell)
|
||||
|
||||
local UISpineObject = require "app/bf/unity/ui_spine_object"
|
||||
|
||||
-- local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
|
||||
local HERO_SPINE_ASSET_PATH = "assets/arts/spines/characters/%s/%s_skeletondata.asset"
|
||||
local CHAPTER_PATH = "assets/arts/textures/background/main/%s.png"
|
||||
|
||||
local BOX_ICON = {
|
||||
"common_chest_1",
|
||||
@ -64,6 +69,29 @@ function ChapterComp:initChapter()
|
||||
end)
|
||||
|
||||
self.uiMap["chapter.effect_node.ui_spine_obj"]:playAnim("idle", true, false)
|
||||
|
||||
self.chapterBg = self.uiMap["chapter_comp.bg"]
|
||||
self.chapterBg:setAnchoredPositionX(-720)
|
||||
self.bossSmoke = self.uiMap["chapter_comp.boss_smoke"]
|
||||
self.bossSmoke:setAnchoredPositionX(10000)
|
||||
self.smokeNodeTop = self.uiMap["chapter_comp.smoke_node_1"]
|
||||
self.monsterNodeTop = self.uiMap["chapter_comp.monster_node_1"]
|
||||
self.bossNode = self.uiMap["chapter_comp.boss_node"]
|
||||
self.bossNode:setActive(false)
|
||||
self.bossSpine = self.uiMap["chapter_comp.boss_node.boss"]
|
||||
self.smokeNodeDown = self.uiMap["chapter_comp.smoke_node_2"]
|
||||
self.monsterNodeDown = self.uiMap["chapter_comp.monster_node_2"]
|
||||
self.dialogueTx = self.uiMap["chapter_comp.dialogue_node.bg.text"]
|
||||
self.dialogueBg = self.uiMap["chapter_comp.dialogue_node.bg"]
|
||||
self.dialogueNode = self.uiMap["chapter_comp.dialogue_node"]
|
||||
self.dialogueNode:setAnchoredPositionX(0)
|
||||
self.monsterSpineTopPool = {}
|
||||
self.monsterSpineDownPool = {}
|
||||
self.monsterSpineTopList = {}
|
||||
self.monsterSpineDownList = {}
|
||||
-- self.monsterShadowPool = {}
|
||||
self.monsterSmokePool = {}
|
||||
self.startMonsterAction = true
|
||||
end
|
||||
|
||||
function ChapterComp:refresh()
|
||||
@ -88,7 +116,20 @@ function ChapterComp:refreshChapter(force)
|
||||
local chapterInfo = ConfigManager:getConfig("chapter")[chapterId]
|
||||
local chapterI18NInfo = I18N:getConfig("chapter")[chapterId]
|
||||
if chapterInfo then
|
||||
self.chapterImg:setTexture(string.format(CHAPTER_PATH, chapterInfo.icon))
|
||||
local monsterIdList = chapterInfo.monster_id
|
||||
if monsterIdList then
|
||||
local bossId = monsterIdList[1]
|
||||
if bossId then
|
||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
||||
local monsterInfo = monsterCfg[bossId]
|
||||
if monsterInfo then
|
||||
-- self.dialogueBg:setAnchoredPositionY(monsterInfo.blood * monsterInfo.ui/10 + 20)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- main_bg_1
|
||||
-- self.chapterBg:setTexture(string.format(CHAPTER_PATH, chapterInfo.scenes_a)) end
|
||||
self.chapterBg:setTexture(string.format(CHAPTER_PATH, "main_bg_1"))
|
||||
end
|
||||
if chapterI18NInfo then
|
||||
self.chapterNameTx:setText(chapterI18NInfo.name)
|
||||
@ -186,7 +227,485 @@ function ChapterComp:refreshChapter(force)
|
||||
end
|
||||
|
||||
self:refreshFightBtn()
|
||||
self:doBossAction()
|
||||
end
|
||||
self:doChapterMove()
|
||||
self:doMonsterAction()
|
||||
end
|
||||
|
||||
function ChapterComp:onOpen()
|
||||
self.startMonsterAction = true
|
||||
if self.bossNode then
|
||||
self.bossNode:setAnchoredPositionX(0)
|
||||
end
|
||||
-- if self.bossShadow then
|
||||
-- self.bossShadow:setAnchoredPositionX(0)
|
||||
-- end
|
||||
if self.dialogueNode then
|
||||
self.dialogueNode:setAnchoredPositionX(0)
|
||||
end
|
||||
end
|
||||
|
||||
function ChapterComp:onClose()
|
||||
if self.chapterMoveSeq then
|
||||
self.chapterMoveSeq:Kill()
|
||||
self.chapterMoveSeq = nil
|
||||
end
|
||||
if self.chapterMonsterGenerateSeq then
|
||||
self.chapterMonsterGenerateSeq:Kill()
|
||||
self.chapterMonsterGenerateSeq = nil
|
||||
end
|
||||
self.currChapterId = nil
|
||||
self.isTopTurn = nil
|
||||
self.startMonsterAction = false
|
||||
GFunc.killDOTween(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
||||
self.monsterSpineTopPool = {}
|
||||
self.monsterSpineDownPool = {}
|
||||
self.monsterSpineTopList = {}
|
||||
self.monsterSpineDownList = {}
|
||||
-- self.monsterShadowPool = {}
|
||||
self.monsterSmokePool = {}
|
||||
self.monsterNodeTop:removeAllChildren()
|
||||
self.monsterNodeDown:removeAllChildren()
|
||||
-- self.shadowNode:removeAllChildren()
|
||||
self.smokeNodeTop:removeAllChildren()
|
||||
self.smokeNodeDown:removeAllChildren()
|
||||
end
|
||||
|
||||
-- region 动画
|
||||
function ChapterComp:doChapterMove()
|
||||
if self.chapterMoveSeq then
|
||||
return
|
||||
end
|
||||
self.chapterBg:setAnchoredPositionX(-720)
|
||||
self.chapterMoveSeq = self.chapterBg:createBindTweenSequence()
|
||||
local moveTween = self.chapterBg:getTransform():DOAnchorPosX(720, 20):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
self.chapterMoveSeq:Append(moveTween)
|
||||
self.chapterMoveSeq:AppendCallback(function()
|
||||
self.chapterBg:setAnchoredPositionX(-720)
|
||||
end)
|
||||
self.chapterMoveSeq:SetLoops(-1)
|
||||
end
|
||||
|
||||
function ChapterComp:doBossAction()
|
||||
if self.currChapterId == nil then
|
||||
return
|
||||
end
|
||||
local chapterInfo = ConfigManager:getConfig("chapter")[self.currChapterId]
|
||||
if chapterInfo == nil then
|
||||
return
|
||||
end
|
||||
local monsterIdList = chapterInfo.monster_id
|
||||
monsterIdList = {20001, 10001, 10002}
|
||||
if monsterIdList == nil then
|
||||
return
|
||||
end
|
||||
self.chapterMonsterShowList = monsterIdList
|
||||
if self.chapterBossId == nil then -- 还没显示boss模型
|
||||
self.chapterBossId = self.chapterMonsterShowList[1]
|
||||
local chapterBossId = self.chapterBossId
|
||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
||||
local monsterInfo = monsterCfg[self.chapterBossId]
|
||||
if monsterInfo then
|
||||
local modelId = monsterInfo.model_id
|
||||
local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId)
|
||||
self.bossNode:setActive(false)
|
||||
local scale = monsterInfo.ui or 1
|
||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
||||
-- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
||||
-- self.bossShadow:setAnchoredPosition(10000, shadowOffset)
|
||||
self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
||||
self.bossSmoke:setAnchoredPositionX(10000)
|
||||
self.bossSpine:loadAssetAsync(modelId, function()
|
||||
if chapterBossId == self.chapterBossId then
|
||||
self.bossNode:setActive(true)
|
||||
self.bossSpine:setLocalScale(-scale, scale, scale)
|
||||
self.bossSpine:playAnim("move", true, true, true)
|
||||
-- self.bossShadow:setAnchoredPositionX(0)
|
||||
self.bossSmoke:playAnim("idle", true, true, true)
|
||||
self.bossSmoke:setAnchoredPositionX(0)
|
||||
else -- 加载完成后,已经切换到其他boss了
|
||||
self:doChangeBossAction()
|
||||
end
|
||||
end, path)
|
||||
end
|
||||
else
|
||||
local chapterBossId = self.chapterMonsterShowList[1]
|
||||
if self.chapterBossId ~= chapterBossId then
|
||||
self.chapterBossId = chapterBossId
|
||||
self:doChangeBossAction()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 切换boss
|
||||
function ChapterComp:doChangeBossAction()
|
||||
local chapterBossId = self.chapterBossId
|
||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
||||
local monsterInfo = monsterCfg[self.chapterBossId]
|
||||
if monsterInfo then
|
||||
local modelId = monsterInfo.model_id
|
||||
local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId)
|
||||
self.bossNode:setActive(false)
|
||||
local scale = monsterInfo.ui or 1
|
||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
||||
-- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
||||
-- self.bossShadow:setAnchoredPosition(10000, shadowOffset)
|
||||
self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
||||
self.bossSmoke:setAnchoredPositionX(10000)
|
||||
self.bossSpine:loadAssetAsync(modelId, function()
|
||||
if chapterBossId == self.chapterBossId then
|
||||
self.bossNode:setActive(true)
|
||||
self.bossSpine:setLocalScale(-scale, scale, scale)
|
||||
self.bossSpine:playAnim("move", true, true, true)
|
||||
-- self.bossShadow:setAnchoredPositionX(0)
|
||||
self.bossSmoke:playAnim("idle", true, true, true)
|
||||
self.bossSmoke:setAnchoredPositionX(0)
|
||||
else -- 加载完成后,已经切换到其他boss了
|
||||
self:doChangeBossAction()
|
||||
end
|
||||
end, path)
|
||||
end
|
||||
end
|
||||
|
||||
function ChapterComp:doMonsterAction()
|
||||
if self.chapterMonsterGenerateSeq then
|
||||
return
|
||||
end
|
||||
self.chapterMonsterGenerateSeq = DOTweenManager:createSeqWithIntId()
|
||||
local interval = GFunc.getConstValue("chapter_idel_monster_x") / 1000
|
||||
interval = 2
|
||||
self.chapterMonsterGenerateSeq:AppendCallback(function()
|
||||
self:generateChapterMonsters()
|
||||
end)
|
||||
self.chapterMonsterGenerateSeq:AppendInterval(interval)
|
||||
self.chapterMonsterGenerateSeq:SetLoops(-1)
|
||||
end
|
||||
|
||||
function ChapterComp:generateChapterMonsters()
|
||||
local monsterId
|
||||
if #self.chapterMonsterShowList <= 2 then
|
||||
monsterId = self.chapterMonsterShowList[2]
|
||||
else
|
||||
monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)]
|
||||
end
|
||||
if monsterId == nil then
|
||||
return
|
||||
end
|
||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
||||
local monsterInfo = monsterCfg[monsterId]
|
||||
if monsterInfo == nil then
|
||||
return
|
||||
end
|
||||
if self.isTopTurn == nil then
|
||||
self.isTopTurn = math.random(1, 100) > 50
|
||||
end
|
||||
local modelId = monsterInfo.model_id
|
||||
local pool
|
||||
local list
|
||||
local parent
|
||||
local posY
|
||||
if self.isTopTurn then -- 刷上面
|
||||
pool = self.monsterSpineTopPool[modelId]
|
||||
list = self.monsterSpineTopList
|
||||
parent = self.monsterNodeTop
|
||||
posY = math.random(1, 300)
|
||||
else -- 刷下面
|
||||
pool = self.monsterSpineDownPool[modelId]
|
||||
list = self.monsterSpineDownList
|
||||
parent = self.monsterNodeDown
|
||||
posY = -math.random(1, 240)
|
||||
end
|
||||
self.isTopTurn = not self.isTopTurn
|
||||
if pool and #pool > 0 then
|
||||
local spine = table.remove(pool)
|
||||
table.insert(list, spine)
|
||||
spine:setActive(true)
|
||||
self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
||||
else
|
||||
SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine)
|
||||
if not self.startMonsterAction then
|
||||
spine:destroy()
|
||||
return
|
||||
end
|
||||
table.insert(list, spine)
|
||||
local scale = monsterInfo.ui or 1
|
||||
spine:setLocalScale(-scale, scale, scale)
|
||||
self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function ChapterComp:doMonsterMove(modelId, spine, posY, monsterInfo, isTopTurn)
|
||||
spine:playAnim("move", true, true, true)
|
||||
local posX = GConst.UI_SCREEN_WIDTH / 2 + 100
|
||||
local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300
|
||||
spine:setAnchoredPosition(posX, posY)
|
||||
local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
||||
if self.chapterMonsterSpeed == nil then
|
||||
-- self.chapterMonsterSpeed = GFunc.getConstValue("chapter_idel_monstermove")
|
||||
self.chapterMonsterSpeed = 150
|
||||
end
|
||||
local distance = posX - targetPosX
|
||||
local moveTime = distance / self.chapterMonsterSpeed
|
||||
local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
seq:Append(moveTween)
|
||||
|
||||
-- local monsterShadow = self:getMonsterShadow()
|
||||
local scale = monsterInfo.ui or 1
|
||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
||||
-- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
||||
-- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset)
|
||||
-- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
-- seq:Join(moveTween2)
|
||||
|
||||
local monsterSmoke = self:getMonsterSmoke(isTopTurn)
|
||||
monsterSmoke:setAnchoredPosition(posX, posY)
|
||||
monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
||||
monsterSmoke:playAnim("idle", true, true, true)
|
||||
local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
seq:Join(moveTween3)
|
||||
|
||||
seq:AppendCallback(function()
|
||||
spine:setActive(false)
|
||||
-- monsterShadow:setAnchoredPositionX(10000)
|
||||
-- table.insert(self.monsterShadowPool, monsterShadow)
|
||||
monsterSmoke:setAnchoredPositionX(10000)
|
||||
table.insert(self.monsterSmokePool, monsterSmoke)
|
||||
if isTopTurn then
|
||||
local pool = self.monsterSpineTopPool[modelId]
|
||||
if pool == nil then
|
||||
pool = {}
|
||||
self.monsterSpineTopPool[modelId] = pool
|
||||
end
|
||||
table.insert(pool, spine)
|
||||
for k, v in ipairs(self.monsterSpineTopList) do
|
||||
if v == spine then
|
||||
table.remove(self.monsterSpineTopList, k)
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
local pool = self.monsterSpineDownPool[modelId]
|
||||
if pool == nil then
|
||||
pool = {}
|
||||
self.monsterSpineDownPool[modelId] = pool
|
||||
end
|
||||
table.insert(pool, spine)
|
||||
for k, v in ipairs(self.monsterSpineDownList) do
|
||||
if v == spine then
|
||||
table.remove(self.monsterSpineDownList, k)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ChapterComp:enterChapterBattle()
|
||||
-- boss等一会再跑
|
||||
local bossWaitTime = GFunc.getConstValue("chapter_fight_bosswait") / 1000
|
||||
local bossSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
||||
bossSeq:AppendInterval(bossWaitTime)
|
||||
local bossSpeed = GFunc.getConstValue("chapter_fight_bossmove")
|
||||
local distance = GConst.UI_SCREEN_WIDTH/2 + 100
|
||||
local moveTime = distance / bossSpeed
|
||||
local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300
|
||||
local moveTween = self.bossNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
bossSeq:Append(moveTween)
|
||||
local moveTween2 = self.dialogueNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
bossSeq:Join(moveTween2)
|
||||
-- local moveTween3 = self.bossShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
-- bossSeq:Join(moveTween3)
|
||||
|
||||
|
||||
-- 出来一批小怪从右边跑向左边
|
||||
local monsterCount = GFunc.getConstIntValue("chapter_fight_monster_num")
|
||||
self.chapterFightMonsterCount = monsterCount
|
||||
local wave = 5
|
||||
local monsterCountPerWave = math.ceil(monsterCount / wave)
|
||||
-- 分批处理
|
||||
local monsterSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
||||
for i = 1, wave do
|
||||
monsterSeq:AppendCallback(function ()
|
||||
if monsterCountPerWave > monsterCount then
|
||||
monsterCountPerWave = monsterCount
|
||||
end
|
||||
monsterCount = monsterCount - monsterCountPerWave
|
||||
for j = 1, monsterCountPerWave do
|
||||
self:generateChapterFightMonsters()
|
||||
end
|
||||
end)
|
||||
monsterSeq:AppendInterval(0.03)
|
||||
end
|
||||
return GFunc.getConstValue("chapter_fight_wait") / 1000
|
||||
end
|
||||
|
||||
function ChapterComp:generateChapterFightMonsters()
|
||||
local monsterId
|
||||
if #self.chapterMonsterShowList <= 2 then
|
||||
monsterId = self.chapterMonsterShowList[2]
|
||||
else
|
||||
monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)]
|
||||
end
|
||||
if monsterId == nil then
|
||||
return
|
||||
end
|
||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
||||
local monsterInfo = monsterCfg[monsterId]
|
||||
if monsterInfo == nil then
|
||||
return
|
||||
end
|
||||
local modelId = monsterInfo.model_id
|
||||
local pool
|
||||
local list
|
||||
local parent
|
||||
local posY
|
||||
if self.isTopTurn then -- 刷上面
|
||||
pool = self.monsterSpineTopPool[modelId]
|
||||
list = self.monsterSpineTopList
|
||||
parent = self.monsterNodeTop
|
||||
posY = math.random(1, 300)
|
||||
else -- 刷下面
|
||||
pool = self.monsterSpineDownPool[modelId]
|
||||
list = self.monsterSpineDownList
|
||||
parent = self.monsterNodeDown
|
||||
posY = -math.random(1, 240)
|
||||
end
|
||||
self.isTopTurn = not self.isTopTurn
|
||||
if pool and #pool > 0 then
|
||||
local spine = table.remove(pool)
|
||||
table.insert(list, spine)
|
||||
spine:setActive(true)
|
||||
self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
||||
else
|
||||
SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine)
|
||||
if not self.startMonsterAction then
|
||||
spine:destroy()
|
||||
return
|
||||
end
|
||||
table.insert(list, spine)
|
||||
local scale = monsterInfo.ui or 1
|
||||
spine:setLocalScale(-scale, scale, scale)
|
||||
self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function ChapterComp:doMonsterFightMove(modelId, spine, posY, monsterInfo, isTopTurn)
|
||||
spine:playAnim("move", true, true, true)
|
||||
local posX = GConst.UI_SCREEN_WIDTH / 2 + math.random(100, math.floor(GConst.UI_SCREEN_WIDTH*2/3))
|
||||
spine:setAnchoredPosition(posX, posY)
|
||||
local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
||||
if self.chapterMonsterFightSpeed == nil then
|
||||
-- self.chapterMonsterFightSpeed = GFunc.getConstValue("chapter_fight_monstermove")
|
||||
self.chapterMonsterFightSpeed = 880
|
||||
end
|
||||
local distance = posX + GConst.UI_SCREEN_WIDTH/2 + 100
|
||||
local moveTime = distance / self.chapterMonsterFightSpeed
|
||||
local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 100
|
||||
local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
seq:Append(moveTween)
|
||||
|
||||
-- local monsterShadow = self:getMonsterShadow()
|
||||
local scale = monsterInfo.ui or 1
|
||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
||||
-- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
||||
-- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset)
|
||||
-- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
-- seq:Join(moveTween2)
|
||||
|
||||
local monsterSmoke = self:getMonsterSmoke(isTopTurn)
|
||||
monsterSmoke:setAnchoredPosition(posX, posY)
|
||||
monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
||||
monsterSmoke:playAnim("idle", true, true, true)
|
||||
local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
||||
seq:Join(moveTween3)
|
||||
|
||||
seq:AppendCallback(function()
|
||||
spine:setActive(false)
|
||||
-- monsterShadow:setAnchoredPositionX(10000)
|
||||
-- table.insert(self.monsterShadowPool, monsterShadow)
|
||||
monsterSmoke:setAnchoredPositionX(10000)
|
||||
table.insert(self.monsterSmokePool, monsterSmoke)
|
||||
if isTopTurn then
|
||||
local pool = self.monsterSpineTopPool[modelId]
|
||||
if pool == nil then
|
||||
pool = {}
|
||||
self.monsterSpineTopPool[modelId] = pool
|
||||
end
|
||||
table.insert(pool, spine)
|
||||
for k, v in ipairs(self.monsterSpineTopList) do
|
||||
if v == spine then
|
||||
table.remove(self.monsterSpineTopList, k)
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
local pool = self.monsterSpineDownPool[modelId]
|
||||
if pool == nil then
|
||||
pool = {}
|
||||
self.monsterSpineDownPool[modelId] = pool
|
||||
end
|
||||
table.insert(pool, spine)
|
||||
for k, v in ipairs(self.monsterSpineDownList) do
|
||||
if v == spine then
|
||||
table.remove(self.monsterSpineDownList, k)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if self.chapterFightMonsterCount then
|
||||
self.chapterFightMonsterCount = self.chapterFightMonsterCount - 1
|
||||
if self.chapterFightMonsterCount == 0 then -- 最后一个怪物生成完毕后,重新排一下序
|
||||
self:sortChapterFightMonstersOrder()
|
||||
self:sortChapterFightMonstersOrder()
|
||||
self:sortChapterFightMonstersOrder()
|
||||
self:sortChapterFightMonstersOrder()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ChapterComp:sortChapterFightMonstersOrder()
|
||||
self:sortChildrenOrder(self.monsterNodeTop)
|
||||
self:sortChildrenOrder(self.monsterNodeDown)
|
||||
self:sortChildrenOrder(self.smokeNodeTop)
|
||||
self:sortChildrenOrder(self.smokeNodeDown)
|
||||
end
|
||||
|
||||
function ChapterComp:sortChildrenOrder(parent)
|
||||
local children = parent:getChildList()
|
||||
if children and #children > 0 then
|
||||
table.sort(children, function(a, b)
|
||||
return a:getAnchoredPositionY() > b:getAnchoredPositionY()
|
||||
end)
|
||||
|
||||
for i = #children, 1, -1 do
|
||||
children[i]:getTransform():SetSiblingIndex(i - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ChapterComp:getMonsterSmoke(isTop)
|
||||
local monsterSmoke
|
||||
if #self.monsterSmokePool > 0 then
|
||||
monsterSmoke = table.remove(self.monsterSmokePool)
|
||||
monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false)
|
||||
else
|
||||
local shadowObj = CS.UnityEngine.Object.Instantiate(self.bossSmoke:getGameObject())
|
||||
monsterSmoke = UISpineObject:create()
|
||||
monsterSmoke:initWithPrefab(GConst.EMPTY_STRING, shadowObj)
|
||||
monsterSmoke:getAnimationState()
|
||||
monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false)
|
||||
end
|
||||
return monsterSmoke
|
||||
end
|
||||
-- endregion
|
||||
|
||||
return ChapterComp
|
||||
550
lua/app/userdata/activity/act_base_data.lua
Normal file
550
lua/app/userdata/activity/act_base_data.lua
Normal file
@ -0,0 +1,550 @@
|
||||
local ActBaseData = class("ActBaseData", BaseData)
|
||||
|
||||
-- 必须重写 --------------------------------------------------------------------------------------------------------------
|
||||
function ActBaseData:setActivityInfo()
|
||||
Logger.logFatal("不能被调用,必须重写")
|
||||
end
|
||||
|
||||
function ActBaseData:getActNameStr()
|
||||
return ""
|
||||
end
|
||||
|
||||
-- 通用逻辑 --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function ActBaseData:setDirty()
|
||||
end
|
||||
|
||||
function ActBaseData:initActInfo(data)
|
||||
-- Logger.logHighlight(tostring(self.actId) .. " " .. tostring(data.actId))
|
||||
if self.actId ~= data.actId then
|
||||
self.turntableCfg = nil
|
||||
self.turntableCfgList = nil
|
||||
self.turntableTargetCfg = nil
|
||||
self.turntableTargetCfgList = nil
|
||||
self.bountyCfg = nil
|
||||
self.bountyCfgList = nil
|
||||
self.bountyProId = nil
|
||||
self.exchangeCfg = nil
|
||||
|
||||
if self.actId then
|
||||
self:tryResetActItem(data.actId)
|
||||
self:tryResetGift(data.actId, true)
|
||||
self:tryResetProBought(data.actId)
|
||||
end
|
||||
self:clear()
|
||||
end
|
||||
|
||||
self.actId = data.actId
|
||||
self.startTime = data.startTime
|
||||
self.endTime = data.endTime
|
||||
self.extraTime = data.extraTime
|
||||
end
|
||||
|
||||
function ActBaseData:getActId()
|
||||
return self.actId
|
||||
end
|
||||
|
||||
function ActBaseData:getStartTime()
|
||||
return self.startTime
|
||||
end
|
||||
|
||||
function ActBaseData:getEndTime()
|
||||
return self.endTime
|
||||
end
|
||||
|
||||
function ActBaseData:getExtraTime()
|
||||
return self.extraTime
|
||||
end
|
||||
|
||||
function ActBaseData:getRemainTime()
|
||||
if not self:getStartTime() then
|
||||
return 0
|
||||
end
|
||||
|
||||
local nowTime = Time:getServerTime()
|
||||
if self:getExtraTime() < nowTime then
|
||||
return 0
|
||||
end
|
||||
|
||||
return self:getExtraTime() - nowTime
|
||||
end
|
||||
|
||||
function ActBaseData:getNormalRemainTime()
|
||||
local nowTime = Time:getServerTime()
|
||||
if self:getEndTime() < nowTime then
|
||||
return 0
|
||||
end
|
||||
|
||||
return self:getEndTime() - nowTime
|
||||
end
|
||||
|
||||
function ActBaseData:getTotalRemainTime()
|
||||
local remainTime = self:getNormalRemainTime()
|
||||
if remainTime <= 0 then
|
||||
remainTime = self:getRemainTime()
|
||||
end
|
||||
|
||||
return remainTime
|
||||
end
|
||||
|
||||
function ActBaseData:getIsLastDay()
|
||||
if not self:getStartTime() then
|
||||
return false
|
||||
end
|
||||
|
||||
local nowTime = Time:getServerTime()
|
||||
if self:getExtraTime() > nowTime and nowTime >= self:getEndTime() then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function ActBaseData:getActivityDay()
|
||||
local time = Time:getDayBeginTimeStamp(self:getStartTime())
|
||||
return (Time:getServerTime() - time) // GConst.SECONDS_PRE_DAY + 1
|
||||
end
|
||||
|
||||
function ActBaseData:getTimeOpen()
|
||||
if not self:getStartTime() then
|
||||
return false
|
||||
end
|
||||
|
||||
local nowTime = Time:getServerTime()
|
||||
if self:getStartTime() <= nowTime and nowTime <= self:getExtraTime() then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function ActBaseData:getIsOpen()
|
||||
if GFunc.isShenhe() then
|
||||
return false
|
||||
end
|
||||
|
||||
if not ModuleManager:getIsOpen(DataManager.ActivityData:getActOpenKey(), true) then
|
||||
return false
|
||||
end
|
||||
|
||||
local actId = self:getActId()
|
||||
if not actId or actId <= 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
return self:getTimeOpen()
|
||||
end
|
||||
|
||||
-- 重置活动道具
|
||||
function ActBaseData:tryResetActItem(actId)
|
||||
actId = actId or self:getActId()
|
||||
if not actId or actId <= 0 then
|
||||
return
|
||||
end
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("重置活动道具数据 act_id = " .. tostring(actId))
|
||||
end
|
||||
|
||||
DataManager.ActivityData:tryResetActItem(actId)
|
||||
end
|
||||
|
||||
-- 重置礼包购买次数
|
||||
-- force true重置所有礼包 false只重置免费礼包
|
||||
function ActBaseData:tryResetGift(actId, force)
|
||||
actId = actId or self:getActId()
|
||||
if not actId or actId <= 0 then
|
||||
return
|
||||
end
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("重置活动礼包数据 act_id = " .. tostring(actId))
|
||||
end
|
||||
|
||||
DataManager.ActGiftData:tryResetGift(actId, force)
|
||||
end
|
||||
|
||||
function ActBaseData:tryResetProBought(actId)
|
||||
actId = actId or self:getActId()
|
||||
if not actId or actId <= 0 then
|
||||
return
|
||||
end
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("重置活动战令数据 act_id = " .. tostring(actId))
|
||||
end
|
||||
|
||||
DataManager.ActBountyData:tryResetProBought(actId)
|
||||
end
|
||||
|
||||
-- region 转盘
|
||||
|
||||
function ActBaseData:getTurntableCfg(id)
|
||||
if self.turntableCfg == nil then
|
||||
self.turntableCfg = {}
|
||||
for id, info in pairs(ConfigManager:getConfig("act_turntable")) do
|
||||
if info.activity == self:getActId() then
|
||||
info.id = id
|
||||
self.turntableCfg[id] = info
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if id then
|
||||
return self.turntableCfg[id]
|
||||
else
|
||||
return self.turntableCfg
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseData:getTurntableCfgList()
|
||||
if self.turntableCfgList == nil then
|
||||
self.turntableCfgList = {}
|
||||
for k,v in pairs(self:getTurntableCfg()) do
|
||||
table.insert(self.turntableCfgList, v)
|
||||
end
|
||||
table.sort(self.turntableCfgList, function(a, b) return a.id < b.id end)
|
||||
end
|
||||
|
||||
return self.turntableCfgList
|
||||
end
|
||||
|
||||
function ActBaseData:getTurntableTargetCfg(id)
|
||||
if self.turntableTargetCfg == nil then
|
||||
self.turntableTargetCfg = {}
|
||||
for id, info in pairs(ConfigManager:getConfig("act_turntable_target")) do
|
||||
if info.activity == self:getActId() then
|
||||
self.turntableTargetCfg[id] = info
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if id then
|
||||
return self.turntableTargetCfg[id]
|
||||
else
|
||||
return self.turntableTargetCfg
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseData:getTurntableTargetCfgList()
|
||||
if self.turntableTargetCfgList == nil then
|
||||
self.turntableTargetCfgList = {}
|
||||
for k,v in pairs(self:getTurntableTargetCfg()) do
|
||||
v.id = k
|
||||
table.insert(self.turntableTargetCfgList, v)
|
||||
end
|
||||
table.sort(self.turntableTargetCfgList, function(a, b) return a.id < b.id end)
|
||||
end
|
||||
|
||||
return self.turntableTargetCfgList
|
||||
end
|
||||
|
||||
function ActBaseData:getTurntableTargetList()
|
||||
local targetList = {}
|
||||
for i, info in pairs(self:getTurntableTargetCfg()) do
|
||||
table.insert(targetList, info.target)
|
||||
end
|
||||
table.sort(targetList, function(a, b)
|
||||
return a < b
|
||||
end)
|
||||
return targetList
|
||||
end
|
||||
|
||||
-- 获取抽取消耗
|
||||
function ActBaseData:getTurntableCost()
|
||||
for id, info in pairs(self:getTurntableCfg()) do
|
||||
return info.cost
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseData:hasTurntableItem()
|
||||
local cost = self:getTurntableCost()
|
||||
local num = DataManager.BagData.ItemData:getItemNumById(GFunc.getRewardId(cost))
|
||||
return num > 0
|
||||
end
|
||||
|
||||
-- 是否是大奖
|
||||
function ActBaseData:isTurntableBigReward(id)
|
||||
return self:getTurntableCfg(id).reward_final == 1
|
||||
end
|
||||
|
||||
function ActBaseData:saveBigRewards(reward)
|
||||
self.bigRewards = reward
|
||||
end
|
||||
|
||||
function ActBaseData:getBigRewards()
|
||||
return self.bigRewards
|
||||
end
|
||||
|
||||
--@endregion
|
||||
|
||||
-- region 战令
|
||||
|
||||
function ActBaseData:getBountyCfg(id)
|
||||
if self.bountyCfg == nil then
|
||||
self.bountyCfg = {}
|
||||
for id, info in pairs(ConfigManager:getConfig("act_bounty")) do
|
||||
if info.activity == self:getActId() then
|
||||
info.id = id
|
||||
self.bountyCfg[id] = info
|
||||
end
|
||||
end
|
||||
end
|
||||
if id then
|
||||
return self.bountyCfg[id]
|
||||
else
|
||||
return self.bountyCfg
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseData:getBountyCfgList(id)
|
||||
if self.bountyCfgList == nil then
|
||||
self.bountyCfgList = {}
|
||||
for k, v in pairs(self:getBountyCfg()) do
|
||||
table.insert(self.bountyCfgList, v)
|
||||
end
|
||||
table.sort(self.bountyCfgList, function(a, b) return a.id < b.id end)
|
||||
end
|
||||
if id then
|
||||
return self.bountyCfgList[id]
|
||||
else
|
||||
return self.bountyCfgList
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取高级奖励礼包id,用于支付
|
||||
function ActBaseData:getProRewardGiftId()
|
||||
if self.bountyProId == nil then
|
||||
for id, info in pairs(self:getBountyCfg()) do
|
||||
if info.reward_pro_pay then
|
||||
self.bountyProId = info.reward_pro_pay
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return self.bountyProId
|
||||
end
|
||||
|
||||
-- 是否解锁高级奖励
|
||||
function ActBaseData:isUnlockProReward()
|
||||
local giftId = self:getProRewardGiftId()
|
||||
local boughtCount = DataManager.PaymentData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, giftId)
|
||||
local boughtTime = DataManager.PaymentData:getGiftBoughtTime(PayManager.PURCHARSE_TYPE.ACT_GIFT, giftId)
|
||||
|
||||
if boughtCount <= 0 then
|
||||
return false
|
||||
end
|
||||
if boughtTime < self:getStartTime() or boughtTime > self:getEndTime() then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--@endregion
|
||||
|
||||
-- region 兑换
|
||||
|
||||
function ActBaseData:getExchangeCfg(id)
|
||||
if self.exchangeCfg == nil then
|
||||
self.exchangeCfg = {}
|
||||
for id, info in pairs(ConfigManager:getConfig("act_exchange")) do
|
||||
if info.activity == self:getActId() then
|
||||
info.id = id
|
||||
self.exchangeCfg[id] = info
|
||||
end
|
||||
end
|
||||
table.sort(self.exchangeCfg, function(a, b) return a.id < b.id end)
|
||||
end
|
||||
|
||||
if id then
|
||||
return self.exchangeCfg[id]
|
||||
else
|
||||
return self.exchangeCfg
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseData:getExchangeCfgList(page)
|
||||
local isV2 = false
|
||||
for k,v in pairs(self:getExchangeCfg()) do
|
||||
if v.group then
|
||||
isV2 = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if isV2 then
|
||||
self.isV2 = isV2
|
||||
return self:getExchangeCfgList2(page)
|
||||
end
|
||||
|
||||
self.isV2 = false
|
||||
self.exchangeCfgList = {}
|
||||
for k,v in pairs(self:getExchangeCfg()) do
|
||||
v.id = k
|
||||
if v.limit - self:getTodayExchangeCount(k) <= 0 then
|
||||
v._sort = 10000000 + k
|
||||
else
|
||||
v._sort = k
|
||||
end
|
||||
table.insert(self.exchangeCfgList, v)
|
||||
end
|
||||
table.sort(self.exchangeCfgList, function(a, b) return a._sort < b._sort end)
|
||||
return self.exchangeCfgList
|
||||
end
|
||||
|
||||
function ActBaseData:getExchangeCfgList2(page)
|
||||
self.exchangeCfgList = {}
|
||||
self.canExchangeList = {}
|
||||
for k,v in pairs(self:getExchangeCfg()) do
|
||||
self.canExchangeList[v.group] = self.canExchangeList[v.group] or {}
|
||||
v.id = k
|
||||
if v.limit - self:getTodayExchangeCount(k) <= 0 then
|
||||
v._sort = 100000000000000000 + v.group *1000000000000 + (1000000000000 - DataManager.ActivityData:getExchangeTime(k))
|
||||
else
|
||||
v._sort = v.group *1000 + v.group_pr
|
||||
end
|
||||
-- if v.limit - self:getTodayExchangeCount(k) > 0 and self:checkExchange2Display(v) then
|
||||
if self:checkExchange2Display(v) then
|
||||
table.insert(self.canExchangeList[v.group], v)
|
||||
end
|
||||
end
|
||||
for group, tab in pairs(self.canExchangeList) do
|
||||
table.sort(tab, function(a, b) return a._sort < b._sort end)
|
||||
end
|
||||
if not self.exchangeSelIdxs then
|
||||
self.exchangeSelIdxs = {}
|
||||
for group, tab in pairs(self.canExchangeList) do
|
||||
for i,v in ipairs(tab) do
|
||||
table.insert(self.exchangeCfgList, v)
|
||||
self.exchangeSelIdxs[group] = i
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
for group, idx in pairs(self.exchangeSelIdxs) do
|
||||
if not self.canExchangeList[group] then
|
||||
self.exchangeSelIdxs[group] = nil
|
||||
elseif not self.canExchangeList[group][idx] then
|
||||
for i,v in ipairs(self.canExchangeList[group]) do
|
||||
table.insert(self.exchangeCfgList, v)
|
||||
self.exchangeSelIdxs[group] = i
|
||||
break
|
||||
end
|
||||
else
|
||||
local cfg = self.canExchangeList[group][idx]
|
||||
if cfg.limit - self:getTodayExchangeCount(cfg.id) <= 0 then
|
||||
self.exchangeSelIdxs[group] = 1
|
||||
table.insert(self.exchangeCfgList, self.canExchangeList[group][1])
|
||||
else
|
||||
table.insert(self.exchangeCfgList, cfg)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- for group, tab in pairs(self.canExchangeList) do
|
||||
-- for i,v in ipairs(tab) do
|
||||
-- if v.limit - self:getTodayExchangeCount(k) > 0 then
|
||||
-- table.insert(self.exchangeCfgList, tab[self.exchangeSelIdxs[group]])
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
table.sort(self.exchangeCfgList, function(a, b) return a._sort < b._sort end)
|
||||
if page then
|
||||
local tab = {}
|
||||
for i,v in ipairs(self.exchangeCfgList) do
|
||||
if v.page == page then
|
||||
table.insert(tab, v)
|
||||
end
|
||||
end
|
||||
return tab
|
||||
else
|
||||
return self.exchangeCfgList
|
||||
end
|
||||
end
|
||||
|
||||
function ActBaseData:checkExchange2Display(cfg)
|
||||
-- 1 英雄是否拥有
|
||||
-- 2 防线皮肤是否拥有
|
||||
-- 3 武器是否拥有
|
||||
-- 4 英雄皮肤是否拥有
|
||||
-- 5 领主时装是否拥有
|
||||
-- 6 宝物是否满星
|
||||
-- 7 宠物是否满星
|
||||
-- 8 魔法书是否满星
|
||||
local reward = cfg.reward[1]
|
||||
if cfg.display == 1 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FORCE, true) then
|
||||
return not DataManager.ForceData:getIsOwnForce(reward.id)
|
||||
elseif cfg.display == 2 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DEFENSE_LINE, true) then
|
||||
return DataManager.DefenseLineData:getSkinStar(reward.id) <= 0
|
||||
elseif cfg.display == 3 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.EQUIP, true) then
|
||||
return DataManager.WeaponData:getSkinStar(reward.id) <= 0
|
||||
elseif cfg.display == 4 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FORCE, true) then
|
||||
return not DataManager.ForceData:isSkinUnlock(reward.id)
|
||||
elseif cfg.display == 5 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SKIN, true) then
|
||||
return DataManager.SkinData:getSkinStar(reward.id) <= 0
|
||||
elseif cfg.display == 6 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.COLLECTION, true) then
|
||||
return not DataManager.CollectionData:isMaxStar(reward.id)
|
||||
elseif cfg.display == 7 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.PET, true) then
|
||||
local petId = reward.id // 10
|
||||
local entity = DataManager.PetData:getEntityById(petId)
|
||||
return not entity:isMaxStar()
|
||||
elseif cfg.display == 8 and ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MAGIC_BOOK, true) then
|
||||
local cfg = ConfigManager:getConfig("item")[reward.id]
|
||||
local id = cfg.parameter[1]
|
||||
local lv = DataManager.MagicBookData:getLv(id)
|
||||
local isMaxLv = lv >= DataManager.MagicBookData:getMagicBookMaxLv(id)
|
||||
return not isMaxLv
|
||||
elseif not cfg.display then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function ActBaseData:getIsExchangeV2()
|
||||
return self.isV2
|
||||
end
|
||||
|
||||
function ActBaseData:getExchange2GroupList(group)
|
||||
local tmp = self.canExchangeList[group] or {}
|
||||
local tab = {}
|
||||
for i,v in ipairs(tmp) do
|
||||
if v.limit - self:getTodayExchangeCount(v.id) > 0 then
|
||||
table.insert(tab, v)
|
||||
end
|
||||
end
|
||||
return tab
|
||||
end
|
||||
|
||||
function ActBaseData:getExchange2GroupListSelIdx(group)
|
||||
return self.exchangeSelIdxs[group]
|
||||
end
|
||||
|
||||
function ActBaseData:setExchange2GroupListSelIdx(group, idx)
|
||||
self.exchangeSelIdxs[group] = idx
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
-- 今日已买次数
|
||||
function ActBaseData:getTodayExchangeCount(id)
|
||||
return DataManager.ActivityData:getExchangeCount(id)
|
||||
end
|
||||
|
||||
-- 是否可购买
|
||||
function ActBaseData:canExchange(id, showToast, count)
|
||||
local cfg = self:getExchangeCfg(id)
|
||||
count = count or 1
|
||||
if cfg.limit - self:getTodayExchangeCount(id) <= 0 then
|
||||
if showToast then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.IDLE_DESC_10))
|
||||
end
|
||||
return false
|
||||
end
|
||||
local cost = cfg.cost[1]
|
||||
if not GFunc.checkCost(GFunc.getRewardId(cost), GFunc.getRewardNum(cost) * count, showToast) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--@endregion
|
||||
|
||||
return ActBaseData
|
||||
10
lua/app/userdata/activity/act_base_data.lua.meta
Normal file
10
lua/app/userdata/activity/act_base_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b654f2ca573e4100a53179f219f75a4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
120
lua/app/userdata/activity/act_time_data.lua
Normal file
120
lua/app/userdata/activity/act_time_data.lua
Normal file
@ -0,0 +1,120 @@
|
||||
local ActTimeData = class("ActTimeData", BaseData)
|
||||
|
||||
function ActTimeData:ctor()
|
||||
self.actTimeList = {}
|
||||
end
|
||||
|
||||
function ActTimeData:clear()
|
||||
end
|
||||
|
||||
---- 活动改版后,服务器只会发一个活动类型的当前或下一次的数据,不是想之前一样无脑把activity表转过来
|
||||
function ActTimeData:init(data)
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("活动时间初始化-------------------" .. tostring(data ~= nil))
|
||||
-- Logger.printTable(data)
|
||||
end
|
||||
data = data or {}
|
||||
self.actTimeList = data
|
||||
self:refreshActTime()
|
||||
end
|
||||
|
||||
function ActTimeData:refreshActTime()
|
||||
local curTime = Time:getServerTime()
|
||||
self.actTypeTimeList = {}
|
||||
for _, info in ipairs(self.actTimeList) do
|
||||
local actId = info.id
|
||||
if ModuleManager.ActivityManager:getActivityInCfg(actId) then
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("活动id:" .. info.id .. " 类型:" .. info.type .. " 开启:" .. info.start_at .. " 结束:" .. info.end_at .. " 额外:" .. info.extra_at)
|
||||
end
|
||||
local actType = info.type
|
||||
local startTime = info.start_at or 0
|
||||
if startTime < 0 then
|
||||
startTime = 0
|
||||
end
|
||||
|
||||
local endTime = info.end_at
|
||||
if endTime < 0 then
|
||||
endTime = 0
|
||||
end
|
||||
|
||||
local extraTime = info.extra_at
|
||||
if extraTime < endTime then
|
||||
extraTime = endTime
|
||||
end
|
||||
|
||||
local actGifts = info.gifts or {}
|
||||
local data = info.data
|
||||
if curTime < extraTime then -- 在有效期内
|
||||
if self.actTypeTimeList[actType] == nil or self.actTypeTimeList[actType].endTime > endTime then
|
||||
self.actTypeTimeList[actType] = {actId = actId, actType = actType, startTime = startTime, endTime = endTime, extraTime = extraTime, actGifts = actGifts, data = data}
|
||||
self:initActivityData(actType, self.actTypeTimeList[actType])
|
||||
end
|
||||
else
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("活动暂未开启:" .. info.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActTimeData:getActTimeList()
|
||||
return self.actTimeList
|
||||
end
|
||||
|
||||
function ActTimeData:getActTimeInfoByActId(id)
|
||||
for _, info in ipairs(self.actTimeList) do
|
||||
if info.id == id then
|
||||
return info
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActTimeData:getActStartTime(actId)
|
||||
for _, info in ipairs(self.actTimeList) do
|
||||
if info.id == actId then
|
||||
return info.start_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActTimeData:getActEndTime(actId)
|
||||
for _, info in ipairs(self.actTimeList) do
|
||||
if info.id == actId then
|
||||
local extraTime = info.extra_at
|
||||
if extraTime < info.end_at then
|
||||
extraTime = info.end_at
|
||||
end
|
||||
return extraTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActTimeData:getActExtraTime(actId)
|
||||
for _, info in ipairs(self.actTimeList) do
|
||||
if info.id == actId then
|
||||
local extraTime = info.extra_at
|
||||
if extraTime < info.end_at then
|
||||
extraTime = info.end_at
|
||||
end
|
||||
return extraTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ActTimeData:getActTypeTimeList()
|
||||
return self.actTypeTimeList or {}
|
||||
end
|
||||
|
||||
function ActTimeData:initActivityData(actType, info)
|
||||
local data = DataManager[GConst.ActivityConst.ACTIVITY_TYPE_DATA[actType]]
|
||||
if data then
|
||||
if data.initActInfo then
|
||||
data:initActInfo(info)-- 初始化基类方法
|
||||
end
|
||||
data:setActivityInfo(info)-- 初始化子类方法
|
||||
end
|
||||
end
|
||||
|
||||
return ActTimeData
|
||||
10
lua/app/userdata/activity/act_time_data.lua.meta
Normal file
10
lua/app/userdata/activity/act_time_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6d01ed18154941579357b5e2fa6d474
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
Loading…
x
Reference in New Issue
Block a user