Merge branch 'dev' into net
This commit is contained in:
commit
cb0e613e47
@ -197,6 +197,26 @@ function UIPrefabObject:fastGetAnchoredPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function UIPrefabObject:fastGetAnchoredPositionX()
|
||||
if self.prefabHelper then
|
||||
self.prefabHelper:CacheAnchoredPosition(self.objectIndex)
|
||||
return self.prefabHelper.PositionX
|
||||
else
|
||||
local anchoredPosition = self:getTransform().anchoredPosition
|
||||
return anchoredPosition.x
|
||||
end
|
||||
end
|
||||
|
||||
function UIPrefabObject:fastGetAnchoredPositionY()
|
||||
if self.prefabHelper then
|
||||
self.prefabHelper:CacheAnchoredPosition(self.objectIndex)
|
||||
return self.prefabHelper.PositionY
|
||||
else
|
||||
local anchoredPosition = self:getTransform().anchoredPosition
|
||||
return anchoredPosition.y
|
||||
end
|
||||
end
|
||||
|
||||
function UIPrefabObject:getAnchoredPosition()
|
||||
if self.prefabHelper then
|
||||
return self.prefabHelper:GetAnchoredPosition(self.objectIndex)
|
||||
|
||||
@ -15,6 +15,7 @@ function DataManager:init()
|
||||
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
|
||||
self:initManager("ActivityData", "app/userdata/activity/activity_data")
|
||||
self:initManager("GodPigData", "app/userdata/activity/god_pig/god_pig_data")
|
||||
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
||||
-- self:initManager("IdleData", "app/userdata/idle/idle_data")
|
||||
-- self:initManager("SevenDayData", "app/userdata/activity/seven_day/seven_day_data")
|
||||
end
|
||||
@ -77,6 +78,7 @@ function DataManager:clear()
|
||||
self.FormationData:clear()
|
||||
self.ActivityData:clear()
|
||||
self.GodPigData:clear()
|
||||
self.BountyData:clear()
|
||||
-- self.IdleData:clear()
|
||||
-- self.SevenDayData:clear()
|
||||
|
||||
@ -104,6 +106,7 @@ function DataManager:initWithServerData(data)
|
||||
self.TutorialData:init(data.guide)
|
||||
self.ActivityData:init()
|
||||
self.GodPigData:init()
|
||||
self.BountyData:init()
|
||||
-- self.IdleData:clear(data.IdleData)
|
||||
-- self.SevenDayData:init(data.SevenDayData)
|
||||
|
||||
|
||||
@ -176,6 +176,7 @@ GConst.ATLAS_PATH = {
|
||||
ICON_HERO = "assets/arts/atlas/icon/hero.asset",
|
||||
ICON_SKILL_ROGUE = "assets/arts/atlas/icon/skill_rogue.asset",
|
||||
ICON_BUFF = "assets/arts/atlas/icon/buff.asset",
|
||||
BOUNTY = "assets/arts/atlas/ui/bounty.asset",
|
||||
}
|
||||
|
||||
GConst.TOUCH_EVENT = {
|
||||
|
||||
@ -60,7 +60,7 @@ end
|
||||
function LoginManager:initSocket()
|
||||
local isConnected = NetManager:isConnected(NetManager.MAIN_SOCKET_NAME)
|
||||
if EDITOR_MODE then
|
||||
Logger.logError("LoginMgr:initSocket:%s", isConnected)
|
||||
Logger.logHighlight("LoginMgr:initSocket:%s", isConnected)
|
||||
end
|
||||
if not isConnected then
|
||||
NetManager:init(
|
||||
@ -68,7 +68,7 @@ function LoginManager:initSocket()
|
||||
self:connectByChannel(
|
||||
function()
|
||||
if EDITOR_MODE then
|
||||
Logger.logError("主链接链接成功")
|
||||
Logger.logHighlight("主链接链接成功")
|
||||
end
|
||||
self:_login()
|
||||
end
|
||||
|
||||
@ -19,7 +19,9 @@ MainCityConst.BOTTOM_COUNT = 2
|
||||
MainCityConst.LEFT_SIDE_BARS = {
|
||||
"app/ui/main_city/cell/side_bar_setting_cell",
|
||||
"app/ui/main_city/cell/side_bar_idle_cell",
|
||||
"app/ui/main_city/cell/side_bar_seven_days_cell"
|
||||
"app/ui/main_city/cell/side_bar_seven_days_cell",
|
||||
-- gm放最后一个
|
||||
"app/ui/main_city/cell/side_bar_gm_cell"
|
||||
}
|
||||
|
||||
MainCityConst.RIGHT_SIDE_BARS = {
|
||||
|
||||
@ -16,4 +16,20 @@ function MaincityManager:firstEnterMainCity()
|
||||
end
|
||||
end
|
||||
|
||||
function MaincityManager:changeMainCityLeftSideBarOpenOrClose()
|
||||
self.isLeftSideBarClose = not self.isLeftSideBarClose
|
||||
end
|
||||
|
||||
function MaincityManager:getIsMainCityLeftSideBarClose()
|
||||
return self.isLeftSideBarClose
|
||||
end
|
||||
|
||||
function MaincityManager:changeMainCityRightSideBarOpenOrClose()
|
||||
self.isRightSideBarClose = not self.isRightSideBarClose
|
||||
end
|
||||
|
||||
function MaincityManager:getIsMainCityRightSideBarClose()
|
||||
return self.isRightSideBarClose
|
||||
end
|
||||
|
||||
return MaincityManager
|
||||
@ -94,6 +94,10 @@ function SideBarBaseCellComp:setAnchoredPositionY(y)
|
||||
self.baseObject:setAnchoredPositionY(y)
|
||||
end
|
||||
|
||||
function SideBarBaseCellComp:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function SideBarBaseCellComp:getCellPath()
|
||||
return self.cellPath
|
||||
end
|
||||
|
||||
16
lua/app/ui/main_city/cell/side_bar_gm_cell.lua
Normal file
16
lua/app/ui/main_city/cell/side_bar_gm_cell.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
|
||||
local SideBarGMCell = class("SideBarGMCell", SideBarBaseCellComp)
|
||||
|
||||
function SideBarGMCell:getIsOpen()
|
||||
return Platform:getIsDevChannel()
|
||||
end
|
||||
|
||||
function SideBarGMCell:getIconRes()
|
||||
return "maincity_gm"
|
||||
end
|
||||
|
||||
function SideBarGMCell:onClick()
|
||||
ModuleManager.DevToolManager:showOrHideDevListUI()
|
||||
end
|
||||
|
||||
return SideBarGMCell
|
||||
10
lua/app/ui/main_city/cell/side_bar_gm_cell.lua.meta
Normal file
10
lua/app/ui/main_city/cell/side_bar_gm_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd053010d0d30b9409b0f34246c925b4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -6,7 +6,7 @@ function SideBarGodPigCell:getIsOpen()
|
||||
end
|
||||
|
||||
function SideBarGodPigCell:getIconRes()
|
||||
return "main_btn_godpig"
|
||||
return "main_btn_pig"
|
||||
end
|
||||
|
||||
function SideBarGodPigCell:onClick()
|
||||
|
||||
@ -6,7 +6,7 @@ function SideBarIdleCell:getIsOpen()
|
||||
end
|
||||
|
||||
function SideBarIdleCell:getIconRes()
|
||||
return "main_btn_idle"
|
||||
return "main_btn_hang"
|
||||
end
|
||||
|
||||
function SideBarIdleCell:onClick()
|
||||
|
||||
@ -10,7 +10,6 @@ function MainComp:init()
|
||||
self.uiMap = self:getBaseObject():genAllChildren()
|
||||
self:initChapter()
|
||||
self:initStageFormation()
|
||||
self:initGM()
|
||||
end
|
||||
|
||||
function MainComp:initChapter()
|
||||
@ -49,14 +48,6 @@ function MainComp:initStageFormation()
|
||||
}
|
||||
end
|
||||
|
||||
function MainComp:initGM()
|
||||
self.btnGM = self.uiMap["main_comp.gm_btn"]
|
||||
self.btnGM:setVisible(Platform:getIsDevChannel(), 2)
|
||||
self.btnGM:addClickListener(function()
|
||||
ModuleManager.DevToolManager:showOrHideDevListUI()
|
||||
end)
|
||||
end
|
||||
|
||||
function MainComp:refresh()
|
||||
self:refreshChapter()
|
||||
self:refreshStageFormaion()
|
||||
@ -105,6 +96,10 @@ function MainComp:refreshChapter(force)
|
||||
end
|
||||
|
||||
local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId()
|
||||
if rewardChapterId > chapterId then
|
||||
rewardChapterId = chapterId
|
||||
end
|
||||
|
||||
local curMaxWave = DataManager.ChapterData:getChapterMaxWave(rewardChapterId)
|
||||
local boxCount = DataManager.ChapterData:getChapterBoxCount(rewardChapterId)
|
||||
local unitValue = 1 / boxCount
|
||||
|
||||
@ -23,7 +23,7 @@ function MainCityUI:getBGMId()
|
||||
return AudioManager.BGM_ID.MAINCITY
|
||||
end
|
||||
|
||||
function MainCityUI:getCurrencyParams()
|
||||
function MainCityUI:getCurrencyParams()
|
||||
if self.currencyParams == nil then
|
||||
self.currencyParams = {
|
||||
itemIds = {}
|
||||
@ -95,6 +95,8 @@ function MainCityUI:_display()
|
||||
self:initBottomUI()
|
||||
self:initComp()
|
||||
self:initLeftRightBtns()
|
||||
self:initPlayerInfo()
|
||||
self:initTopNode()
|
||||
self:refreshBottom()
|
||||
end
|
||||
|
||||
@ -113,7 +115,7 @@ function MainCityUI:_bind()
|
||||
end
|
||||
end, true)
|
||||
self:bind(DataManager.PlayerData, "dirty", function(binder, value)
|
||||
self:refreshRoleInfo()
|
||||
self:refreshPlayerInfo()
|
||||
end, true)
|
||||
self:bind(DataManager.PlayerData, "lvUpDirty", function(binder, value)
|
||||
self:checkMainPop()
|
||||
@ -237,9 +239,23 @@ function MainCityUI:refreshBottomCell(showAni)
|
||||
end
|
||||
|
||||
function MainCityUI:initLeftRightBtns()
|
||||
self.leftNode = self.uiMap["main_ui.left_node"]
|
||||
self.leftSideBar = self.uiMap["main_ui.left_node.side_bar"]
|
||||
self.leftArrowNode = self.uiMap["main_ui.left_node.arrow_node"]
|
||||
self.leftArrowBtn = self.uiMap["main_ui.left_node.arrow_node.arrow"]
|
||||
self.leftArrowBtn:addClickListener(function()
|
||||
self:openOrCloseLeftSideBar()
|
||||
end)
|
||||
self.rightNode = self.uiMap["main_ui.right_node"]
|
||||
self.rightSideBar = self.uiMap["main_ui.right_node.side_bar"]
|
||||
self.rightArrowNode = self.uiMap["main_ui.right_node.arrow_node"]
|
||||
self.rightArrowBtn = self.uiMap["main_ui.right_node.arrow_node.arrow"]
|
||||
self.rightArrowBtn:addClickListener(function()
|
||||
self:openOrCloseRightSideBar()
|
||||
end)
|
||||
self.sideBarCellObject = self.uiMap["main_ui.cache_node.side_bar_cell"]
|
||||
local w, h = self.sideBarCellObject:fastGetSizeDelta()
|
||||
self.sideBarHeight = h
|
||||
if self.leftBarList == nil then
|
||||
self.leftBarList = {}
|
||||
end
|
||||
@ -263,12 +279,18 @@ function MainCityUI:addSideBarCellComp(cellClassPath)
|
||||
return prefabObject:addLuaComponent(cellClassPath)
|
||||
end
|
||||
|
||||
function MainCityUI:openOrCloseLeftSideBar()
|
||||
ModuleManager.MaincityManager:changeMainCityLeftSideBarOpenOrClose()
|
||||
self:refreshLeftBtns()
|
||||
end
|
||||
|
||||
function MainCityUI:refreshLeftBtns()
|
||||
self:clearSideBarList(self.leftBarList)
|
||||
local list = GConst.MainCityConst.LEFT_SIDE_BARS
|
||||
if #list <= 0 then
|
||||
self:clearSideBarList(self.leftBarList)
|
||||
return
|
||||
end
|
||||
local isClose = ModuleManager.MaincityManager:getIsMainCityLeftSideBarClose()
|
||||
for k, v in ipairs(list) do
|
||||
local CellClass = self.sideBarClassMap[v]
|
||||
if CellClass == nil then
|
||||
@ -285,20 +307,42 @@ function MainCityUI:refreshLeftBtns()
|
||||
table.insert(self.leftBarList, cell)
|
||||
end
|
||||
end
|
||||
local y = 0
|
||||
for k, v in ipairs(self.leftBarList) do
|
||||
v:setAnchoredPositionY(y)
|
||||
v:refresh()
|
||||
y = y - 80
|
||||
local y = - 2 - self.sideBarHeight/2
|
||||
if isClose then -- 只显示一个
|
||||
local first = self.leftBarList[1]
|
||||
first:setAnchoredPositionY(y)
|
||||
first:setVisible(true)
|
||||
first:refresh()
|
||||
y = y - self.sideBarHeight - 2
|
||||
for i = 2, #self.leftBarList do
|
||||
self.leftBarList[i]:setVisible(false)
|
||||
self.leftBarList[i]:refresh()
|
||||
end
|
||||
else
|
||||
for k, v in ipairs(self.leftBarList) do
|
||||
v:setAnchoredPositionY(y)
|
||||
v:setVisible(true)
|
||||
v:refresh()
|
||||
y = y - self.sideBarHeight - 2
|
||||
end
|
||||
end
|
||||
self.leftSideBar:setSizeDeltaY(-y)
|
||||
self.leftArrowNode:setLocalScale(1, isClose and -1 or 1, 1)
|
||||
self.leftArrowNode:setAnchoredPositionY(self.leftSideBar:fastGetAnchoredPositionY() + y + 20)
|
||||
end
|
||||
|
||||
function MainCityUI:openOrCloseRightSideBar()
|
||||
ModuleManager.MaincityManager:changeMainCityRightSideBarOpenOrClose()
|
||||
self:refreshRightBtns()
|
||||
end
|
||||
|
||||
function MainCityUI:refreshRightBtns()
|
||||
self:clearSideBarList(self.rightBarList)
|
||||
local list = GConst.MainCityConst.RIGHT_SIDE_BARS
|
||||
if #list <= 0 then
|
||||
self:clearSideBarList(self.rightBarList)
|
||||
return
|
||||
end
|
||||
local isClose = ModuleManager.MaincityManager:getIsMainCityRightSideBarClose()
|
||||
for k, v in ipairs(list) do
|
||||
local CellClass = self.sideBarClassMap[v]
|
||||
if CellClass == nil then
|
||||
@ -315,12 +359,27 @@ function MainCityUI:refreshRightBtns()
|
||||
table.insert(self.rightBarList, cell)
|
||||
end
|
||||
end
|
||||
local y = 0
|
||||
for k, v in ipairs(self.rightBarList) do
|
||||
v:setAnchoredPositionY(y)
|
||||
v:refresh()
|
||||
y = y - 80
|
||||
local y = -2 - self.sideBarHeight/2
|
||||
if isClose then -- 只显示一个
|
||||
local first = self.rightBarList[1]
|
||||
first:setAnchoredPositionY(y)
|
||||
first:setVisible(true)
|
||||
first:refresh()
|
||||
y = y - self.sideBarHeight - 2
|
||||
for i = 2, #self.rightBarList do
|
||||
self.rightBarList[i]:setVisible(false)
|
||||
self.rightBarList[i]:refresh()
|
||||
end
|
||||
else
|
||||
for k, v in ipairs(self.rightBarList) do
|
||||
v:setAnchoredPositionY(y)
|
||||
v:refresh()
|
||||
y = y - self.sideBarHeight - 2
|
||||
end
|
||||
end
|
||||
self.rightSideBar:setSizeDeltaY(-y)
|
||||
self.rightArrowNode:setLocalScale(1, isClose and -1 or 1, 1)
|
||||
self.rightArrowNode:setAnchoredPositionY(self.rightSideBar:fastGetAnchoredPositionY() + y + 20)
|
||||
end
|
||||
|
||||
function MainCityUI:clearSideBarList(sideBarList)
|
||||
@ -332,8 +391,62 @@ function MainCityUI:clearSideBarList(sideBarList)
|
||||
end
|
||||
|
||||
function MainCityUI:setSideBarVisible(visible)
|
||||
self.leftSideBar:setVisible(visible)
|
||||
self.rightSideBar:setVisible(visible)
|
||||
self.leftNode:setVisible(visible)
|
||||
self.rightNode:setVisible(visible)
|
||||
end
|
||||
|
||||
function MainCityUI:initPlayerInfo()
|
||||
self.playerSlider = self.uiMap["main_ui.player_node.slider"]
|
||||
self.playerLvTx = self.uiMap["main_ui.player_node.lv"]
|
||||
end
|
||||
|
||||
function MainCityUI:refreshPlayerInfo()
|
||||
local lv = DataManager.PlayerData:getLv()
|
||||
self.playerLvTx:setText(GConst.INT_TO_STRING[lv] or tostring(lv))
|
||||
self.playerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = DataManager.PlayerData:getExpPercent()
|
||||
end
|
||||
|
||||
function MainCityUI:initTopNode()
|
||||
self.topNode = self.uiMap["main_ui.top_node"]
|
||||
self:initTask()
|
||||
self:initBounty()
|
||||
self:initSetting()
|
||||
end
|
||||
|
||||
function MainCityUI:initTask()
|
||||
self.taskBtn = self.uiMap["main_ui.top_node.task_btn"]
|
||||
self.taskBtn:addClickListener(function()
|
||||
end)
|
||||
end
|
||||
|
||||
function MainCityUI:initBounty()
|
||||
self.bountyNode = self.uiMap["main_ui.top_node.bounty_node"]
|
||||
self.bountyBanner = self.uiMap["main_ui.top_node.bounty_node.banner"]
|
||||
end
|
||||
|
||||
function MainCityUI:initSetting()
|
||||
self.settingbtn = self.uiMap["main_ui.top_node.setting_btn"]
|
||||
self.settingbtn:addClickListener(function()
|
||||
end)
|
||||
end
|
||||
|
||||
function MainCityUI:setTopNodeVisible(visible)
|
||||
self.topNode:setVisible(visible)
|
||||
end
|
||||
|
||||
function MainCityUI:refreshTopNode()
|
||||
self:refreshBounty()
|
||||
end
|
||||
|
||||
function MainCityUI:refreshBounty()
|
||||
local isOpen = DataManager.BountyData:getIsOpen()
|
||||
if not isOpen then
|
||||
self.bountyNode:setVisible(false)
|
||||
return
|
||||
end
|
||||
self.bountyNode:setVisible(true)
|
||||
local bannerName = DataManager.BountyData:getBannerName()
|
||||
self.bountyBanner:setSprite(GConst.ATLAS_PATH.BOUNTY, bannerName)
|
||||
end
|
||||
|
||||
function MainCityUI:switchComp(index)
|
||||
@ -348,8 +461,11 @@ function MainCityUI:switchComp(index)
|
||||
self:updateCurrencyBar()
|
||||
if self.selectedIndex == MAIN_COMP_INDEX then
|
||||
self:checkMainPop()
|
||||
self:setTopNodeVisible(true)
|
||||
self:refreshTopNode()
|
||||
self:setSideBarVisible(true)
|
||||
else
|
||||
self:setTopNodeVisible(false)
|
||||
self:setSideBarVisible(false)
|
||||
end
|
||||
end
|
||||
@ -357,16 +473,6 @@ end
|
||||
function MainCityUI:updateTime()
|
||||
end
|
||||
|
||||
function MainCityUI:refreshRoleInfo()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local v, _, _2 = DataManager.PlayerData:getExpPer()
|
||||
uiMap["main_ui.role_node.role_cell.setting.lv"]:setText(DataManager.PlayerData:getLv())
|
||||
uiMap["main_ui.role_node.role_cell.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = v
|
||||
uiMap["main_ui.role_node.role_cell.setting"]:addClickListener(function()
|
||||
ModuleManager.GameSettingManager:showSettingUI()
|
||||
end)
|
||||
end
|
||||
|
||||
function MainCityUI:refreshBottomRp()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local heroRpObj = uiMap["main_ui.bottom_node.icons.ui_spine_obj_r.rp_node"]
|
||||
|
||||
8
lua/app/userdata/bounty.meta
Normal file
8
lua/app/userdata/bounty.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 272533192ecd8bf428c0e17dcdcfe6b6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
445
lua/app/userdata/bounty/bounty_data.lua
Normal file
445
lua/app/userdata/bounty/bounty_data.lua
Normal file
@ -0,0 +1,445 @@
|
||||
local BountyData = class("BountyData", BaseData)
|
||||
|
||||
-- local ACT_BATTLE_PASS = ConfigManager:getConfig("act_battle_pass")
|
||||
-- local ACT_BATTLE_PASS_TASK = ConfigManager:getConfig("act_battle_pass_task")
|
||||
-- local MALL_ACT = ConfigManager:getConfig("mall_act")
|
||||
local BOUNTY_TYPE = 8
|
||||
|
||||
function BountyData:getTimeStr()
|
||||
local endTime = self:getEndTime()
|
||||
local remainTime = endTime - Time:getServerTime()
|
||||
if remainTime < 0 then
|
||||
remainTime = 0
|
||||
end
|
||||
return Time:formatNumTimeStr(remainTime)
|
||||
end
|
||||
|
||||
function BountyData:getRp()
|
||||
return self:getTaskRp() or self:getLevelRp()
|
||||
end
|
||||
|
||||
function BountyData:gotoBtnFunc()
|
||||
ModuleManager.BountyManager:showUI()
|
||||
end
|
||||
|
||||
function BountyData:getIsOpen()
|
||||
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.BATTLE_PASS, true) then
|
||||
return false
|
||||
end
|
||||
if self.endTime and self.endTime > 0 and self.endTime > Time:getServerTime() then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function BountyData:ctor()
|
||||
self:clear()
|
||||
end
|
||||
|
||||
function BountyData:clear()
|
||||
self.season = 1
|
||||
self.level = 1
|
||||
self.exp = 0
|
||||
self.bought = false
|
||||
self.highCount = 0
|
||||
self.count = 0
|
||||
self.tasks = {}
|
||||
self.weekRefreshTime = 0
|
||||
self.maxLevel = nil
|
||||
self.data.isDirty = false
|
||||
DataManager:unregisterCrossDayFunc("BountyData")
|
||||
end
|
||||
|
||||
function BountyData:setDirty()
|
||||
self.data.isDirty = not self.data.isDirty
|
||||
end
|
||||
|
||||
function BountyData:init(data, isInit)
|
||||
-- data = data or {}
|
||||
|
||||
-- self.season = data.season or 1
|
||||
-- self.level = data.level or 1
|
||||
-- self.exp = data.exp or 0
|
||||
-- self.bought = data.bought or false
|
||||
-- self.tasks = data.tasks or {}
|
||||
-- self.highCount = data.pro_claimed or 0
|
||||
-- self.count = data.claimed or 0
|
||||
-- self.maxLevel = nil
|
||||
|
||||
-- self.weekRefreshTime = Time:getWeekOverTimeStamp()
|
||||
|
||||
-- self:initFuncTime()
|
||||
|
||||
-- if isInit then
|
||||
-- self:initTaskListener()
|
||||
-- DataManager:registerCrossDayFunc("BountyData", function()
|
||||
-- local needRefreshWeek = self.weekRefreshTime < Time:getServerTime()
|
||||
-- self.weekRefreshTime = Time:getWeekOverTimeStamp()
|
||||
-- local list = self:getTaskList()
|
||||
-- for _, id in ipairs(list) do
|
||||
-- if self:getTaskIsDailyRefresh(id) or needRefreshWeek then
|
||||
-- self:getTaskInfo(id).progress = 0
|
||||
-- self:getTaskInfo(id).claimed = false
|
||||
-- end
|
||||
-- end
|
||||
-- self:initFuncTime()
|
||||
-- self:setDirty()
|
||||
-- end)
|
||||
-- end
|
||||
end
|
||||
|
||||
function BountyData:getBannerName()
|
||||
return "bounty_btn_main_1"
|
||||
end
|
||||
|
||||
function BountyData:refreshTask(task)
|
||||
if not task then
|
||||
return
|
||||
end
|
||||
self.tasks[task.id] = task
|
||||
end
|
||||
|
||||
function BountyData:refreshLevelRewardInfo(data)
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
self.highCount = data.pro_claimed or 0
|
||||
self.count = data.claimed or 0
|
||||
end
|
||||
|
||||
function BountyData:refreshLevelInfo(data)
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
self.level = data.level or 0
|
||||
self.exp = data.exp or 0
|
||||
end
|
||||
|
||||
function BountyData:setBoughtStatus(data)
|
||||
if not data then
|
||||
return
|
||||
end
|
||||
self.bought = data.bought or false
|
||||
end
|
||||
|
||||
function BountyData:initFuncTime()
|
||||
if not self.seasonList then
|
||||
self.seasonList = {}
|
||||
for id, info in pairs(MALL_ACT) do
|
||||
if info.type == BOUNTY_TYPE then
|
||||
table.insert(self.seasonList, id)
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(self.seasonList, function(a, b)
|
||||
return a < b
|
||||
end)
|
||||
end
|
||||
|
||||
local nowTime = Time:getServerTime()
|
||||
if self.endTime and self.endTime > 0 and self.endTime > nowTime then
|
||||
return
|
||||
end
|
||||
|
||||
if (not self.endTime or self.endTime <= nowTime) and self.season then
|
||||
local cfg = MALL_ACT[self.season]
|
||||
if cfg then
|
||||
self.startTime = Time:getCertainTimeByStr2(cfg.start_time)
|
||||
self.endTime = Time:getCertainTimeByStr2(cfg.end_time)
|
||||
end
|
||||
end
|
||||
|
||||
if not self.endTime or self.endTime <= nowTime then
|
||||
for _, id in ipairs(self.seasonList) do
|
||||
local cfg = MALL_ACT[id]
|
||||
local startTime = Time:getCertainTimeByStr2(cfg.start_time)
|
||||
local endTime = Time:getCertainTimeByStr2(cfg.end_time)
|
||||
if startTime <= nowTime and endTime > nowTime then
|
||||
self.startTime = startTime
|
||||
self.endTime = endTime
|
||||
self.season = id
|
||||
self.bought = false
|
||||
self.level = 1
|
||||
self.exp = 0
|
||||
self.highCount = 0
|
||||
self.count = 0
|
||||
self.maxLevel = nil
|
||||
BIReport:postBattlePassOpen()
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BountyData:getEndTime()
|
||||
return self.endTime or 0
|
||||
end
|
||||
|
||||
function BountyData:getSeasonRewardList()
|
||||
if not self.seasonRewardList then
|
||||
self.seasonRewardList = {}
|
||||
for id, info in pairs(ACT_BATTLE_PASS) do
|
||||
local season = info.mall_id
|
||||
if not self.seasonRewardList[season] then
|
||||
self.seasonRewardList[season] = {}
|
||||
end
|
||||
table.insert(self.seasonRewardList[season], id)
|
||||
end
|
||||
|
||||
for season, list in pairs(self.seasonRewardList) do
|
||||
table.sort(self.seasonRewardList[season], function(a, b)
|
||||
return a < b
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
return self.seasonRewardList[self.season] or {}
|
||||
end
|
||||
|
||||
function BountyData:getSeason()
|
||||
return self.season
|
||||
end
|
||||
|
||||
function BountyData:getSeasonTx()
|
||||
local cfg = I18N:getConfig("mall_act")[self.season]
|
||||
if cfg and cfg.name then
|
||||
return cfg.name
|
||||
end
|
||||
return GConst.EMPTY_STRING
|
||||
end
|
||||
|
||||
function BountyData:getRechargeId()
|
||||
local cfg = ConfigManager:getConfig("mall_act")[self.season]
|
||||
if cfg then
|
||||
return cfg.recharge_id
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function BountyData:getLevel()
|
||||
return self.level
|
||||
end
|
||||
|
||||
function BountyData:getMaxLevel()
|
||||
if not self.maxLevel then
|
||||
self.maxLevel = #self:getSeasonRewardList()
|
||||
end
|
||||
return self.maxLevel
|
||||
end
|
||||
|
||||
function BountyData:getIsMaxLevel()
|
||||
return self.level >= self:getMaxLevel()
|
||||
end
|
||||
|
||||
function BountyData:getExp()
|
||||
return self.exp
|
||||
end
|
||||
|
||||
function BountyData:getBought()
|
||||
return self.bought
|
||||
end
|
||||
|
||||
function BountyData:getCurNeedExp(lv)
|
||||
lv = lv or self.level + 1
|
||||
local id = self:getSeasonRewardList()[lv]
|
||||
if not id then
|
||||
id = self:getSeasonRewardList()[self:getMaxLevel()]
|
||||
end
|
||||
|
||||
if not id then
|
||||
return 1
|
||||
end
|
||||
|
||||
return ACT_BATTLE_PASS[id].exp
|
||||
end
|
||||
|
||||
function BountyData:getRewardById(id)
|
||||
return ACT_BATTLE_PASS[id].reward
|
||||
end
|
||||
|
||||
function BountyData:getProRewardById(id)
|
||||
return ACT_BATTLE_PASS[id].reward_pro
|
||||
end
|
||||
|
||||
function BountyData:getClaimed(index)
|
||||
return self.count >= index
|
||||
end
|
||||
|
||||
function BountyData:getHighClaimed(index)
|
||||
return self.highCount >= index
|
||||
end
|
||||
|
||||
function BountyData:getCount()
|
||||
return self.count
|
||||
end
|
||||
|
||||
function BountyData:getHighCount()
|
||||
return self.highCount
|
||||
end
|
||||
|
||||
function BountyData:getTaskList()
|
||||
if not self.taskList then
|
||||
self.taskList = {}
|
||||
for id, info in pairs(ACT_BATTLE_PASS_TASK) do
|
||||
local season = info.mall_id
|
||||
if not self.taskList[season] then
|
||||
self.taskList[season] = {}
|
||||
end
|
||||
|
||||
table.insert(self.taskList[season], id)
|
||||
end
|
||||
end
|
||||
|
||||
return self.taskList[self.season] or {}
|
||||
end
|
||||
|
||||
function BountyData:getTaskListByType(taskType)
|
||||
if not self.taskTypeMap then
|
||||
self.taskTypeMap = {}
|
||||
for id, info in pairs(ACT_BATTLE_PASS_TASK) do
|
||||
if not self.taskTypeMap[info.type] then
|
||||
self.taskTypeMap[info.type] = {}
|
||||
end
|
||||
table.insert(self.taskTypeMap[info.type], id)
|
||||
end
|
||||
end
|
||||
|
||||
return self.taskTypeMap[taskType] or {}
|
||||
end
|
||||
|
||||
function BountyData:getTaskType(id)
|
||||
return ACT_BATTLE_PASS_TASK[id].type
|
||||
end
|
||||
|
||||
function BountyData:getTaskParamater(id)
|
||||
return ACT_BATTLE_PASS_TASK[id].parameter
|
||||
end
|
||||
|
||||
function BountyData:getTaskExp(id)
|
||||
return ACT_BATTLE_PASS_TASK[id].exp_reward
|
||||
end
|
||||
|
||||
function BountyData:getTaskIsDailyRefresh(id)
|
||||
return ACT_BATTLE_PASS_TASK[id].refresh_type == 1
|
||||
end
|
||||
|
||||
function BountyData:getTaskInfo(id)
|
||||
if not self.tasks[id] then
|
||||
self.tasks[id] = {
|
||||
id = id,
|
||||
progress = 0,
|
||||
claimed = false
|
||||
}
|
||||
end
|
||||
|
||||
return self.tasks[id]
|
||||
end
|
||||
|
||||
function BountyData:addTaskProgress(id, count)
|
||||
if not count or count <= 0 then
|
||||
return
|
||||
end
|
||||
self:getTaskInfo(id).progress = self:getTaskInfo(id).progress + count
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function BountyData:getTaskCount(id)
|
||||
return self:getTaskInfo(id).progress
|
||||
end
|
||||
|
||||
function BountyData:getTaskCaimed(id)
|
||||
return self:getTaskInfo(id).claimed
|
||||
end
|
||||
|
||||
function BountyData:getTaskCanCaimed(id)
|
||||
if self:getTaskCaimed(id) then
|
||||
return false
|
||||
end
|
||||
if not self:getTaskIsDailyRefresh(id) and not self:getBought() then
|
||||
return false
|
||||
end
|
||||
return self:getTaskInfo(id).progress >= self:getTaskParamater(id)
|
||||
end
|
||||
|
||||
function BountyData:initTaskListener()
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_SUMMON, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_SUMMON)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_HOE_USE, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_HOE_USE)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_JEWELRY_BATTLE, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_JEWELRY_BATTLE)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_GOLD_BATTLE, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_GOLD_BATTLE)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_MITHRIL_BATTLE, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_MITHRIL_BATTLE)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_ARENA_CHALLENGE, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_ARENA_CHALLENGE)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
|
||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY, function(count)
|
||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY)
|
||||
for _, id in ipairs(list) do
|
||||
self:addTaskProgress(id, count)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function BountyData:getTaskRp()
|
||||
local taskList = self:getTaskList()
|
||||
for _, id in ipairs(taskList) do
|
||||
if self:getTaskCanCaimed(id) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function BountyData:getLevelRp()
|
||||
if self.level > self.count then
|
||||
return true
|
||||
end
|
||||
|
||||
if self.bought and self.level > self.highCount then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return BountyData
|
||||
10
lua/app/userdata/bounty/bounty_data.lua.meta
Normal file
10
lua/app/userdata/bounty/bounty_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d566564ac5ce938488f779c6d9466503
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -3,6 +3,7 @@ local PlayerData = class("PlayerData", BaseData)
|
||||
function PlayerData:init(data)
|
||||
data = data or {}
|
||||
self.data.level = data.level or 1
|
||||
self.data.dirty = false
|
||||
self.loginDay = data.loginDay or 1
|
||||
self.lastLoginTime = data.lastLoginTime or Time:getBeginningOfServerToday()
|
||||
end
|
||||
@ -26,6 +27,10 @@ function PlayerData:getLv()
|
||||
return self.data.level
|
||||
end
|
||||
|
||||
function PlayerData:getExpPercent()
|
||||
return 0
|
||||
end
|
||||
|
||||
function PlayerData:getLoginDay()
|
||||
return self.loginDay
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user