挂机
This commit is contained in:
parent
0289de2d9a
commit
3cb5152538
@ -66,7 +66,8 @@ BIReport.ITEM_GET_TYPE = {
|
|||||||
TASK_DAILY_REWARD = "TaskDailyReward",
|
TASK_DAILY_REWARD = "TaskDailyReward",
|
||||||
BOUNTY_UNLOCK_LEVEL = "BountyUnlockLevel",
|
BOUNTY_UNLOCK_LEVEL = "BountyUnlockLevel",
|
||||||
BOUNTY_REWARD = "BountyReward",
|
BOUNTY_REWARD = "BountyReward",
|
||||||
BOUNTY = "Bounty"
|
BOUNTY = "Bounty",
|
||||||
|
IDLE_DROP = "IdleDrop"
|
||||||
}
|
}
|
||||||
|
|
||||||
BIReport.ADS_CLICK_TYPE = {
|
BIReport.ADS_CLICK_TYPE = {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
local IdleManager = class("IdleManager", BaseModule)
|
local IdleManager = class("IdleManager", BaseModule)
|
||||||
|
|
||||||
function IdleManager:showIdleDropUI(params)
|
function IdleManager:showIdleDropUI(params)
|
||||||
|
self:getIdleShowRewrad()
|
||||||
UIManager:showUI("app/ui/idle/idle_drop_ui", params)
|
UIManager:showUI("app/ui/idle/idle_drop_ui", params)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -8,8 +9,27 @@ function IdleManager:showIdleQuickDropUI(params)
|
|||||||
UIManager:showUI("app/ui/idle/idle_quick_drop_ui", params)
|
UIManager:showUI("app/ui/idle/idle_quick_drop_ui", params)
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleManager:getIdleRewrad()
|
function IdleManager:getIdleShowRewrad()
|
||||||
|
self:sendMessage(ProtoMsgType.FromMsgEnum.IdleInfoReq, {}, {}, self.onGetIdleShowRewrad, BIReport.ITEM_GET_TYPE.NONE)
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleManager:onGetIdleShowRewrad(result)
|
||||||
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
|
DataManager.IdleData:onGetIdleShowRewrad(result)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleManager:getIdleRewrad()
|
||||||
|
self:sendMessage(ProtoMsgType.FromMsgEnum.IdleRewardReq, {}, {}, self.onGetIdleRewrad, BIReport.ITEM_GET_TYPE.IDLE_DROP)
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleManager:onGetIdleRewrad(result)
|
||||||
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
|
if result.rewards and next(result.rewards) then
|
||||||
|
GFunc.showRewardBox(result.rewards)
|
||||||
|
end
|
||||||
|
DataManager.IdleData:onGetIdleRewrad(result.claim_at)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleManager:getHangUpQuickRewrad()
|
function IdleManager:getHangUpQuickRewrad()
|
||||||
|
|||||||
@ -36,6 +36,8 @@ local ProtoMsgType = {
|
|||||||
[1666429753] = "MailDeleteRsp",
|
[1666429753] = "MailDeleteRsp",
|
||||||
[1690297937] = "SummonReq",
|
[1690297937] = "SummonReq",
|
||||||
[1690299770] = "SummonRsp",
|
[1690299770] = "SummonRsp",
|
||||||
|
[1746317288] = "IdleInfoReq",
|
||||||
|
[1746319121] = "IdleInfoRsp",
|
||||||
[1901321540] = "PipedReq",
|
[1901321540] = "PipedReq",
|
||||||
[2095612947] = "ChangeNameReq",
|
[2095612947] = "ChangeNameReq",
|
||||||
[2095614780] = "ChangeNameRsp",
|
[2095614780] = "ChangeNameRsp",
|
||||||
@ -134,6 +136,8 @@ local ProtoMsgType = {
|
|||||||
MailDeleteRsp = 1666429753,
|
MailDeleteRsp = 1666429753,
|
||||||
SummonReq = 1690297937,
|
SummonReq = 1690297937,
|
||||||
SummonRsp = 1690299770,
|
SummonRsp = 1690299770,
|
||||||
|
IdleInfoReq = 1746317288,
|
||||||
|
IdleInfoRsp = 1746319121,
|
||||||
PipedReq = 1901321540,
|
PipedReq = 1901321540,
|
||||||
ChangeNameReq = 2095612947,
|
ChangeNameReq = 2095612947,
|
||||||
ChangeNameRsp = 2095614780,
|
ChangeNameRsp = 2095614780,
|
||||||
@ -232,6 +236,8 @@ local ProtoMsgType = {
|
|||||||
MailDeleteRsp = "MailDeleteRsp",
|
MailDeleteRsp = "MailDeleteRsp",
|
||||||
SummonReq = "SummonReq",
|
SummonReq = "SummonReq",
|
||||||
SummonRsp = "SummonRsp",
|
SummonRsp = "SummonRsp",
|
||||||
|
IdleInfoReq = "IdleInfoReq",
|
||||||
|
IdleInfoRsp = "IdleInfoRsp",
|
||||||
PipedReq = "PipedReq",
|
PipedReq = "PipedReq",
|
||||||
ChangeNameReq = "ChangeNameReq",
|
ChangeNameReq = "ChangeNameReq",
|
||||||
ChangeNameRsp = "ChangeNameRsp",
|
ChangeNameRsp = "ChangeNameRsp",
|
||||||
|
|||||||
@ -9,11 +9,9 @@ function IdleDropUI:getPrefabPath()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function IdleDropUI:ctor()
|
function IdleDropUI:ctor()
|
||||||
self.rewardList = {}
|
self.itemList = {}
|
||||||
end
|
self.refreshIntervalTime = GFunc.getConstValue("idle_exp_drop_time")
|
||||||
|
self.canRefreshReward = false
|
||||||
function IdleDropUI:onReshow()
|
|
||||||
-- self:refreshBtn()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleDropUI:onLoadRootComplete()
|
function IdleDropUI:onLoadRootComplete()
|
||||||
@ -36,6 +34,8 @@ function IdleDropUI:onLoadRootComplete()
|
|||||||
uiMap["idle_drop_ui.bg.quick_btn.text"]:setText("临时文本:快速挂机")
|
uiMap["idle_drop_ui.bg.quick_btn.text"]:setText("临时文本:快速挂机")
|
||||||
self.getBtn = uiMap["idle_drop_ui.bg.get_btn"]
|
self.getBtn = uiMap["idle_drop_ui.bg.get_btn"]
|
||||||
self.getBtn:addClickListener(function()
|
self.getBtn:addClickListener(function()
|
||||||
|
self.lastRefreshTime = Time:getServerTime()
|
||||||
|
ModuleManager.IdleManager:getIdleRewrad()
|
||||||
end)
|
end)
|
||||||
uiMap["idle_drop_ui.bg.get_btn.text"]:setText("临时文本:领取")
|
uiMap["idle_drop_ui.bg.get_btn.text"]:setText("临时文本:领取")
|
||||||
uiMap["idle_drop_ui.bg.close_btn"]:addClickListener(function()
|
uiMap["idle_drop_ui.bg.close_btn"]:addClickListener(function()
|
||||||
@ -43,6 +43,7 @@ function IdleDropUI:onLoadRootComplete()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
self:initRewards()
|
self:initRewards()
|
||||||
|
self:bindData()
|
||||||
self:refreshCD()
|
self:refreshCD()
|
||||||
self:scheduleGlobal(function()
|
self:scheduleGlobal(function()
|
||||||
self:refreshCD()
|
self:refreshCD()
|
||||||
@ -55,73 +56,100 @@ function IdleDropUI:initRewards()
|
|||||||
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
||||||
end)
|
end)
|
||||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||||
-- cell:refreshByConfig(self.list[index])
|
cell:refreshByConfig(self.itemList[index])
|
||||||
end)
|
end)
|
||||||
self.scrollRect:clearCells()
|
self.scrollRect:clearCells()
|
||||||
self.scrollRect:refillCells(#self.rewardList)
|
self.scrollRect:setTotalCount(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- function IdleDropUI:_display()
|
function IdleDropUI:bindData()
|
||||||
-- local uiMap = self.root:genAllChildren()
|
self:bind(DataManager.IdleData, "dirty", function()
|
||||||
-- uiMap["idle_drop_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC))
|
self:onRefresh()
|
||||||
-- uiMap["idle_drop_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_1))
|
self.canRefreshReward = true
|
||||||
-- uiMap["idle_drop_ui.bg.desc_2"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_3, Time:formatNumTime(GFunc.getConstIntValue("idle_maxtime"))))
|
end)
|
||||||
-- uiMap["idle_drop_ui.bg.btn_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_5))
|
end
|
||||||
-- uiMap["idle_drop_ui.bg.btn_2.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.GET_DESC))
|
|
||||||
-- uiMap["idle_drop_ui.bg.bg_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_4, self.coinPerHour))
|
|
||||||
-- uiMap["idle_drop_ui.bg.bg_2.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_4, self.expPerHour))
|
|
||||||
|
|
||||||
-- self:_refreshScrollRect()
|
function IdleDropUI:onRefresh()
|
||||||
-- self:refreshBtn()
|
self:refreshRewards()
|
||||||
-- self.canRefreshReward = true
|
self:refreshBtns()
|
||||||
-- end
|
end
|
||||||
|
|
||||||
-- function IdleDropUI:_addListeners()
|
function IdleDropUI:refreshRewards()
|
||||||
-- local uiMap = self.root:genAllChildren()
|
for i = 1, #self.itemList do
|
||||||
-- self.root:addClickListener(function()
|
table.remove(self.itemList)
|
||||||
-- self:closeUI()
|
end
|
||||||
-- ModuleManager.IdleManager:getIdleRewrad()
|
local rewards = DataManager.IdleData:getIdleRewards()
|
||||||
-- end)
|
for _, item in pairs(rewards) do
|
||||||
-- uiMap["idle_drop_ui.bg.close_img"]:addClickListener(function()
|
if item.num > 0 then
|
||||||
-- self:closeUI()
|
table.insert(self.itemList, item)
|
||||||
-- ModuleManager.IdleManager:getIdleRewrad()
|
end
|
||||||
-- end)
|
end
|
||||||
|
if #self.itemList > 1 then
|
||||||
|
-- 道具类型从低到高>道具ID从低到高>品质从高到低
|
||||||
|
local cfg = ConfigManager:getConfig("item")
|
||||||
|
local infoA
|
||||||
|
local infoB
|
||||||
|
table.sort(self.itemList, function(a, b)
|
||||||
|
infoA = cfg[a.id]
|
||||||
|
infoB = cfg[b.id]
|
||||||
|
if infoA.type == infoB.type then
|
||||||
|
if infoA.qlt == infoB.qlt then
|
||||||
|
return infoA.qlt > infoB.qlt
|
||||||
|
else
|
||||||
|
return a.id < b.id
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return infoA.type < infoB.type
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if self.scrollRect:getTotalCount() ~= #self.itemList then -- 打开界面的时候定位到当前可领取的最低等级奖励,如果没有则定位到当前等级
|
||||||
|
self.scrollRect:refillCells(#self.itemList)
|
||||||
|
else
|
||||||
|
self.scrollRect:updateAllCell()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- uiMap["idle_drop_ui.bg.btn_1"]:addClickListener(function()
|
function IdleDropUI:refreshBtns()
|
||||||
-- ModuleManager.IdleManager:showIdleQuickDropUI()
|
if #self.itemList > 0 then
|
||||||
-- end)
|
self.getBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_green_2")
|
||||||
|
self.getBtn:setTouchEnable(true)
|
||||||
-- uiMap["idle_drop_ui.bg.btn_2"]:addClickListener(function()
|
else
|
||||||
-- ModuleManager.IdleManager:getIdleRewrad()
|
self.getBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey_2")
|
||||||
-- end)
|
self.getBtn:setTouchEnable(false)
|
||||||
|
end
|
||||||
-- -- self:bind(DataManager.HangUpData, "isDirty", function()
|
local quickTimes = DataManager.IdleData:getQuickIdleTimes()
|
||||||
-- -- self.list = DataManager.HangUpData:getCacheRewards()
|
if quickTimes > 0 then
|
||||||
-- -- self:_refreshScrollRect()
|
self.quickBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_yellow_2")
|
||||||
-- -- self.canRefreshReward = true
|
self.quickBtn:setTouchEnable(true)
|
||||||
-- -- end)
|
self:addQuickBtnRedPoint()
|
||||||
-- end
|
else
|
||||||
|
self.quickBtn:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey_2")
|
||||||
|
self.quickBtn:setTouchEnable(false)
|
||||||
|
self:removeQuickBtnRedPoint()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function IdleDropUI:refreshCD()
|
function IdleDropUI:refreshCD()
|
||||||
local time = Time:getServerTime() - DataManager.IdleData:getLastDropTime()
|
local time = Time:getServerTime() - DataManager.IdleData:getLastDropTime()
|
||||||
local idleMaxTime = DataManager.IdleData:getIdleMaxTime()
|
local idleMaxTime = DataManager.IdleData:getIdleMaxTime()
|
||||||
if time >= idleMaxTime then
|
if time >= idleMaxTime and #self.itemList > 0 then
|
||||||
self:addGetBtnRedPoint()
|
self:addGetBtnRedPoint()
|
||||||
self.timeTx:setText(Time:formatNumTime(idleMaxTime))
|
self.timeTx:setText(Time:formatNumTime(idleMaxTime))
|
||||||
else
|
else
|
||||||
self:removeGetBtnRedPoint()
|
self:removeGetBtnRedPoint()
|
||||||
self.timeTx:setText(Time:formatNumTime(time))
|
self.timeTx:setText(Time:formatNumTime(time))
|
||||||
end
|
end
|
||||||
-- if self.lastRefreshTime == nil then
|
if self.lastRefreshTime == nil then
|
||||||
-- self.lastRefreshTime = Time:getServerTime()
|
self.lastRefreshTime = Time:getServerTime()
|
||||||
-- elseif Time:getServerTime() - self.lastRefreshTime > GFunc.getConstIntValue("exp_drop_time") then
|
elseif Time:getServerTime() - self.lastRefreshTime > self.refreshIntervalTime then
|
||||||
-- if not self.canRefreshReward then
|
if not self.canRefreshReward then
|
||||||
-- return
|
return
|
||||||
-- end
|
end
|
||||||
-- self.canRefreshReward = false
|
self.canRefreshReward = false
|
||||||
-- self.lastRefreshTime = Time:getServerTime()
|
self.lastRefreshTime = Time:getServerTime()
|
||||||
-- ModuleManager.HangUpManager:getHangUpShowRewrad()
|
ModuleManager.IdleManager:getIdleShowRewrad()
|
||||||
-- end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleDropUI:addGetBtnRedPoint()
|
function IdleDropUI:addGetBtnRedPoint()
|
||||||
@ -156,23 +184,4 @@ function IdleDropUI:removeQuickBtnRedPoint()
|
|||||||
self.quickBtn:removeRedPoint()
|
self.quickBtn:removeRedPoint()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- function IdleDropUI:refreshBtn()
|
|
||||||
-- local uiMap = self.root:genAllChildren()
|
|
||||||
-- local btn = uiMap["idle_drop_ui.bg.btn_1"]
|
|
||||||
-- if self:canAd() or self:canDiamond() then
|
|
||||||
-- btn:addRedPoint(85, 36, 0.5)
|
|
||||||
-- else
|
|
||||||
-- btn:removeRedPoint()
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- function IdleDropUI:canAd()
|
|
||||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_1") > DataManager.HangUpData:getAdCount()
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- function IdleDropUI:canDiamond()
|
|
||||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_2") > DataManager.HangUpData:getDiamondCount()
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
|
||||||
return IdleDropUI
|
return IdleDropUI
|
||||||
@ -1,11 +1,5 @@
|
|||||||
local IdleQuickDropUI = class("IdleQuickDropUI", BaseUI)
|
local IdleQuickDropUI = class("IdleQuickDropUI", BaseUI)
|
||||||
|
|
||||||
local BTN_ICON = {
|
|
||||||
BLUE = "common_btn_3",
|
|
||||||
YELLOW = "common_btn_2",
|
|
||||||
GRAY = "common_btn_4"
|
|
||||||
}
|
|
||||||
|
|
||||||
function IdleQuickDropUI:isFullScreen()
|
function IdleQuickDropUI:isFullScreen()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -15,114 +9,44 @@ function IdleQuickDropUI:getPrefabPath()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function IdleQuickDropUI:ctor()
|
function IdleQuickDropUI:ctor()
|
||||||
-- self.list = ModuleManager.IdleManager:getRewardList()
|
self.rewardList = {}
|
||||||
self.list = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleQuickDropUI:onLoadRootComplete()
|
function IdleQuickDropUI:onLoadRootComplete()
|
||||||
self:_display()
|
|
||||||
self:_addListeners()
|
|
||||||
end
|
|
||||||
|
|
||||||
function IdleQuickDropUI:_display()
|
|
||||||
local uiMap = self.root:genAllChildren()
|
local uiMap = self.root:genAllChildren()
|
||||||
uiMap["idle_quick_drop_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_5))
|
self.uiMap = uiMap
|
||||||
uiMap["idle_quick_drop_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_6))
|
uiMap["idle_quick_drop_ui.mask"]:addClickListener(function()
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.FREE_DESC))
|
|
||||||
-- uiMap["idle_quick_drop_ui.bg.btn_2.desc"]:setText("X" .. GFunc.getConstIntValue("idle_drop_fast_cost"))
|
|
||||||
-- uiMap["idle_quick_drop_ui.bg.desc2"]:setText(I18N:getGlobalText(I18N.GlobalConst.BUY_VIT_DESC_2, GFunc.getConstIntValue("idle_drop_fast_times_2") - DataManager.HangUpData:getDiamondCount()))
|
|
||||||
|
|
||||||
-- if DataManager.MonthlyData:skipAd() then
|
|
||||||
-- uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setSprite(GConst.ATLAS_PATH.COMMON, "common_ad_1", function ()
|
|
||||||
-- uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
|
||||||
-- end)
|
|
||||||
-- else
|
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setSprite(GConst.ATLAS_PATH.COMMON, "common_ad", function ()
|
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
|
||||||
end)
|
|
||||||
-- end
|
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setImageGray(not self:canAd())
|
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_2.img"]:setImageGray(not self:canDiamond())
|
|
||||||
|
|
||||||
local btn1 = uiMap["idle_quick_drop_ui.bg.btn_1"]
|
|
||||||
|
|
||||||
local icon = BTN_ICON.BLUE
|
|
||||||
if not self:canAd() then
|
|
||||||
icon = BTN_ICON.GRAY
|
|
||||||
btn1:removeRedPoint()
|
|
||||||
else
|
|
||||||
btn1:addRedPoint(85, 36, 0.5)
|
|
||||||
end
|
|
||||||
btn1:setSprite(GConst.ATLAS_PATH.COMMON, icon)
|
|
||||||
|
|
||||||
icon = BTN_ICON.YELLOW
|
|
||||||
if not self:canDiamond() then
|
|
||||||
icon = BTN_ICON.GRAY
|
|
||||||
end
|
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_2"]:setSprite(GConst.ATLAS_PATH.COMMON, icon)
|
|
||||||
|
|
||||||
self:_refreshScrollRect()
|
|
||||||
end
|
|
||||||
|
|
||||||
function IdleQuickDropUI:_addListeners()
|
|
||||||
local uiMap = self.root:genAllChildren()
|
|
||||||
self.root:addClickListener(function()
|
|
||||||
self:closeUI()
|
self:closeUI()
|
||||||
end)
|
end)
|
||||||
|
uiMap["idle_quick_drop_ui.bg.title_text"]:setText("临时文本:快速挂机")
|
||||||
|
uiMap["idle_quick_drop_ui.bg.desc_tx"]:setText("临时文本:立刻获得6小时挂机奖励")
|
||||||
|
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_1"]:addClickListener(function()
|
self:initRewards()
|
||||||
if not self:canAd() then
|
self:initBtns()
|
||||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_7, "0"))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
BIReport:postAdClick(BIReport.ADS_CLICK_TYPE.AD_HANG_UP)
|
|
||||||
SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.AD_HANG_UP, function()
|
|
||||||
ModuleManager.IdleManager:getHangUpQuickRewrad(ModuleManager.IdleManager.HANG_UP_REWARD_TYPE.QUICK_AD)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
uiMap["idle_quick_drop_ui.bg.btn_2"]:addClickListener(function()
|
|
||||||
if not self:canDiamond() then
|
|
||||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_7, "0"))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
ModuleManager.IdleManager:getHangUpQuickRewrad(ModuleManager.IdleManager.HANG_UP_REWARD_TYPE.QUICK_DIAMOND)
|
|
||||||
end)
|
|
||||||
|
|
||||||
uiMap["idle_quick_drop_ui.bg.close_img"]:addClickListener(function()
|
|
||||||
self:closeUI()
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- self:bind(DataManager.IdleData, "isDirty", function()
|
|
||||||
-- self:_display()
|
|
||||||
-- end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleQuickDropUI:_refreshScrollRect()
|
function IdleQuickDropUI:initRewards()
|
||||||
if self.scrollRect then
|
self.scrollRect = self.uiMap["idle_quick_drop_ui.bg.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||||
self.scrollRect:clearCells()
|
|
||||||
self.scrollRect:refillCells(#self.list)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local uiMap = self.root:genAllChildren()
|
|
||||||
self.scrollRect = uiMap["idle_quick_drop_ui.bg.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
|
||||||
self.scrollRect:addInitCallback(function()
|
self.scrollRect:addInitCallback(function()
|
||||||
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
||||||
end)
|
end)
|
||||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||||
cell:refreshByConfig(self.list[index])
|
-- cell:refreshByConfig(self.list[index])
|
||||||
end)
|
end)
|
||||||
self.scrollRect:clearCells()
|
self.scrollRect:clearCells()
|
||||||
self.scrollRect:refillCells(#self.list)
|
self.scrollRect:refillCells(#self.rewardList)
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleQuickDropUI:canAd()
|
function IdleQuickDropUI:initBtns()
|
||||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_1") > DataManager.HangUpData:getAdCount()
|
self.uiMap["idle_quick_drop_ui.bg.ad_btn"]:addClickListener(function()
|
||||||
end
|
end)
|
||||||
|
self.uiMap["idle_quick_drop_ui.bg.ad_btn.text"]:setText("临时文本:免费")
|
||||||
function IdleQuickDropUI:canDiamond()
|
self.uiMap["idle_quick_drop_ui.bg.gem_btn"]:addClickListener(function()
|
||||||
-- return GFunc.getConstIntValue("idle_drop_fast_times_2") > DataManager.HangUpData:getDiamondCount()
|
end)
|
||||||
|
local gemBtnIcon = self.uiMap["idle_quick_drop_ui.bg.gem_btn.icon"]
|
||||||
|
local gemBtnTx = self.uiMap["idle_quick_drop_ui.bg.gem_btn.text"]
|
||||||
|
gemBtnTx:setText("50")
|
||||||
|
GFunc.centerImgAndTx(gemBtnIcon, gemBtnTx)
|
||||||
end
|
end
|
||||||
|
|
||||||
return IdleQuickDropUI
|
return IdleQuickDropUI
|
||||||
|
|||||||
@ -104,7 +104,6 @@ function MainComp:refreshChapter(force)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId()
|
local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId()
|
||||||
Logger.logHighlight("rewardChapterId " .. rewardChapterId)
|
|
||||||
if rewardChapterId > chapterId then
|
if rewardChapterId > chapterId then
|
||||||
rewardChapterId = chapterId
|
rewardChapterId = chapterId
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,19 +1,67 @@
|
|||||||
local IdleData = class("IdleData", BaseData)
|
local IdleData = class("IdleData", BaseData)
|
||||||
|
|
||||||
function IdleData:ctor()
|
function IdleData:ctor()
|
||||||
|
self.data.dirty = false
|
||||||
|
self.idleRewardMap = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function IdleData:init(data)
|
function IdleData:init(data)
|
||||||
data = data or GConst.EMPTY_TABLE
|
data = data or GConst.EMPTY_TABLE
|
||||||
self.data.dropTime = (data.gold_drop_time or 0) // 1000
|
self.data.dropTime = (data.claim_at or 0) // 1000
|
||||||
self.data.adCount = data.ad_count or 0
|
self.data.adCount = data.ad_count or 0
|
||||||
self.data.energyCount = data.energy_count or 0
|
self.data.energyCount = data.energy_count or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IdleData:onGetIdleShowRewrad(data)
|
||||||
|
data = data or GConst.EMPTY_TABLE
|
||||||
|
self.data.dropTime = (data.claim_at or 0) // 1000
|
||||||
|
self.data.adCount = data.ad_count or 0
|
||||||
|
self.data.energyCount = data.energy_count or 0
|
||||||
|
self:updateIdleRewards(data.items)
|
||||||
|
self:markDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleData:updateIdleRewards(items)
|
||||||
|
if items == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for k, v in pairs(self.idleRewardMap) do
|
||||||
|
self.idleRewardMap[k].num = 0
|
||||||
|
end
|
||||||
|
for id, num in pairs(items) do
|
||||||
|
if self.idleRewardMap[id] then
|
||||||
|
self.idleRewardMap[id].num = num
|
||||||
|
else
|
||||||
|
self.idleRewardMap[id] = {
|
||||||
|
id = id,
|
||||||
|
num = num,
|
||||||
|
type = GConst.REWARD_TYPE.ITEM
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:markDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleData:getIdleRewards()
|
||||||
|
return self.idleRewardMap
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleData:markDirty()
|
||||||
|
self.data.dirty = not self.data.dirty
|
||||||
|
end
|
||||||
|
|
||||||
function IdleData:getLastDropTime()
|
function IdleData:getLastDropTime()
|
||||||
return self.data.dropTime
|
return self.data.dropTime
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IdleData:onGetIdleRewrad(time)
|
||||||
|
self.data.dropTime = time // 1000
|
||||||
|
for k, v in pairs(self.idleRewardMap) do
|
||||||
|
self.idleRewardMap[k].num = 0
|
||||||
|
end
|
||||||
|
self:markDirty()
|
||||||
|
end
|
||||||
|
|
||||||
function IdleData:getIsOpen()
|
function IdleData:getIsOpen()
|
||||||
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.IDLE_DROP, true)
|
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.IDLE_DROP, true)
|
||||||
end
|
end
|
||||||
@ -51,4 +99,22 @@ function IdleData:getExpPerHour()
|
|||||||
return math.floor(expDrop * 3600 / time)
|
return math.floor(expDrop * 3600 / time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IdleData:getQuickIdleMaxAdTimes()
|
||||||
|
if self.quickIdleMaxAdTimes == nil then
|
||||||
|
self.quickIdleMaxAdTimes = ConfigManager:getConfig("const")["idle_drop_fast_times_1"].value
|
||||||
|
end
|
||||||
|
return self.quickIdleMaxAdTimes
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleData:getQuickIdleMaxVitTimes()
|
||||||
|
if self.quickIdleMaxVitTimes == nil then
|
||||||
|
self.quickIdleMaxVitTimes = ConfigManager:getConfig("const")["idle_drop_fast_times_2"].value
|
||||||
|
end
|
||||||
|
return self.quickIdleMaxVitTimes
|
||||||
|
end
|
||||||
|
|
||||||
|
function IdleData:getQuickIdleTimes()
|
||||||
|
return self:getQuickIdleMaxAdTimes() + self:getQuickIdleMaxVitTimes() - self.data.adCount - self.data.energyCount
|
||||||
|
end
|
||||||
|
|
||||||
return IdleData
|
return IdleData
|
||||||
Loading…
x
Reference in New Issue
Block a user