基金
This commit is contained in:
parent
142bf926b2
commit
fdc400fd8d
@ -19,6 +19,7 @@ function DataManager:init()
|
|||||||
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
||||||
self:initManager("DailyTaskData", "app/userdata/task/daily_task_data")
|
self:initManager("DailyTaskData", "app/userdata/task/daily_task_data")
|
||||||
self:initManager("IdleData", "app/userdata/idle/idle_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("SevenDayData", "app/userdata/activity/seven_day/seven_day_data")
|
||||||
self:initManager("ShopData", "app/userdata/shop/shop_data")
|
self:initManager("ShopData", "app/userdata/shop/shop_data")
|
||||||
self:initManager("SummonData", "app/userdata/summon/summon_data")
|
self:initManager("SummonData", "app/userdata/summon/summon_data")
|
||||||
@ -90,6 +91,7 @@ function DataManager:clear()
|
|||||||
self.BountyData:clear()
|
self.BountyData:clear()
|
||||||
self.DailyTaskData:clear()
|
self.DailyTaskData:clear()
|
||||||
self.IdleData:clear()
|
self.IdleData:clear()
|
||||||
|
self.FundData:clear()
|
||||||
-- self.SevenDayData:clear()
|
-- self.SevenDayData:clear()
|
||||||
self.ShopData:clear()
|
self.ShopData:clear()
|
||||||
self.SummonData:clear()
|
self.SummonData:clear()
|
||||||
@ -132,7 +134,9 @@ function DataManager:initWithServerData(data)
|
|||||||
self.ShopData:initCommonDailyGoldGift(data.mall_idle and data.mall_idle.ad_count) -- 常驻金币礼包
|
self.ShopData:initCommonDailyGoldGift(data.mall_idle and data.mall_idle.ad_count) -- 常驻金币礼包
|
||||||
self.ShopData:initGrowUpGift(data.act_grow_up_gift) -- 成长礼包
|
self.ShopData:initGrowUpGift(data.act_grow_up_gift) -- 成长礼包
|
||||||
self.ShopData:initLevelUpGift(data.act_level_up_gift) -- 助力礼包
|
self.ShopData:initLevelUpGift(data.act_level_up_gift) -- 助力礼包
|
||||||
self.SummonData:init(data.summon)
|
self.SummonData:init(data.summon)
|
||||||
|
-- 成长基金要在ShopData和PlayerDataBagData还有之后初始化,依赖这些数据
|
||||||
|
self.FundData:init(data.fund)
|
||||||
|
|
||||||
self:scheduleGlobal()
|
self:scheduleGlobal()
|
||||||
self:checkDataBind()
|
self:checkDataBind()
|
||||||
|
|||||||
@ -27,6 +27,8 @@ local MODULE_PATHS = {
|
|||||||
IdleManager = "app/module/idle/idle_manager",
|
IdleManager = "app/module/idle/idle_manager",
|
||||||
-- 活动
|
-- 活动
|
||||||
-- SevenDayManager = "app/module/activity/seven_day/seven_day_manager",
|
-- SevenDayManager = "app/module/activity/seven_day/seven_day_manager",
|
||||||
|
-- 基金
|
||||||
|
FundManager = "app/module/fund/fund_manager",
|
||||||
-- 设置
|
-- 设置
|
||||||
GameSettingManager = "app/module/game_setting/game_setting_manager",
|
GameSettingManager = "app/module/game_setting/game_setting_manager",
|
||||||
-- 活动
|
-- 活动
|
||||||
@ -57,6 +59,7 @@ ModuleManager.MODULE_KEY = {
|
|||||||
IDLE_DROP = "idle_drop",
|
IDLE_DROP = "idle_drop",
|
||||||
MALL = "mall", -- 商城
|
MALL = "mall", -- 商城
|
||||||
MALL_DAILY = "mall_daily", -- 每日商城
|
MALL_DAILY = "mall_daily", -- 每日商城
|
||||||
|
FUND = "act_level_gift" -- 成长基金
|
||||||
}
|
}
|
||||||
|
|
||||||
local _moduleMgrs = {}
|
local _moduleMgrs = {}
|
||||||
|
|||||||
@ -187,6 +187,7 @@ GConst.ATLAS_PATH = {
|
|||||||
ICON_TASK = "assets/arts/atlas/icon/task.asset",
|
ICON_TASK = "assets/arts/atlas/icon/task.asset",
|
||||||
SHOP = "assets/arts/atlas/ui/shop.asset",
|
SHOP = "assets/arts/atlas/ui/shop.asset",
|
||||||
HERO = "assets/arts/atlas/ui/hero.asset",
|
HERO = "assets/arts/atlas/ui/hero.asset",
|
||||||
|
FUND = "assets/arts/atlas/ui/fund.asset",
|
||||||
}
|
}
|
||||||
|
|
||||||
GConst.TOUCH_EVENT = {
|
GConst.TOUCH_EVENT = {
|
||||||
|
|||||||
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:
|
||||||
7
lua/app/module/fund/fund_manager.lua
Normal file
7
lua/app/module/fund/fund_manager.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
local FundManager = class("FundManager", BaseModule)
|
||||||
|
|
||||||
|
function FundManager:showLevelFundUI()
|
||||||
|
UIManager:showUI("app/ui/fund/level_fund_ui")
|
||||||
|
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 = {
|
MainCityConst.RIGHT_SIDE_BARS = {
|
||||||
"app/ui/main_city/cell/side_bar_gold_pig_cell",
|
"app/ui/main_city/cell/side_bar_gold_pig_cell",
|
||||||
|
"app/ui/main_city/cell/side_bar_level_fund_cell",
|
||||||
}
|
}
|
||||||
|
|
||||||
return MainCityConst
|
return MainCityConst
|
||||||
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}
|
||||||
149
lua/app/ui/fund/level_fund_ui.lua
Normal file
149
lua/app/ui/fund/level_fund_ui.lua
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
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_VIT,
|
||||||
|
GConst.ItemConst.ITEM_ID_GOLD,
|
||||||
|
GConst.ItemConst.ITEM_ID_GEM
|
||||||
|
},
|
||||||
|
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: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()
|
||||||
|
end
|
||||||
|
|
||||||
|
function LevelFundUI:initTitle()
|
||||||
|
self.uiMap["level_fund_ui.title_img.title_tx"]:setText("临时文本:购买成长基金后,可通过提升等级获得钻石,多档基金可同时购买")
|
||||||
|
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)
|
||||||
|
|
||||||
|
local payBtn1 = self.uiMap["level_fund_ui.title_bg_2.btn_1"]
|
||||||
|
payBtn1:addClickListener(function()
|
||||||
|
end)
|
||||||
|
if not DataManager.FundData:getIsBoughtBase() then
|
||||||
|
local rechargeId = DataManager.FundData:getCurrLevelBaseRechargeId()
|
||||||
|
self.uiMap["level_fund_ui.title_bg_2.btn_1.text"]:setText(GFunc.getFormatPrice(rechargeId))
|
||||||
|
else
|
||||||
|
self.uiMap["level_fund_ui.title_bg_2.btn_1.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_ACTIVE))
|
||||||
|
end
|
||||||
|
|
||||||
|
local payBtn2 = self.uiMap["level_fund_ui.title_bg_2.btn_2"]
|
||||||
|
payBtn2:setAnchoredPositionX(width/3)
|
||||||
|
payBtn2:addClickListener(function()
|
||||||
|
end)
|
||||||
|
if not DataManager.FundData:getIsBoughtAdvance() then
|
||||||
|
local rechargeId = DataManager.FundData:getCurrLevelAdvanceRechargeId()
|
||||||
|
self.uiMap["level_fund_ui.title_bg_2.btn_2.text"]:setText(GFunc.getFormatPrice(rechargeId))
|
||||||
|
else
|
||||||
|
self.uiMap["level_fund_ui.title_bg_2.btn_2.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_ACTIVE))
|
||||||
|
end
|
||||||
|
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:onRefresh()
|
||||||
|
self:refreshRewards()
|
||||||
|
end
|
||||||
|
|
||||||
|
function LevelFundUI:refreshRewards()
|
||||||
|
local count = #self.levelInfoList
|
||||||
|
if self.scrollRectComp:getTotalCount() ~= count then -- 打开界面的时候定位到当前可领取的最低等级奖励,如果没有则定位到当前等级
|
||||||
|
self.scrollRectComp:clearCells()
|
||||||
|
self.scrollRectComp:refillCells(count)
|
||||||
|
-- local level = DataManager.BountyData:getMinUnclaimedRewardIndex()
|
||||||
|
-- if level > 1 then
|
||||||
|
-- self:scrollToIndex(level)
|
||||||
|
-- end
|
||||||
|
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}
|
||||||
16
lua/app/ui/main_city/cell/side_bar_level_fund_cell.lua
Normal file
16
lua/app/ui/main_city/cell/side_bar_level_fund_cell.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
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}
|
||||||
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:
|
||||||
182
lua/app/userdata/fund/fund_data.lua
Normal file
182
lua/app/userdata/fund/fund_data.lua
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
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: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:getIsOpen()
|
||||||
|
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FUND, true)
|
||||||
|
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
|
||||||
|
|
||||||
|
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}
|
||||||
Loading…
x
Reference in New Issue
Block a user