Merge branch 'dev' of git.juzugame.com:b6-client/b6-lua into dev
# Conflicts: # lua/app/common/pay_manager.lua
This commit is contained in:
commit
602cd716df
@ -84,6 +84,7 @@ BIReport.ITEM_GET_TYPE = {
|
||||
PLAYER_LV_UP = "PlayerLvUp",
|
||||
GOLD_PIG = "GoldPig",
|
||||
BATTLE_SKILL_REFRESH = "BattleSkillRefresh",
|
||||
LEVEL_FUND = "LevelFund"
|
||||
}
|
||||
|
||||
BIReport.ADS_CLICK_TYPE = {
|
||||
@ -133,6 +134,7 @@ BIReport.GIFT_TYPE = {
|
||||
GOLD_PIG = "GoldPig",
|
||||
MALL_TREASURE = "MallTreasure",
|
||||
ACT_CHAPTER_STORE = "ActChapterStore",
|
||||
LEVEL_FUND = "LevelFund",
|
||||
}
|
||||
|
||||
BIReport.COIN_TYPE = {
|
||||
@ -353,11 +355,7 @@ end
|
||||
|
||||
-- 游戏退出
|
||||
function BIReport:postGameExit()
|
||||
local nowTime = Time:getServerTime()
|
||||
local args = {}
|
||||
-- if DataManager then
|
||||
-- args.duration = nowTime - DataManager:getLoginTime()
|
||||
-- end
|
||||
self:report(EVENT_NAME_EXIT, args)
|
||||
end
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ function DataManager:init()
|
||||
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
||||
self:initManager("DailyTaskData", "app/userdata/task/daily_task_data")
|
||||
self:initManager("IdleData", "app/userdata/idle/idle_data")
|
||||
self:initManager("FundData", "app/userdata/fund/fund_data")
|
||||
-- self:initManager("SevenDayData", "app/userdata/activity/seven_day/seven_day_data")
|
||||
self:initManager("ShopData", "app/userdata/shop/shop_data")
|
||||
self:initManager("SummonData", "app/userdata/summon/summon_data")
|
||||
@ -90,6 +91,7 @@ function DataManager:clear()
|
||||
self.BountyData:clear()
|
||||
self.DailyTaskData:clear()
|
||||
self.IdleData:clear()
|
||||
self.FundData:clear()
|
||||
-- self.SevenDayData:clear()
|
||||
self.ShopData:clear()
|
||||
self.SummonData:clear()
|
||||
@ -132,18 +134,14 @@ function DataManager:initWithServerData(data)
|
||||
self.ShopData:initCommonDailyGoldGift(data.mall_idle and data.mall_idle.ad_count) -- 常驻金币礼包
|
||||
self.ShopData:initGrowUpGift(data.act_grow_up_gift) -- 成长礼包
|
||||
self.ShopData:initLevelUpGift(data.act_level_up_gift) -- 助力礼包
|
||||
self.SummonData:init(data.summon, true)
|
||||
self.SummonData:init(data.summon, true)
|
||||
-- 成长基金要在ShopData和PlayerDataBagData还有之后初始化,依赖这些数据
|
||||
self.FundData:init(data.fund)
|
||||
|
||||
self:scheduleGlobal()
|
||||
self:checkDataBind()
|
||||
end
|
||||
|
||||
function DataManager:onServerTimeBack(serverTime, loginCount, loginTime)
|
||||
self.loginCount = loginCount or 1
|
||||
self.loginTime = loginTime or Time:getServerTime()
|
||||
self:scheduleGlobal()
|
||||
end
|
||||
|
||||
-- 是否首次登录
|
||||
function DataManager:getIsFirstLogin()
|
||||
local nowTime = Time:getServerTime()
|
||||
@ -161,10 +159,6 @@ function DataManager:getIsInitWithServer()
|
||||
return self.initWithServer
|
||||
end
|
||||
|
||||
function DataManager:getLoginTime()
|
||||
return self.loginTime or 0
|
||||
end
|
||||
|
||||
function DataManager:registerDataCd(dataName)
|
||||
if not dataName then
|
||||
return
|
||||
@ -254,11 +248,6 @@ function DataManager:scheduleGlobal()
|
||||
end, 1)
|
||||
end
|
||||
|
||||
-- 获取登录天数
|
||||
function DataManager:getLoginCount()
|
||||
return self.loginCount or 1
|
||||
end
|
||||
|
||||
function DataManager:getSignInfo()
|
||||
local nowTime = Time:getServerTime()
|
||||
local lastSignTime = self.signInfo.latest_at // 1000
|
||||
|
||||
@ -27,6 +27,8 @@ local MODULE_PATHS = {
|
||||
IdleManager = "app/module/idle/idle_manager",
|
||||
-- 活动
|
||||
-- SevenDayManager = "app/module/activity/seven_day/seven_day_manager",
|
||||
-- 基金
|
||||
FundManager = "app/module/fund/fund_manager",
|
||||
-- 设置
|
||||
GameSettingManager = "app/module/game_setting/game_setting_manager",
|
||||
-- 活动
|
||||
@ -57,6 +59,7 @@ ModuleManager.MODULE_KEY = {
|
||||
IDLE_DROP = "idle_drop",
|
||||
MALL = "mall", -- 商城
|
||||
MALL_DAILY = "mall_daily", -- 每日商城
|
||||
FUND = "act_level_gift" -- 成长基金
|
||||
}
|
||||
|
||||
local _moduleMgrs = {}
|
||||
|
||||
@ -15,6 +15,7 @@ PayManager.PURCHARSE_ACT_TYPE = {
|
||||
COIN_GIFT = 2,
|
||||
BEGINNER_GIFT = 4,
|
||||
LEVEL_UP_GIFT = 5,
|
||||
LEVEL_FUND = 6,
|
||||
BOUNTY = 7,
|
||||
}
|
||||
|
||||
@ -31,6 +32,7 @@ PayManager.BI_ITEM_GET_TYPE = {
|
||||
[PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = BIReport.ITEM_GET_TYPE.COIN_GIFT,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.ITEM_GET_TYPE.BEGINNER_GIFT,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = BIReport.ITEM_GET_TYPE.LEVEL_UP_GIFT,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_FUND] = BIReport.ITEM_GET_TYPE.LEVEL_FUND,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.ITEM_GET_TYPE.BOUNTY,
|
||||
},
|
||||
[PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.ITEM_GET_TYPE.GOLD_PIG,
|
||||
@ -44,6 +46,7 @@ PayManager.BI_GIFT_TYPE = {
|
||||
[PayManager.PURCHARSE_ACT_TYPE.COIN_GIFT] = BIReport.GIFT_TYPE.COIN_GIFT,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.BEGINNER_GIFT] = BIReport.GIFT_TYPE.BEGINNER_GIFT,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_UP_GIFT] = BIReport.GIFT_TYPE.LEVEL_UP_GIFT,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.LEVEL_FUND] = BIReport.GIFT_TYPE.LEVEL_FUND,
|
||||
[PayManager.PURCHARSE_ACT_TYPE.BOUNTY] = BIReport.GIFT_TYPE.BOUNTY,
|
||||
},
|
||||
[PayManager.PURCHARSE_TYPE.ACT_GOLD_PIG] = BIReport.GIFT_TYPE.GOLD_PIG,
|
||||
|
||||
@ -187,6 +187,7 @@ GConst.ATLAS_PATH = {
|
||||
ICON_TASK = "assets/arts/atlas/icon/task.asset",
|
||||
SHOP = "assets/arts/atlas/ui/shop.asset",
|
||||
HERO = "assets/arts/atlas/ui/hero.asset",
|
||||
FUND = "assets/arts/atlas/ui/fund.asset",
|
||||
}
|
||||
|
||||
GConst.TOUCH_EVENT = {
|
||||
|
||||
@ -32,9 +32,9 @@ function CommerceManager:onBuyBitFinish(data)
|
||||
DataManager.PlayerData:addVitGemBuyCount()
|
||||
else -- 激励视频
|
||||
DataManager.PlayerData:addVitAdBuyCount()
|
||||
if data.rewards then
|
||||
GFunc.showRewardBox(data.rewards)
|
||||
end
|
||||
end
|
||||
if data.rewards then
|
||||
GFunc.showRewardBox(data.rewards)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
8
lua/app/module/fund.meta
Normal file
8
lua/app/module/fund.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 023f6b315dd3ad34a9752710714b85ef
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
lua/app/module/fund/fund_manager.lua
Normal file
14
lua/app/module/fund/fund_manager.lua
Normal file
@ -0,0 +1,14 @@
|
||||
local FundManager = class("FundManager", BaseModule)
|
||||
|
||||
function FundManager:showLevelFundUI()
|
||||
UIManager:showUI("app/ui/fund/level_fund_ui")
|
||||
end
|
||||
|
||||
function FundManager:buyLevelFund(id)
|
||||
if not DataManager.FundData:getIsOpen() then
|
||||
return
|
||||
end
|
||||
PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
||||
end
|
||||
|
||||
return FundManager
|
||||
10
lua/app/module/fund/fund_manager.lua.meta
Normal file
10
lua/app/module/fund/fund_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d492995e6c467f4e8f3b1e712b3ad4b
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -24,6 +24,7 @@ MainCityConst.LEFT_SIDE_BARS = {
|
||||
|
||||
MainCityConst.RIGHT_SIDE_BARS = {
|
||||
"app/ui/main_city/cell/side_bar_gold_pig_cell",
|
||||
"app/ui/main_city/cell/side_bar_level_fund_cell",
|
||||
}
|
||||
|
||||
return MainCityConst
|
||||
@ -75,6 +75,7 @@ function BuyVitUI:onRefresh()
|
||||
self.numTx1:setVisible(false)
|
||||
end
|
||||
|
||||
GFunc.setAdsSprite(self.iconImg2, false)
|
||||
if adBuyCount < maxAdBuy then
|
||||
self.buyBtn2:setTouchEnable(true)
|
||||
self.checkImg2:setVisible(false)
|
||||
|
||||
8
lua/app/ui/fund.meta
Normal file
8
lua/app/ui/fund.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a57b4c2e6887d4d45a6d38a5bd87b510
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
lua/app/ui/fund/cell.meta
Normal file
8
lua/app/ui/fund/cell.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5ff8158759657748a1dec5f61a851c0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
lua/app/ui/fund/cell/level_fund_cell.lua
Normal file
86
lua/app/ui/fund/cell/level_fund_cell.lua
Normal file
@ -0,0 +1,86 @@
|
||||
local LevelFundCell = class("LevelFundCell", BaseCell)
|
||||
|
||||
local Fund_REWARD_CELL = "app/ui/fund/cell/level_fund_reward_cell"
|
||||
|
||||
function LevelFundCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
local width = GConst.UI_SCREEN_WIDTH
|
||||
|
||||
self.fundRewardCell1 = uiMap["level_fund_cell.fund_reward_cell_1"]:addLuaComponent(Fund_REWARD_CELL)
|
||||
self.fundRewardCell1:setAnchoredPositionX(-width/3)
|
||||
self.fundRewardCell1:addClickListener(function()
|
||||
if self.fundId == nil then
|
||||
return
|
||||
end
|
||||
local iCslaimed = DataManager.FundData:getIsClaimedBase(self.fundId)
|
||||
local needLevel = DataManager.FundData:getNeedLevel(self.fundId)
|
||||
local playerLevel = DataManager.PlayerData:getLv()
|
||||
if not iCslaimed and playerLevel >= needLevel then
|
||||
else
|
||||
local freeReward = DataManager.FundData:getFreeFundRewards(self.fundId)
|
||||
local reward = freeReward and freeReward[1]
|
||||
if reward then
|
||||
ModuleManager.TipsManager:showRewardTips(reward.id, reward.type, self.fundRewardCell1:getBaseObject())
|
||||
end
|
||||
end
|
||||
end)
|
||||
self.fundRewardCell2 = uiMap["level_fund_cell.fund_reward_cell_2"]:addLuaComponent(Fund_REWARD_CELL)
|
||||
self.fundRewardCell2:addClickListener(function()
|
||||
if self.fundId == nil then
|
||||
return
|
||||
end
|
||||
local iCslaimed = DataManager.FundData:getIsClaimedBase(self.fundId)
|
||||
local needLevel = DataManager.FundData:getNeedLevel(self.fundId)
|
||||
local playerLevel = DataManager.PlayerData:getLv()
|
||||
if not iCslaimed and playerLevel >= needLevel and DataManager.FundData:getIsBoughtBase(self.fundId) then
|
||||
else
|
||||
local baseReward = DataManager.FundData:getBaseFundRewards(self.fundId)
|
||||
local reward = baseReward and baseReward[1]
|
||||
if reward then
|
||||
ModuleManager.TipsManager:showRewardTips(reward.id, reward.type, self.fundRewardCell2:getBaseObject())
|
||||
end
|
||||
end
|
||||
end)
|
||||
self.fundRewardCell3 = uiMap["level_fund_cell.fund_reward_cell_3"]:addLuaComponent(Fund_REWARD_CELL)
|
||||
self.fundRewardCell3:addClickListener(function()
|
||||
if self.fundId == nil then
|
||||
return
|
||||
end
|
||||
local iCslaimed = DataManager.FundData:getIsClaimedAdvance(self.fundId)
|
||||
local needLevel = DataManager.FundData:getNeedLevel(self.fundId)
|
||||
local playerLevel = DataManager.PlayerData:getLv()
|
||||
if not iCslaimed and playerLevel >= needLevel and DataManager.FundData:getIsBoughtAdvance(self.fundId) then
|
||||
else
|
||||
local advanceReward = DataManager.FundData:getAdvanceFundRewards(self.fundId)
|
||||
local reward = advanceReward and advanceReward[1]
|
||||
if reward then
|
||||
ModuleManager.TipsManager:showRewardTips(reward.id, reward.type, self.fundRewardCell3:getBaseObject())
|
||||
end
|
||||
end
|
||||
end)
|
||||
self.fundRewardCell3:setAnchoredPositionX(width/3)
|
||||
self.levelBg = uiMap["level_fund_cell.lv_bg"]
|
||||
self.levelBg:setAnchoredPositionX(-width/6)
|
||||
self.levelGrayImg = uiMap["level_fund_cell.lv_bg.gray"]
|
||||
self.levelTx = uiMap["level_fund_cell.lv_bg.tx"]
|
||||
end
|
||||
|
||||
function LevelFundCell:refresh(id)
|
||||
self.fundId = id
|
||||
local FundData = DataManager.FundData
|
||||
local needLevel = DataManager.FundData:getNeedLevel(id)
|
||||
local playerLevel = DataManager.PlayerData:getLv()
|
||||
local isActive = playerLevel >= needLevel
|
||||
self.levelGrayImg:setVisible(not isActive)
|
||||
self.levelTx:setText(GFunc.intToString(needLevel))
|
||||
local freeReward, baseReward, advanceReward = FundData:getAllStepFundRewards(id)
|
||||
self.fundRewardCell1:refresh(freeReward[1], isActive and 1 or 0, false, FundData:getIsClaimedFree(id))
|
||||
self.fundRewardCell2:refresh(baseReward[1], isActive and 2 or 0, not FundData:getIsBoughtBase(id), FundData:getIsClaimedBase(id))
|
||||
self.fundRewardCell3:refresh(advanceReward[1], isActive and 3 or 0, not FundData:getIsBoughtAdvance(id), FundData:getIsClaimedAdvance(id))
|
||||
end
|
||||
|
||||
function LevelFundCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
return LevelFundCell
|
||||
10
lua/app/ui/fund/cell/level_fund_cell.lua.meta
Normal file
10
lua/app/ui/fund/cell/level_fund_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f29b4252c5aeb64abafe246ea6c16e5
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
90
lua/app/ui/fund/cell/level_fund_reward_cell.lua
Normal file
90
lua/app/ui/fund/cell/level_fund_reward_cell.lua
Normal file
@ -0,0 +1,90 @@
|
||||
local LevelFundRewardCell = class("LevelFundRewardCell", BaseCell)
|
||||
|
||||
function LevelFundRewardCell:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.bg = uiMap["fund_reward_cell.bg"]
|
||||
self.icon = uiMap["fund_reward_cell.icon"]
|
||||
self.numTx = uiMap["fund_reward_cell.num"]
|
||||
self.check = uiMap["fund_reward_cell.check"]
|
||||
self.fragment = uiMap["fund_reward_cell.fragment"]
|
||||
self.light = uiMap["fund_reward_cell.light"]
|
||||
self.lock = uiMap["fund_reward_cell.lock"]
|
||||
self.baseObject:addClickListener(function()
|
||||
if self.clickCallback then
|
||||
self.clickCallback()
|
||||
elseif self.rewardId ~= nil then
|
||||
ModuleManager.TipsManager:showRewardTips(self.rewardId, self.rewardType, self.baseObject)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function LevelFundRewardCell:refresh(reward, step, isLock, showCheck)
|
||||
if step == 0 then
|
||||
self.bg:setSprite(GConst.ATLAS_PATH.FUND, "fund_bg_5")
|
||||
elseif step == 1 then
|
||||
self.bg:setSprite(GConst.ATLAS_PATH.FUND, "fund_bg_2")
|
||||
elseif step == 2 then
|
||||
self.bg:setSprite(GConst.ATLAS_PATH.FUND, "fund_bg_3")
|
||||
else
|
||||
self.bg:setSprite(GConst.ATLAS_PATH.FUND, "fund_bg_4")
|
||||
end
|
||||
if isLock then
|
||||
self.lock:setVisible(true)
|
||||
self.light:setVisible(false)
|
||||
else
|
||||
self.lock:setVisible(false)
|
||||
if step == 0 then
|
||||
self.light:setVisible(false)
|
||||
else
|
||||
self.light:setVisible(true)
|
||||
end
|
||||
end
|
||||
self.check:setVisible(showCheck == true)
|
||||
if reward.type == GConst.REWARD_TYPE.ITEM then
|
||||
self:_refreshItem(reward)
|
||||
self.rewardId = reward.id
|
||||
self.rewardType = reward.type
|
||||
else
|
||||
self.rewardId = nil
|
||||
end
|
||||
end
|
||||
|
||||
function LevelFundRewardCell:_refreshItem(item)
|
||||
local info = ConfigManager:getConfig("item")[item.id]
|
||||
if info == nil then
|
||||
return
|
||||
end
|
||||
self.numTx:setText(item.count or item.num)
|
||||
if info.type == GConst.ItemConst.ITEM_TYPE.HERO_FRAGMENT then
|
||||
local heroInfo = ConfigManager:getConfig("hero")[info.parameter]
|
||||
if heroInfo then
|
||||
self.icon:setLocalScale(0.86, 0.86, 0.86)
|
||||
self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, heroInfo.icon)
|
||||
else
|
||||
self.icon:setSprite(GConst.ATLAS_PATH.COMMON, "common_alpha")
|
||||
end
|
||||
self.fragment:setVisible(true)
|
||||
else
|
||||
self.icon:setLocalScale(1, 1, 1)
|
||||
self.icon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon)
|
||||
self.fragment:setVisible(false)
|
||||
end
|
||||
end
|
||||
|
||||
function LevelFundRewardCell:setVisible(visible)
|
||||
self.baseObject:setActive(visible)
|
||||
end
|
||||
|
||||
function LevelFundRewardCell:setAnchoredPositionX(x)
|
||||
self.baseObject:setAnchoredPositionX(x)
|
||||
end
|
||||
|
||||
function LevelFundRewardCell:setTouchEnable(enable)
|
||||
self.baseObject:setTouchEnable(enable)
|
||||
end
|
||||
|
||||
function LevelFundRewardCell:addClickListener(callback)
|
||||
self.clickCallback = callback
|
||||
end
|
||||
|
||||
return LevelFundRewardCell
|
||||
10
lua/app/ui/fund/cell/level_fund_reward_cell.lua.meta
Normal file
10
lua/app/ui/fund/cell/level_fund_reward_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6e1fcafc8ff9f4459edefaa8e079e3e
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
194
lua/app/ui/fund/level_fund_ui.lua
Normal file
194
lua/app/ui/fund/level_fund_ui.lua
Normal file
@ -0,0 +1,194 @@
|
||||
local LevelFundUI = class("LevelFundUI", BaseUI)
|
||||
|
||||
function LevelFundUI:isFullScreen()
|
||||
return true
|
||||
end
|
||||
|
||||
function LevelFundUI:getCurrencyParams()
|
||||
if self.currencyParams == nil then
|
||||
self.currencyParams = {
|
||||
itemIds = {
|
||||
GConst.ItemConst.ITEM_ID_GOLD,
|
||||
GConst.ItemConst.ITEM_ID_GEM,
|
||||
GConst.ItemConst.ITEM_ID_VIT,
|
||||
},
|
||||
showType = GConst.CURRENCY_TYPE.HORIZONTAL
|
||||
}
|
||||
end
|
||||
return self.currencyParams
|
||||
end
|
||||
|
||||
function LevelFundUI:getPrefabPath()
|
||||
return "assets/prefabs/ui/fund/level_fund_ui.prefab"
|
||||
end
|
||||
|
||||
function LevelFundUI:ctor()
|
||||
self.levelInfoList = DataManager.FundData:getCurrLevelInfoList()
|
||||
local playerLevel = DataManager.PlayerData:getLv()
|
||||
local cfg = ConfigManager:getConfig("act_level_fund")
|
||||
for k, v in ipairs(self.levelInfoList) do
|
||||
if cfg[v] then
|
||||
if playerLevel < cfg[v].level then
|
||||
self.inactiveIndex = k
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.inactiveIndex == nil then
|
||||
self.inactiveIndex = #self.levelInfoList
|
||||
end
|
||||
end
|
||||
|
||||
function LevelFundUI:onClose()
|
||||
if self.originTitleBgHeight then
|
||||
self.uiMap["level_fund_ui.title_img.bg"]:setSizeDeltaY(self.originTitleBgHeight)
|
||||
end
|
||||
end
|
||||
|
||||
function LevelFundUI:onLoadRootComplete()
|
||||
self.uiMap = self.root:genAllChildren()
|
||||
|
||||
self.uiMap["level_fund_ui.down.close_btn"]:addClickListener(function()
|
||||
self:closeUI()
|
||||
end)
|
||||
|
||||
self:initTitle()
|
||||
self:initPayBtns()
|
||||
self:initRewards()
|
||||
self:bindData()
|
||||
end
|
||||
|
||||
function LevelFundUI:initTitle()
|
||||
self.uiMap["level_fund_ui.title_img.title_tx"]:setText("临时文本:购买成长基金后,可通过提升等级获得钻石。\n多档基金可同时购买")
|
||||
local height = self.uiMap["level_fund_ui.title_img.title_tx"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredHeight + 58
|
||||
self.originTitleBgHeight = self.uiMap["level_fund_ui.title_img.bg"]:fastGetSizeDeltaY()
|
||||
if height < self.originTitleBgHeight then
|
||||
height = self.originTitleBgHeight
|
||||
end
|
||||
self.uiMap["level_fund_ui.title_img.bg"]:setSizeDeltaY(height)
|
||||
end
|
||||
|
||||
function LevelFundUI:initPayBtns()
|
||||
local width = GConst.UI_SCREEN_WIDTH
|
||||
|
||||
local freeTx = self.uiMap["level_fund_ui.title_bg_2.free_tx"]
|
||||
freeTx:setText(I18N:getGlobalText(I18N.GlobalConst.STR_FREE))
|
||||
freeTx:setAnchoredPositionX(-width/3)
|
||||
|
||||
self.payBtn1 = self.uiMap["level_fund_ui.title_bg_2.btn_1"]
|
||||
self.payBtn1:addClickListener(function()
|
||||
ModuleManager.FundManager:buyLevelFund(DataManager.FundData:getFundBaseId())
|
||||
end)
|
||||
self.payBtnTx1 = self.uiMap["level_fund_ui.title_bg_2.btn_1.text"]
|
||||
|
||||
self.payBtn2 = self.uiMap["level_fund_ui.title_bg_2.btn_2"]
|
||||
self.payBtn2:setAnchoredPositionX(width/3)
|
||||
self.payBtn2:addClickListener(function()
|
||||
ModuleManager.FundManager:buyLevelFund(DataManager.FundData:getFundAdvanceId())
|
||||
end)
|
||||
self.payBtnTx2 = self.uiMap["level_fund_ui.title_bg_2.btn_2.text"]
|
||||
end
|
||||
|
||||
function LevelFundUI:initRewards()
|
||||
self.scrollRect = self.uiMap["level_fund_ui.scrollrect"]
|
||||
self.scrollRectComp = self.scrollRect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
self.scrollRectComp:addInitCallback(function()
|
||||
return "app/ui/fund/cell/level_fund_cell"
|
||||
end)
|
||||
self.scrollRectComp:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.levelInfoList[index])
|
||||
end)
|
||||
self.scrollRectComp:clearCells()
|
||||
self.scrollRectComp:setTotalCount(0)
|
||||
|
||||
self.progressBg = self.uiMap["level_fund_ui.scrollrect.viewport.content.progress_bg"]
|
||||
self.progressComp = self.uiMap["level_fund_ui.scrollrect.viewport.content.progress_bg.progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.grayImg = self.uiMap["level_fund_ui.scrollrect.viewport.content.gray_img"]
|
||||
self.lineImg = self.uiMap["level_fund_ui.scrollrect.viewport.content.line_img"]
|
||||
self.verticalLine1 = self.uiMap["level_fund_ui.scrollrect.viewport.content.vertical_line_1"]
|
||||
self.verticalLine2 = self.uiMap["level_fund_ui.scrollrect.viewport.content.vertical_line_2"]
|
||||
end
|
||||
|
||||
function LevelFundUI:bindData()
|
||||
self:bind(DataManager.FundData, "dirty", function()
|
||||
self:refreshRewards()
|
||||
end)
|
||||
self:bind(DataManager.FundData, "purcharseDirty", function()
|
||||
self:onRefresh()
|
||||
end)
|
||||
end
|
||||
|
||||
function LevelFundUI:onRefresh()
|
||||
self:refreshTitle()
|
||||
self:refreshPayBtns()
|
||||
self:refreshRewards()
|
||||
end
|
||||
|
||||
function LevelFundUI:refreshTitle()
|
||||
local fundLevel = DataManager.FundData:getFundLevel()
|
||||
if fundLevel == 1 then
|
||||
self.uiMap["level_fund_ui.title_img"]:setTexture("assets/arts/textures/background/fund/fund_bg_1.png")
|
||||
elseif fundLevel == 2 then
|
||||
self.uiMap["level_fund_ui.title_img"]:setTexture("assets/arts/textures/background/fund/fund_bg_2.png")
|
||||
end
|
||||
end
|
||||
|
||||
function LevelFundUI:refreshPayBtns()
|
||||
if not DataManager.FundData:getIsBoughtBase() then
|
||||
local rechargeId = DataManager.FundData:getCurrLevelBaseRechargeId()
|
||||
self.payBtnTx1:setText(GFunc.getFormatPrice(rechargeId))
|
||||
self.payBtn1:setTouchEnable(true)
|
||||
else
|
||||
self.payBtnTx1:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_ACTIVE))
|
||||
self.payBtn1:setTouchEnable(false)
|
||||
end
|
||||
if not DataManager.FundData:getIsBoughtAdvance() then
|
||||
local rechargeId = DataManager.FundData:getCurrLevelAdvanceRechargeId()
|
||||
self.payBtnTx2:setText(GFunc.getFormatPrice(rechargeId))
|
||||
self.payBtn2:setTouchEnable(true)
|
||||
else
|
||||
self.payBtnTx2:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_ACTIVE))
|
||||
self.payBtn2:setTouchEnable(false)
|
||||
end
|
||||
end
|
||||
|
||||
function LevelFundUI:refreshRewards()
|
||||
local count = #self.levelInfoList
|
||||
if self.scrollRectComp:getTotalCount() <= 0 then
|
||||
self.scrollRectComp:refillCells(count)
|
||||
local level = DataManager.FundData:getMinUnclaimedRewardIndex()
|
||||
if level > 1 then
|
||||
self:scrollToIndex(level)
|
||||
end
|
||||
elseif self.scrollRectComp:getTotalCount() ~= count then -- 打开界面的时候定位到当前可领取的最低等级奖励,如果没有则定位到当前等级
|
||||
self.scrollRectComp:clearCells()
|
||||
self.scrollRectComp:refillCells(count)
|
||||
else
|
||||
self.scrollRectComp:updateAllCell()
|
||||
end
|
||||
|
||||
local topRecoveryOffset = self.scrollRectComp:getTopRecoveryOffset()
|
||||
local contentWidth = self.scrollRect:getRectWidth()
|
||||
local cellWidth = self.scrollRectComp:getCellHeight()
|
||||
self.progressBg:setAnchoredPosition(contentWidth/3, -topRecoveryOffset - cellWidth/2)
|
||||
self.progressBg:setSizeDeltaX(cellWidth*(count - 1))
|
||||
local percent = (self.inactiveIndex - 2) / (count - 1)
|
||||
if percent < 0 then
|
||||
percent = 0
|
||||
end
|
||||
self.progressComp.value = percent
|
||||
|
||||
self.grayImg:setAnchoredPositionY(-topRecoveryOffset - (self.inactiveIndex - 1)*cellWidth)
|
||||
self.grayImg:setSizeDeltaY(cellWidth*count + GConst.UI_SCREEN_HEIGHT)
|
||||
|
||||
self.lineImg:setAnchoredPositionY(-topRecoveryOffset - (self.inactiveIndex - 1)*cellWidth)
|
||||
|
||||
local lineHeight = topRecoveryOffset + cellWidth*count + GConst.UI_SCREEN_HEIGHT*2
|
||||
self.verticalLine1:setAnchoredPositionX(contentWidth/3)
|
||||
self.verticalLine1:setSizeDeltaY(lineHeight)
|
||||
|
||||
self.verticalLine2:setAnchoredPositionX(contentWidth*2/3)
|
||||
self.verticalLine2:setSizeDeltaY(lineHeight)
|
||||
end
|
||||
|
||||
return LevelFundUI
|
||||
10
lua/app/ui/fund/level_fund_ui.lua.meta
Normal file
10
lua/app/ui/fund/level_fund_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3380bc95e342186458dd56f3cdd4e4f0
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
20
lua/app/ui/main_city/cell/side_bar_level_fund_cell.lua
Normal file
20
lua/app/ui/main_city/cell/side_bar_level_fund_cell.lua
Normal file
@ -0,0 +1,20 @@
|
||||
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
|
||||
local SideBarLevelFundCell = class("SideBarLevelFundCell", SideBarBaseCellComp)
|
||||
|
||||
function SideBarLevelFundCell:getIsOpen()
|
||||
return DataManager.FundData:getIsOpen()
|
||||
end
|
||||
|
||||
function SideBarLevelFundCell:getIconRes()
|
||||
return "main_btn_fund"
|
||||
end
|
||||
|
||||
function SideBarLevelFundCell:onClick()
|
||||
ModuleManager.FundManager:showLevelFundUI()
|
||||
end
|
||||
|
||||
function SideBarLevelFundCell:getIsShowRedPoint()
|
||||
return DataManager.FundData:getIfCanClaimReward()
|
||||
end
|
||||
|
||||
return SideBarLevelFundCell
|
||||
10
lua/app/ui/main_city/cell/side_bar_level_fund_cell.lua.meta
Normal file
10
lua/app/ui/main_city/cell/side_bar_level_fund_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14a96472379bd3b45a9544e750fa0f10
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -37,8 +37,9 @@ function MainCityUI:getCurrencyParams()
|
||||
table.remove(self.currencyParams.itemIds)
|
||||
end
|
||||
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
|
||||
self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_VIT
|
||||
self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GOLD
|
||||
self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_GOLD
|
||||
self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GEM
|
||||
self.currencyParams.itemIds[3] = GConst.ItemConst.ITEM_ID_VIT
|
||||
elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then
|
||||
self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_VIT
|
||||
self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GOLD
|
||||
|
||||
8
lua/app/userdata/fund.meta
Normal file
8
lua/app/userdata/fund.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bad92e9bd570734b92cd8ea0746ba0d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
249
lua/app/userdata/fund/fund_data.lua
Normal file
249
lua/app/userdata/fund/fund_data.lua
Normal file
@ -0,0 +1,249 @@
|
||||
local FundData = class("FundData", BaseData)
|
||||
|
||||
local ACT_GIFT_FUND_BASE_ID_1 = 60202
|
||||
local ACT_GIFT_FUND_BASE_ID_2 = 60102
|
||||
local ACT_GIFT_FUND_ADVANCE_ID_1 = 60402
|
||||
local ACT_GIFT_FUND_ADVANCE_ID_2 = 60302
|
||||
|
||||
function FundData:ctor()
|
||||
self.data.purcharseDirty = false
|
||||
self.data.dirty = false
|
||||
end
|
||||
|
||||
function FundData:init(data)
|
||||
data = data or GConst.EMPTY_TABLE
|
||||
|
||||
self.freeClaimed = {}
|
||||
self.freeClaimedCount = 0
|
||||
if data.free_awarded then
|
||||
for _, v in ipairs(data.free_awarded) do
|
||||
self.freeClaimed[v] = true
|
||||
self.freeClaimedCount = self.freeClaimedCount + 1
|
||||
end
|
||||
end
|
||||
self.baseClaimed = {}
|
||||
self.baseClaimedCount = 0
|
||||
if data.pay_low_awarded then
|
||||
for _, v in ipairs(data.pay_low_awarded) do
|
||||
self.baseClaimed[v] = true
|
||||
self.baseClaimedCount = self.baseClaimedCount + 1
|
||||
end
|
||||
end
|
||||
self.advanceClaimed = {}
|
||||
self.advanceClaimedCount = 0
|
||||
if data.pay_high_awarded then
|
||||
for _, v in ipairs(data.pay_high_awarded) do
|
||||
self.advanceClaimed[v] = true
|
||||
self.advanceClaimedCount = self.advanceClaimedCount + 1
|
||||
end
|
||||
end
|
||||
self:initLevelInfo()
|
||||
local fundLevel = 1
|
||||
local totalCount = 0
|
||||
while true do
|
||||
local levelInfoIds = self.levelInfoMap[fundLevel]
|
||||
if levelInfoIds == nil then
|
||||
fundLevel = fundLevel - 1
|
||||
break
|
||||
end
|
||||
local firstLevelInfoId = levelInfoIds[1]
|
||||
local cfg = self:getLevelFundCfg()
|
||||
if DataManager.PlayerData:getLv() < cfg[firstLevelInfoId].level then -- 等级不够
|
||||
fundLevel = fundLevel - 1
|
||||
break
|
||||
end
|
||||
totalCount = totalCount + #levelInfoIds
|
||||
if self.freeClaimedCount == totalCount and
|
||||
self.freeClaimedCount == self.baseClaimedCount and
|
||||
self.freeClaimedCount == self.advanceClaimedCount then
|
||||
fundLevel = fundLevel + 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
if fundLevel < 1 then
|
||||
fundLevel = 1
|
||||
end
|
||||
self.data.fundLevel = fundLevel
|
||||
if self.data.fundLevel == 2 then
|
||||
self.fundBaseId = ACT_GIFT_FUND_BASE_ID_2
|
||||
self.fundAdvanceId = ACT_GIFT_FUND_ADVANCE_ID_2
|
||||
else
|
||||
self.fundBaseId = ACT_GIFT_FUND_BASE_ID_1
|
||||
self.fundAdvanceId = ACT_GIFT_FUND_ADVANCE_ID_1
|
||||
end
|
||||
end
|
||||
|
||||
function FundData:initLevelInfo()
|
||||
if not self.levelInfoMap then
|
||||
self.levelInfoMap = {}
|
||||
local cfg = self:getLevelFundCfg()
|
||||
for id, info in pairs(cfg) do
|
||||
if not self.levelInfoMap[info.stage] then
|
||||
self.levelInfoMap[info.stage] = {}
|
||||
end
|
||||
table.insert(self.levelInfoMap[info.stage], id)
|
||||
end
|
||||
for level, _ in pairs(self.levelInfoMap) do
|
||||
table.sort(self.levelInfoMap[level], function(a, b)
|
||||
return a < b
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function FundData:markDirty()
|
||||
self.data.dirty = not self.data.dirty
|
||||
end
|
||||
|
||||
function FundData:markPurcharseDirty()
|
||||
self.data.purcharseDirty = not self.data.purcharseDirty
|
||||
end
|
||||
|
||||
function FundData:getIsOpen()
|
||||
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FUND, true)
|
||||
end
|
||||
|
||||
function FundData:getFundLevel()
|
||||
return self.data.fundLevel
|
||||
end
|
||||
|
||||
function FundData:getFundBaseId()
|
||||
return self.fundBaseId
|
||||
end
|
||||
|
||||
function FundData:getFundAdvanceId()
|
||||
return self.fundAdvanceId
|
||||
end
|
||||
|
||||
function FundData:getCurrLevelBaseRechargeId()
|
||||
local info = self:getActGiftCfg()[self.fundBaseId]
|
||||
return info.recharge_id
|
||||
end
|
||||
|
||||
function FundData:getCurrLevelAdvanceRechargeId()
|
||||
local info = self:getActGiftCfg()[self.fundAdvanceId]
|
||||
return info.recharge_id
|
||||
end
|
||||
|
||||
function FundData:getActGiftCfg()
|
||||
if self.cfg == nil then
|
||||
self.cfg = ConfigManager:getConfig("act_gift")
|
||||
end
|
||||
return self.cfg
|
||||
end
|
||||
|
||||
function FundData:getLevelFundCfg()
|
||||
if self.levelFundCfg == nil then
|
||||
self.levelFundCfg = ConfigManager:getConfig("act_level_fund")
|
||||
end
|
||||
return self.levelFundCfg
|
||||
end
|
||||
|
||||
function FundData:getCurrLevelInfoList()
|
||||
return self.levelInfoMap[self.data.fundLevel] or GConst.EMPTY_TABLE
|
||||
end
|
||||
|
||||
function FundData:getNeedLevel(id)
|
||||
local levelFundInfo = self:getLevelFundCfg()[id]
|
||||
if levelFundInfo == nil then
|
||||
return 9999
|
||||
end
|
||||
return levelFundInfo.level
|
||||
end
|
||||
|
||||
function FundData:getAllStepFundRewards(id)
|
||||
local levelFundInfo = self:getLevelFundCfg()[id]
|
||||
if levelFundInfo == nil then
|
||||
return nil, nil, nil
|
||||
end
|
||||
return levelFundInfo.reward_free, levelFundInfo.reward_small, levelFundInfo.reward
|
||||
end
|
||||
|
||||
function FundData:getFreeFundRewards(id)
|
||||
local levelFundInfo = self:getLevelFundCfg()[id]
|
||||
if levelFundInfo == nil then
|
||||
return nil
|
||||
end
|
||||
return levelFundInfo.reward_free
|
||||
end
|
||||
|
||||
function FundData:getBaseFundRewards(id)
|
||||
local levelFundInfo = self:getLevelFundCfg()[id]
|
||||
if levelFundInfo == nil then
|
||||
return nil
|
||||
end
|
||||
return levelFundInfo.reward_small
|
||||
end
|
||||
|
||||
function FundData:getAdvanceFundRewards(id)
|
||||
local levelFundInfo = self:getLevelFundCfg()[id]
|
||||
if levelFundInfo == nil then
|
||||
return nil
|
||||
end
|
||||
return levelFundInfo.reward
|
||||
end
|
||||
|
||||
function FundData:getIsBoughtBase()
|
||||
return DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, self.fundBaseId) > 0
|
||||
end
|
||||
|
||||
function FundData:getIsBoughtAdvance()
|
||||
return DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, self.fundAdvanceId) > 0
|
||||
end
|
||||
|
||||
function FundData:getIsClaimedFree(id)
|
||||
return self.freeClaimed[id]
|
||||
end
|
||||
|
||||
function FundData:getIsClaimedBase(id)
|
||||
return self.baseClaimed[id]
|
||||
end
|
||||
|
||||
function FundData:getIsClaimedAdvance(id)
|
||||
return self.advanceClaimed[id]
|
||||
end
|
||||
|
||||
function FundData:getMinUnclaimedRewardIndex()
|
||||
local playerLevel = DataManager.PlayerData:getLv()
|
||||
local levelInfoIds = self:getCurrLevelInfoList()
|
||||
local minIndex = 0
|
||||
local isBoughtBase = self:getIsBoughtBase()
|
||||
local isBoughtAdvance = self:getIsBoughtAdvance()
|
||||
for k, id in ipairs(levelInfoIds) do
|
||||
local levelFundInfo = self:getLevelFundCfg()[id]
|
||||
if levelFundInfo then
|
||||
if playerLevel >= levelFundInfo.level then -- 等级到了
|
||||
if not self.freeClaimed[id] then -- 能领但是没有领
|
||||
minIndex = k
|
||||
break
|
||||
end
|
||||
if isBoughtBase then
|
||||
if not self.baseClaimed[id] then -- 能领但是没有领
|
||||
minIndex = k
|
||||
break
|
||||
end
|
||||
end
|
||||
if isBoughtAdvance then
|
||||
if not self.advanceClaimed[id] then -- 能领但是没有领
|
||||
minIndex = k
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return minIndex
|
||||
end
|
||||
|
||||
-- 是否有未领取的奖励
|
||||
function FundData:getIfCanClaimReward()
|
||||
if not self:getIsOpen() then
|
||||
return false
|
||||
end
|
||||
return self:getMinUnclaimedRewardIndex() > 0
|
||||
end
|
||||
|
||||
return FundData
|
||||
10
lua/app/userdata/fund/fund_data.lua.meta
Normal file
10
lua/app/userdata/fund/fund_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9943057ffc3dd541bfff544d512abee
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -4,6 +4,10 @@ function PlayerData:ctor()
|
||||
self.data.dirty = false
|
||||
end
|
||||
|
||||
function PlayerData:clear()
|
||||
DataManager:unregisterCrossDayFunc("PlayerData")
|
||||
end
|
||||
|
||||
function PlayerData:init(data)
|
||||
local basicInfo = data.basic_info or GConst.EMPTY_TABLE
|
||||
self.data.level = basicInfo.level or 1
|
||||
@ -16,6 +20,15 @@ function PlayerData:init(data)
|
||||
self.data.vitADCount = energyLimit.ad_count or 0
|
||||
|
||||
self.lastLoginTime = basicInfo.lastLoginTime or Time:getBeginningOfServerToday()
|
||||
DataManager:registerCrossDayFunc("PlayerData", function()
|
||||
self:resetOnCrossDay()
|
||||
self:markDirty()
|
||||
end)
|
||||
end
|
||||
|
||||
function PlayerData:resetOnCrossDay()
|
||||
self.data.vitGemCount = 0
|
||||
self.data.vitADCount = 0
|
||||
end
|
||||
|
||||
function PlayerData:markDirty()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user