一些系统代码

This commit is contained in:
chenxi 2023-05-05 10:32:50 +08:00
parent a430306743
commit 47cd13f4ad
104 changed files with 1766 additions and 824 deletions

View File

@ -13,6 +13,8 @@ function DataManager:init()
self:initManager("BattleData", "app/userdata/battle/battle_data")
self:initManager("FormationData", "app/userdata/formation/formation_data")
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
-- self:initManager("IdleData", "app/userdata/idle/idle_data")
-- self:initManager("SevenDayData", "app/userdata/activity/seven_day/seven_day_data")
end
function DataManager:initManager(name, path)
@ -71,6 +73,8 @@ function DataManager:clear()
self.HeroData:clear()
self.BagData:clear()
self.FormationData:clear()
-- self.IdleData:clear()
-- self.SevenDayData:clear()
ModuleManager.TaskManager:clear()
end
@ -90,6 +94,8 @@ function DataManager:initWithServerData(data)
self.BagData:init(data.BagData)
self.FormationData:init(data.FormationData)
self.TutorialData:init(data.TutorialData)
-- self.IdleData:clear(data.IdleData)
-- self.SevenDayData:init(data.SevenDayData)
self:scheduleGlobal()
self:checkDataBind()

View File

@ -14,6 +14,12 @@ local MODULE_PATHS = {
FormationManager = "app/module/formation/formation_manager",
HeroManager = "app/module/hero/hero_manager",
ChapterManager = "app/module/chapter/chapter_manager",
-- 挂机
IdleManager = "app/module/idle/idle_manager",
-- 活动
-- SevenDayManager = "app/module/activity/seven_day/seven_day_manager",
-- 设置
GameSettingManager = "app/module/game_setting/game_setting_manager",
}
-- 这里的key对应func_open里的id

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3b293e842f788104e8b98d4ba2b6e2c9
guid: 6e3e0d09097ce624f8d4b5ae32986f8a
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,102 @@
local SevenDayManager = class("SevenDayManager", BaseModule)
function SevenDayManager:showUI()
UIManager:showUI("app/ui/activity/seven_day/seven_day_ui")
end
function SevenDayManager:claimTask(ids)
if not DataManager.SevenDayData:getIsOpen() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACTIVITY_OVER_DESC))
return
end
local rewards = {}
local tasks = {}
local specialType = {}
local specialTypeCount = 0
for _, id in ipairs(ids) do
if DataManager.SevenDayData:taskCollected(id) then
return
end
if not DataManager.SevenDayData:canClaimTask(id) then
return
end
local taskType = ModuleManager.TaskManager:dealTaskType(DataManager.SevenDayData:getTaskType(id), nil, true)
if taskType then
specialType[taskType] = true
specialTypeCount = specialTypeCount + 1
end
table.insert(rewards, GFunc.getRewardTableByReward(DataManager.SevenDayData:getTaskReward(id)))
tasks[id] = {
id = id,
-- progress = DataManager.SevenDayData:taskTotalCount(id),
progress = DataManager.SevenDayData:taskCount(id),
claimed = true
}
end
local params = {ids = ids}
local responseData = {
rewards = rewards,
tasks = tasks,
}
if specialTypeCount > 0 then
for tasktype, b in pairs(specialType) do
ModuleManager.TaskManager:dealTaskType(tasktype, function()
specialTypeCount = specialTypeCount - 1
if specialTypeCount <= 0 then
self:sendMessage(ProtoMsgType.FromMsgEnum.TaskTutorRewardReq, {}, {}, self.claimTaskFinish, BIReport.ITEM_GET_TYPE.TUTORIAL_TASK)
end
end)
end
else
self:sendMessage(ProtoMsgType.FromMsgEnum.SevenDayTaskRewardReq, params, responseData, self.claimTaskFinish, BIReport.ITEM_GET_TYPE.SEVEN_DAY_TASK)
end
end
function SevenDayManager:claimTaskFinish(result)
if result.status == 0 then
GFunc.showRewardBox(result.rewards)
DataManager.SevenDayData:refreshTasks(result.tasks)
DataManager.SevenDayData:setDirty()
end
end
function SevenDayManager:claimStepReward(id)
if not DataManager.SevenDayData:getIsOpen() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACTIVITY_OVER_DESC))
return
end
if DataManager.SevenDayData:getStepCollected(id) then
return
end
if not DataManager.SevenDayData:canClaimStepTask(id) then
return
end
local params = {id = id}
local responseData = {
rewards = {GFunc.getRewardTableByReward(DataManager.SevenDayData:getStepReward(id))},
Claimed = {
[id] = true
}
}
self:sendMessage(ProtoMsgType.FromMsgEnum.SevenDayRewardReq, params, responseData, self.claimStepRewardFinish, BIReport.ITEM_GET_TYPE.SEVEN_DAY_STEP_REWARD)
end
function SevenDayManager:claimStepRewardFinish(result)
if result.status == 0 then
GFunc.showRewardBox(result.rewards)
DataManager.SevenDayData:refreshClaimed(result.Claimed)
DataManager.SevenDayData:setDirty()
end
end
return SevenDayManager

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 1eefb6a440fbc3c4b80c11d5a2196e6f
guid: 3fdb6f3ad506b164384e16409f578595
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 65d2bb50a42d31042be24d9005ee29dc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e9109457b732f2946ac3d78aeb1633ec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 164ac0b8b564cfd4d9e76e0bc0bc6f8e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0154b82c640abfb449624dd011e49e8d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: d52e7f500dcac3a4b93856ac65ac28e7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 61e52f2b86dadd14f83059c5e25de608
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
local GameSettingManager = class("GameSettingManager", BaseModule)
function GameSettingManager:showSettingUI()
UIManager:showUI("app/ui/game_setting/game_setting_ui")
end
function GameSettingManager:showLanguageUI()
UIManager:showUI("app/ui/game_setting/language_ui")
end
function GameSettingManager:showPlayerUpUI(params)
UIManager:showUI("app/ui/player/player_up_ui", params)
end
function GameSettingManager:showCDKeyUI(params)
UIManager:showUI("app/ui/game_setting/cdkey_ui", params)
end
return GameSettingManager

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 20fd3c8dcaa786e4eb1fe8b97f35906c
guid: 6f2ad15d6a4e2c6449e036400a4d2215
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 81bb98ddb57cb2644aabb194838201cb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 06aa6e749a066d643bf326424e10354e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
local IdleManager = class("IdleManager", BaseModule)
function IdleManager:showIdleDropUI(params)
UIManager:showUI("app/ui/idle/idle_drop_ui", params)
end
function IdleManager:showIdleQuickDropUI(params)
UIManager:showUI("app/ui/idle/idle_quick_drop_ui", params)
end
function IdleManager:getIdleRewrad()
end
function IdleManager:getHangUpQuickRewrad()
end
return IdleManager

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 709839b9a220e6c418ede26e1f7e95d1
guid: 51f9f8a1082187641a042e8e31a40726
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e671c325ff6015247aacf3a0e504fb45
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 7ddf660679f89a44bb6c7df1ade4e763
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -16,4 +16,14 @@ MainCityConst.BOTTOM_MODULE_KEY = {
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"
}
MainCityConst.RIGHT_SIDE_BARS = {
"app/ui/main_city/cell/side_bar_mail_cell",
}
return MainCityConst

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1352dd1cd25bd2c4db3b3c76c8565122
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: fe2ff1bab3dc2494884c455761f41149
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 40d69f97441a752428590e0c1b5955de
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f1c7fc94c9b65ed4ea3f5da51bca6d92
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8d1b2e3e302a7014f9303731095873f3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0ef1450429a7f2444b8962ad1e3df20f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0db7cba0f52688c4491b94ebad1f5338
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 2349851ad96deb742bfe7ee435867642
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: dbf3ba26ac998e14faf5c85cf4d7a4e0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e36ae8e88614c8a4b934a0cfbf5dd590
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9cbf2d1e989d90542a4222c9e717bb92
guid: 7bac277fb0fe3a3468738e9906b96dd8
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0de7a644b742b3f48b51863a844aae01
guid: bc98a28f4a7cea144951f2e3a6b5ae84
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,109 @@
local TaskCell = class("TaskCell", BaseCell)
local TIPS_ICON = {
"common_dec_9",
"common_dec_10"
}
function TaskCell:refresh(id, idx, showAction)
local canClaimTask = DataManager.SevenDayData:canClaimTask(id)
local collected = DataManager.SevenDayData:taskCollected(id)
local count = DataManager.SevenDayData:taskCount(id)
local totalCount = DataManager.SevenDayData:taskTotalCount(id)
if collected or count > totalCount then
count = totalCount
end
local isAdTask = false
local reward = DataManager.SevenDayData:getTaskReward(id)
local uiMap = self:getUIMap()
local tipsIcon = uiMap["task_cell.bg.tips_icon"]
if canClaimTask or collected then
tipsIcon:setSprite(GConst.ATLAS_PATH.COMMON, TIPS_ICON[2])
else
tipsIcon:setSprite(GConst.ATLAS_PATH.COMMON, TIPS_ICON[1])
end
local desc = uiMap["task_cell.bg.desc"]
local progressStr = ModuleManager.TaskManager:getTaskDesc(DataManager.SevenDayData:getTaskType(id), count, totalCount)
desc:setText(progressStr)
local sliderOver = uiMap["task_cell.bg.slider_bg.slider_over"]
sliderOver:setVisible(count >= totalCount)
local sliderComp = uiMap["task_cell.bg.slider_bg.slider"]
sliderComp:setVisible(count < totalCount)
sliderComp:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = count / totalCount
if not self.rewardCell then
self.rewardCell = CellManager:addCellComp(uiMap["task_cell.bg.reward_cell"], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
end
self.rewardCell:refreshByConfig(reward)
local claimBtn = uiMap["task_cell.bg.cliam_btn"]
claimBtn:addClickListener(function()
local list = DataManager.SevenDayData:getTaskListByDay(DataManager.SevenDayData:getTaskDay(id))
local ids = {}
for _, taskId in ipairs(list) do
if DataManager.SevenDayData:canClaimTask(taskId) then
table.insert(ids, taskId)
end
end
if not ids[1] then
return
end
ModuleManager.SevenDayManager:claimTask(ids)
end)
local claimAdIcon = uiMap["task_cell.bg.cliam_btn.icon"]
GFunc.setAdsSprite(claimAdIcon)
claimAdIcon:setVisible(isAdTask)
local claimBtntx = uiMap["task_cell.bg.cliam_btn.tx"]
if isAdTask then
claimBtntx:setText(GConst.EMPTY_STRING)
else
claimBtntx:setText(I18N:getGlobalText(I18N.GlobalConst.GET_REWARDS_1))
end
local greyBtn = uiMap["task_cell.bg.grey_btn"]
greyBtn:setVisible(not canClaimTask)
local greyAdIcon = uiMap["task_cell.bg.grey_btn.icon"]
GFunc.setAdsSprite(greyAdIcon, true)
greyAdIcon:setVisible(isAdTask)
local greyBtntx = uiMap["task_cell.bg.grey_btn.tx"]
if isAdTask then
greyBtntx:setText(GConst.EMPTY_STRING)
else
greyBtntx:setText(I18N:getGlobalText(I18N.GlobalConst.GET_REWARDS_1))
end
if collected then
greyAdIcon:setVisible(false)
greyBtntx:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_DONE))
end
local mask = uiMap["task_cell.bg.mask"]
mask:setVisible(collected)
local maskTips = uiMap["task_cell.bg.mask.tx"]
maskTips:setText(I18N:getGlobalText(I18N.GlobalConst.DAILY_TASK_DESC_2))
local overBg = uiMap["task_cell.bg.bg2"]
overBg:setVisible(count >= totalCount)
local bg = uiMap["task_cell.bg"]
if not bg.aniSeq then
if showAction then
if bg.aniSeq then
bg:setAnchoredPositionX(0)
else
GFunc.createListMoveXAction(bg, (idx - 1)*0.1, 720, -100, 0)
end
else
bg:setAnchoredPositionX(0)
end
end
end
return TaskCell

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f76a9cd8a3bc37b489b8fa25d483e02e
guid: a4afbec80f4beef448f851611884982b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}

View File

@ -0,0 +1,215 @@
local SevenDayUI = class("SevenDayUI", BaseUI)
local TASK_CELL = "app/ui/activity/seven_day/cell/task_cell"
function SevenDayUI:getPrefabPath()
return "assets/prefabs/ui/activity/seven_day/seven_day_ui.prefab"
end
function SevenDayUI:ctor()
self.day = 1 -- 默认
end
function SevenDayUI:srotTaskList(day)
self.day = day
self.taskList = DataManager.SevenDayData:getTaskListByDay(day or 1)
table.sort(self.taskList, function(a, b)
local aClaimed = DataManager.SevenDayData:taskCollected(a)
local bClaimed = DataManager.SevenDayData:taskCollected(b)
if aClaimed == false and aClaimed == bClaimed then
local aCan = DataManager.SevenDayData:canClaimTask(a)
local bCan = DataManager.SevenDayData:canClaimTask(b)
if aCan == bCan then
return a < b
else
return aCan
end
else
if aClaimed == bClaimed then
return a < b
else
return not aClaimed
end
end
end)
end
function SevenDayUI:onLoadRootComplete()
self:_display()
self:_addListeners()
self:_bind()
self.sid = self:scheduleGlobal(function()
self:updateTime()
end, 1)
self:updateTime()
end
function SevenDayUI:_display()
local uiMap = self.root:genAllChildren()
uiMap["seven_day_ui.title_bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.SEVEN_DAY_DESC_1))
uiMap["seven_day_ui.img_3.btn_all.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.SEVEN_DAY_DESC_4))
uiMap["seven_day_ui.img_3.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_SEVENDAY_DESC))
local rect = uiMap["seven_day_ui.scrollrect"]:getRectSize()
self.maxVisibleCell = math.ceil(rect.height/120)
self:refreshDay()
self:refreshStepInfo()
self:refreshScrollRect()
end
function SevenDayUI:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["seven_day_ui.img_3.btn_close"]:addClickListener(function()
self:closeUI()
end)
uiMap["seven_day_ui.img_3.btn_all"]:addClickListener(function()
local list = DataManager.SevenDayData:getTaskListByDay(self.day or 1)
local ids = {}
for _, id in ipairs(list) do
if DataManager.SevenDayData:canClaimTask(id) then
table.insert(ids, id)
end
end
if not ids[1] then
return
end
ModuleManager.SevenDayManager:claimTask(ids)
end)
for i = 1, 7 do
local obj = uiMap["seven_day_ui.day_node.day_" .. i]
obj:addClickListener(function()
if i > DataManager.SevenDayData:getActDay() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACT_SEVENDAY_DESC_1, i))
return
end
self.day = i
self:refreshDay()
self:refreshScrollRect()
end)
end
end
function SevenDayUI:_bind()
self:bind(DataManager.SevenDayData, "isDirty", function()
self:refreshDay()
self:refreshStepInfo()
self:refreshScrollRect()
end)
end
function SevenDayUI:refreshStepInfo()
local uiMap = self.root:genAllChildren()
local list = DataManager.SevenDayData:getStepRewardList()
if not self.stepObjs then
self.stepObjs = {}
for i = 1, 7 do
self.stepObjs[i] = {
icon = uiMap["seven_day_ui.total_node.icon_" .. i],
line = uiMap["seven_day_ui.total_node.line_" .. i],
lock = uiMap["seven_day_ui.total_node.lock_" .. i],
check = uiMap["seven_day_ui.total_node.check_" .. i],
num = uiMap["seven_day_ui.total_node.num_" .. i],
count = uiMap["seven_day_ui.total_node.count_" .. i],
light = uiMap["seven_day_ui.total_node.light_" .. i]
}
end
end
for index, objs in ipairs(self.stepObjs) do
local id = list[index]
if id then
local reward = DataManager.SevenDayData:getStepReward(id)
objs.icon:setSprite(ModuleManager.ItemManager:getItemIcon(reward.id))
objs.num:setText("")
objs.line:setVisible(DataManager.SevenDayData:stepOver(id))
objs.lock:setVisible(not DataManager.SevenDayData:stepOver(id))
objs.check:setVisible(DataManager.SevenDayData:getStepCollected(id))
objs.count:setText(DataManager.SevenDayData:getStepNum(id))
if DataManager.SevenDayData:canClaimStepTask(id) then
objs.icon:addClickListener(function()
ModuleManager.SevenDayManager:claimStepReward(id)
end)
objs.light:setVisible(true)
else
objs.icon:addClickListener(function()
ModuleManager.TipsManager:showRewardTips(reward.id, reward.type, objs.icon)
end)
objs.light:setVisible(false)
end
end
end
local desc = uiMap["seven_day_ui.total_node.desc"]
local check = uiMap["seven_day_ui.total_node.check"]
local count = DataManager.SevenDayData:getCollectedCount()
local totalCount = DataManager.SevenDayData:getTotalCount()
desc:setText(I18N:getGlobalText(I18N.GlobalConst.SEVEN_DAY_DESC_3, count, totalCount))
GFunc.centerImgAndTx(check, desc, 9)
local slider = uiMap["seven_day_ui.total_node.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
slider.value = count / totalCount
end
function SevenDayUI:refreshDay()
local uiMap = self.root:genAllChildren()
local highLight = uiMap["seven_day_ui.day_node.page_hl"]
local actDay = DataManager.SevenDayData:getActDay()
for i = 1, 7 do
local obj = uiMap["seven_day_ui.day_node.day_" .. i]
local dayStr = I18N:getGlobalText(I18N.GlobalConst.DAY_DESC1, i)
if i > actDay then
dayStr = string.format("<color=#BCB6B6>%s</color>", dayStr)
end
obj:setText(dayStr)
if i == self.day then
highLight:setAnchoredPositionX(obj:getAnchoredPosition().x)
end
if DataManager.SevenDayData:showRedPoint(i) and i <= actDay then
obj:addRedPoint(40, 26, 0.5)
else
obj:removeRedPoint()
end
end
end
function SevenDayUI:refreshScrollRect()
self:srotTaskList(self.day)
if self.scrollRect then
self.scrollRect:updateAllCell()
return
end
local uiMap = self.root:genAllChildren()
local scrollView = uiMap["seven_day_ui.scrollrect"]
self.scrollRect = scrollView:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRect:addInitCallback(function()
return TASK_CELL
end)
self.scrollRect:addRefreshCallback(function(index, cell)
cell:refresh(self.taskList[index], index, self.maxVisibleCell > 0)
self.maxVisibleCell = self.maxVisibleCell - 1
end)
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.taskList)
end
function SevenDayUI:updateTime()
local uiMap = self.root:genAllChildren()
local timeObj = uiMap["seven_day_ui.title_bg.time"]
local endTime = DataManager.SevenDayData:getEndTime()
local remainTime = endTime - Time:getServerTime()
local str
if remainTime > 0 then
str = I18N:getGlobalText(I18N.GlobalConst.SEVEN_DAY_DESC_2, Time:formatNumTimeStr(remainTime))
else
str = I18N:getGlobalText(I18N.GlobalConst.ADVENTURE_CLOSED)
end
timeObj:setText(str)
end
return SevenDayUI

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: df5ee3920131a6c44b1e0d7712bf9159
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 38336606149b3fd42bc2bc5550b6b55d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1c7e80e28a8bd214b86fc43d962e9ad7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3bb47a02f3f435d4fa1258bcc55fa378
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 17b83d5589ee5a14e8db7d4e773fcbfb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: df037f5d780e75640a04da123e60cd06
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: df9024c6309c8624d8eeb6523477baff
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c6f2207298c099d44ad2591ab6026e59
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: a12e5138b57ce454c96d772e47fa97ae
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,203 @@
local GameSettingUI = class("GameSettingUI", BaseUI)
local BG_HEIGHT = {
NORMAL = 930,
[GConst.LANGUAGE.VIETNAMESE] = 812
}
local SWITCH_TX_COLOR = "#707390"
local IOS_ICON = "setting_decoration_8"
local GOOGLE_ICON = "setting_decoration_9"
local CHECK_WHITE_LIST_COUNT = 5
function GameSettingUI:ctor()
self.clickMusicCount = 0
end
function GameSettingUI:isFullScreen()
return false
end
function GameSettingUI:getPrefabPath()
return "assets/prefabs/ui/setting/game_setting_ui.prefab"
end
function GameSettingUI:onLoadRootComplete()
self:_display()
self:_addListeners()
self:_bind()
end
function GameSettingUI:onPressBackspace()
self:closeUI()
end
function GameSettingUI:_display()
local uiMap = self.root:genAllChildren()
uiMap["game_setting_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.SETTING_DESC))
uiMap["game_setting_ui.bg.support_btn.status"]:setText(I18N:getGlobalText(I18N.GlobalConst.SUPPORT_DESSC))
uiMap["game_setting_ui.bg.player_id_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.COPY_ID))
uiMap["game_setting_ui.bg.exchange_btn.status"]:setText(I18N:getGlobalText(I18N.GlobalConst.SETTING_DESC_1))
local language = I18N:getCurLanguage()
uiMap["game_setting_ui.bg.language_btn.status"]:setSprite(GConst.ATLAS_PATH.UI_SETTING, "language_" .. language)
if CS.BF.BFMain.IsShenhe then
uiMap["game_setting_ui.bg.bg"]:setVisible(false)
end
uiMap["game_setting_ui.bg.tx_1"]:setText(I18N:getGlobalText(I18N.GlobalConst.SERVICE_DESC))
uiMap["game_setting_ui.bg.tx_2"]:setText(I18N:getGlobalText(I18N.GlobalConst.PRIVACY_DESC))
self.helpNode = uiMap["game_setting_ui.help_node"]
local helpTipsBG = uiMap["game_setting_ui.help_node.help_tips"]
local helpTips = uiMap["game_setting_ui.help_node.help_tips.desc"]
helpTips:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_INFO_TIPS))
local h = helpTips:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredHeight
helpTips:setSizeDeltaY(h)
helpTipsBG:setSizeDeltaY(h + 39)
self.helpNode:setActive(false)
self:refreshMusic()
self:refreshVoice()
self:refreshShenhe()
self:refreshBGHeight()
end
function GameSettingUI:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["game_setting_ui.bg.close_btn"]:addClickListener(function()
self:closeUI()
end)
uiMap["game_setting_ui.bg.music_bg"]:addClickListener(function()
local status = AudioManager:isMusicEnabled()
if not status then
AudioManager:setMusicVolume(1)
else
AudioManager:setMusicVolume(0)
end
if CS.BF.BFMain.IsWhite then
self.clickMusicCount = self.clickMusicCount + 1
if self.clickMusicCount > CHECK_WHITE_LIST_COUNT then
GFunc.showToast("Please dont frequently operate")
end
end
self:refreshMusic()
end)
uiMap["game_setting_ui.bg.voice_bg"]:addClickListener(function()
local status = AudioManager:isEffectEnabled()
if not status then
AudioManager:setEffectVolume(1)
else
AudioManager:setEffectVolume(0)
end
self:refreshVoice()
end)
uiMap["game_setting_ui.bg.language_btn"]:addClickListener(function()
ModuleManager.GameSettingManager:showLanguageUI()
end)
uiMap["game_setting_ui.bg.support_btn"]:addClickListener(function()
ModuleManager.GameSettingManager:sendSupport()
DataManager.AiHelpData:setUnreadCount()
end)
uiMap["game_setting_ui.bg.player_id_btn"]:addClickListener(function()
local ServerGameData = require "app/module/server/server_game_data"
local objectId = ServerGameData:getServerPlayerId() or ""
GFunc.copyStr(objectId)
end)
uiMap["game_setting_ui.bg.bg.facebook"]:addClickListener(function()
local url = GConst.GameSettingConst.SOCIAL_URL[I18N:getCurLanguage()]
if not url then
url = GConst.GameSettingConst.SOCIAL_URL.normal
end
GFunc.openUrl(url)
end)
uiMap["game_setting_ui.bg.bg.discord"]:addClickListener(function()
local url = GConst.GameSettingConst.COMMUNITY_URL[I18N:getCurLanguage()]
if not url then
url = GConst.GameSettingConst.COMMUNITY_URL.normal
end
GFunc.openUrl(url)
end)
uiMap["game_setting_ui.bg.exchange_btn"]:addClickListener(function()
ModuleManager.GameSettingManager:showCdkeyUI()
end)
uiMap["game_setting_ui.bg.tx_1"]:addClickListener(function()
GFunc.openUrl("https://cobbygame.com/tos.html")
end)
uiMap["game_setting_ui.bg.tx_2"]:addClickListener(function()
GFunc.openUrl("https://www.cobbygame.com/pp.html")
end)
uiMap["game_setting_ui.bg.point"]:addClickListener(function()
if self.helpNode then
self.helpNode:setActive(true)
end
end)
self.helpNode:addClickListener(function()
self.helpNode:setActive(false)
end)
end
function GameSettingUI:_bind()
end
function GameSettingUI:refreshMusic()
local uiMap = self.root:genAllChildren()
local offIcon = uiMap["game_setting_ui.bg.music_bg.off"]
local onIcon = uiMap["game_setting_ui.bg.music_bg.on"]
local status = AudioManager:isMusicEnabled()
offIcon:setVisible(status ~= true)
onIcon:setVisible(status == true)
end
function GameSettingUI:refreshVoice()
local uiMap = self.root:genAllChildren()
local offIcon = uiMap["game_setting_ui.bg.voice_bg.off"]
local onIcon = uiMap["game_setting_ui.bg.voice_bg.on"]
local status = AudioManager:isEffectEnabled()
offIcon:setVisible(status ~= true)
onIcon:setVisible(status == true)
end
function GameSettingUI:refreshShenhe()
local uiMap = self.root:genAllChildren()
local codeBtn = uiMap["game_setting_ui.bg.exchange_btn"]
local codeBg = uiMap["game_setting_ui.bg.exchange_bg"]
local supportBtn = uiMap["game_setting_ui.bg.support_btn"]
local supportBg = uiMap["game_setting_ui.bg.support_bg"]
codeBtn:setActive(not GFunc.isShenhe())
codeBg:setActive(not GFunc.isShenhe())
supportBtn:setActive(not GFunc.isShenhe())
supportBg:setActive(not GFunc.isShenhe())
end
function GameSettingUI:refreshBGHeight()
local uiMap = self.root:genAllChildren()
local bg = uiMap["game_setting_ui.bg"]
local communityBg = uiMap["game_setting_ui.bg.bg"]
local h = BG_HEIGHT[I18N:getCurLanguage()]
h = h or BG_HEIGHT.NORMAL
bg:setSizeDeltaY(h)
communityBg:setVisible(BG_HEIGHT[I18N:getCurLanguage()] == nil)
end
return GameSettingUI

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 03a251a89caa1d146bbdeaf8b58d791f
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: d15a8352e58c29b47addd9a8feda975a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,147 @@
local IdleDropUI = class("IdleDropUI", BaseUI)
function IdleDropUI:isFullScreen()
return false
end
function IdleDropUI:getPrefabPath()
return "assets/prefabs/ui/idle/idle_drop_ui.prefab"
end
function IdleDropUI:onReshow()
-- self:refreshBtn()
end
function IdleDropUI:onLoadRootComplete()
-- self:_display()
self:_addListeners()
-- self:refreshCD()
-- self:scheduleGlobal(function()
-- self:refreshCD()
-- end, 1)
end
function IdleDropUI:ctor()
self.list = {}
-- self.list = DataManager.HangUpData:getCacheRewards()
self.coinPerHour = 0
self.expPerHour = 0
-- local chapterId = DataManager.StageData:getMaxChapterId()
-- local cfg = ConfigManager:getConfig("chapter")[chapterId]
-- if not cfg then
-- return
-- end
-- local coinPerTime = GFunc.getConstIntValue("gold_drop_time")
-- local expPerTime = GFunc.getConstIntValue("exp_drop_time")
-- local multpliter = DataManager.MonthlyData:getHangUpMultiplier()
-- self.coinPerHour = math.floor(cfg.idle_gold * (3600 // coinPerTime) * multpliter)
-- self.expPerHour = math.floor(cfg.idle_exp * (3600 // expPerTime) * multpliter)
end
function IdleDropUI:_display()
local uiMap = self.root:genAllChildren()
uiMap["idle_drop_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC))
uiMap["idle_drop_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_1))
uiMap["idle_drop_ui.bg.desc_2"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_3, Time:formatNumTime(GFunc.getConstIntValue("idle_maxtime"))))
uiMap["idle_drop_ui.bg.btn_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_5))
uiMap["idle_drop_ui.bg.btn_2.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.GET_DESC))
uiMap["idle_drop_ui.bg.bg_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_4, self.coinPerHour))
uiMap["idle_drop_ui.bg.bg_2.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_4, self.expPerHour))
self:_refreshScrollRect()
self:refreshBtn()
self.canRefreshReward = true
end
function IdleDropUI:_addListeners()
local uiMap = self.root:genAllChildren()
self.root:addClickListener(function()
self:closeUI()
ModuleManager.IdleManager:getIdleRewrad()
end)
uiMap["idle_drop_ui.bg.close_img"]:addClickListener(function()
self:closeUI()
ModuleManager.IdleManager:getIdleRewrad()
end)
uiMap["idle_drop_ui.bg.btn_1"]:addClickListener(function()
ModuleManager.IdleManager:showIdleQuickDropUI()
end)
uiMap["idle_drop_ui.bg.btn_2"]:addClickListener(function()
ModuleManager.IdleManager:getIdleRewrad()
end)
-- self:bind(DataManager.HangUpData, "isDirty", function()
-- self.list = DataManager.HangUpData:getCacheRewards()
-- self:_refreshScrollRect()
-- self.canRefreshReward = true
-- end)
end
function IdleDropUI:refreshCD()
local uiMap = self.root:genAllChildren()
local time = Time:getServerTime() - DataManager.HangUpData:getLastTime()
time = math.min(time, GFunc.getConstIntValue("idle_maxtime"))
uiMap["idle_drop_ui.bg.cd_info"]:setText(Time:formatNumTime(time))
local btn = uiMap["idle_drop_ui.bg.btn_2"]
if time > ModuleManager.HangUpManager.HANG_UP_RP_TIME then
btn:addRedPoint(85, 36, 0.5)
else
btn:removeRedPoint()
end
if not self.lastRefreshTime then
self.lastRefreshTime = Time:getServerTime()
elseif Time:getServerTime() - self.lastRefreshTime > GFunc.getConstIntValue("exp_drop_time") then
if not self.canRefreshReward then
return
end
self.canRefreshReward = false
self.lastRefreshTime = Time:getServerTime()
ModuleManager.HangUpManager:getHangUpShowRewrad()
end
end
function IdleDropUI:_refreshScrollRect()
if self.scrollRect then
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.list)
return
end
local uiMap = self.root:genAllChildren()
self.scrollRect = uiMap["idle_drop_ui.bg.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRect:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end)
self.scrollRect:addRefreshCallback(function(index, cell)
cell:refreshByConfig(self.list[index])
end)
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.list)
end
function IdleDropUI:refreshBtn()
local uiMap = self.root:genAllChildren()
local btn = uiMap["idle_drop_ui.bg.btn_1"]
if self:canAd() or self:canDiamond() then
btn:addRedPoint(85, 36, 0.5)
else
btn:removeRedPoint()
end
end
function IdleDropUI:canAd()
return GFunc.getConstIntValue("idle_drop_fast_times_1") > DataManager.HangUpData:getAdCount()
end
function IdleDropUI:canDiamond()
return GFunc.getConstIntValue("idle_drop_fast_times_2") > DataManager.HangUpData:getDiamondCount()
end
return IdleDropUI

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ad3bad42428af32409f820d586de5185
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,128 @@
local IdleQuickDropUI = class("IdleQuickDropUI", BaseUI)
local BTN_ICON = {
BLUE = "common_btn_3",
YELLOW = "common_btn_2",
GRAY = "common_btn_4"
}
function IdleQuickDropUI:isFullScreen()
return false
end
function IdleQuickDropUI:getPrefabPath()
return "assets/prefabs/ui/idle/idle_quick_drop_ui.prefab"
end
function IdleQuickDropUI:ctor()
-- self.list = ModuleManager.IdleManager:getRewardList()
self.list = {}
end
function IdleQuickDropUI:onLoadRootComplete()
self:_display()
self:_addListeners()
end
function IdleQuickDropUI:_display()
local uiMap = self.root:genAllChildren()
uiMap["idle_quick_drop_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_5))
uiMap["idle_quick_drop_ui.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_6))
uiMap["idle_quick_drop_ui.bg.btn_1.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.FREE_DESC))
-- uiMap["idle_quick_drop_ui.bg.btn_2.desc"]:setText("X" .. GFunc.getConstIntValue("idle_drop_fast_cost"))
-- uiMap["idle_quick_drop_ui.bg.desc2"]:setText(I18N:getGlobalText(I18N.GlobalConst.BUY_VIT_DESC_2, GFunc.getConstIntValue("idle_drop_fast_times_2") - DataManager.HangUpData:getDiamondCount()))
-- if DataManager.MonthlyData:skipAd() then
-- uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setSprite(GConst.ATLAS_PATH.COMMON, "common_ad_1", function ()
-- uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
-- end)
-- else
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setSprite(GConst.ATLAS_PATH.COMMON, "common_ad", function ()
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
end)
-- end
uiMap["idle_quick_drop_ui.bg.btn_1.Image"]:setImageGray(not self:canAd())
uiMap["idle_quick_drop_ui.bg.btn_2.img"]:setImageGray(not self:canDiamond())
local btn1 = uiMap["idle_quick_drop_ui.bg.btn_1"]
local icon = BTN_ICON.BLUE
if not self:canAd() then
icon = BTN_ICON.GRAY
btn1:removeRedPoint()
else
btn1:addRedPoint(85, 36, 0.5)
end
btn1:setSprite(GConst.ATLAS_PATH.COMMON, icon)
icon = BTN_ICON.YELLOW
if not self:canDiamond() then
icon = BTN_ICON.GRAY
end
uiMap["idle_quick_drop_ui.bg.btn_2"]:setSprite(GConst.ATLAS_PATH.COMMON, icon)
self:_refreshScrollRect()
end
function IdleQuickDropUI:_addListeners()
local uiMap = self.root:genAllChildren()
self.root:addClickListener(function()
self:closeUI()
end)
uiMap["idle_quick_drop_ui.bg.btn_1"]:addClickListener(function()
if not self:canAd() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_7, "0"))
return
end
BIReport:postAdClick(BIReport.ADS_CLICK_TYPE.AD_HANG_UP)
SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.AD_HANG_UP, function()
ModuleManager.IdleManager:getHangUpQuickRewrad(ModuleManager.IdleManager.HANG_UP_REWARD_TYPE.QUICK_AD)
end)
end)
uiMap["idle_quick_drop_ui.bg.btn_2"]:addClickListener(function()
if not self:canDiamond() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.HANG_UP_DESC_7, "0"))
return
end
ModuleManager.IdleManager:getHangUpQuickRewrad(ModuleManager.IdleManager.HANG_UP_REWARD_TYPE.QUICK_DIAMOND)
end)
uiMap["idle_quick_drop_ui.bg.close_img"]:addClickListener(function()
self:closeUI()
end)
-- self:bind(DataManager.IdleData, "isDirty", function()
-- self:_display()
-- end)
end
function IdleQuickDropUI:_refreshScrollRect()
if self.scrollRect then
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.list)
return
end
local uiMap = self.root:genAllChildren()
self.scrollRect = uiMap["idle_quick_drop_ui.bg.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRect:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end)
self.scrollRect:addRefreshCallback(function(index, cell)
cell:refreshByConfig(self.list[index])
end)
self.scrollRect:clearCells()
self.scrollRect:refillCells(#self.list)
end
function IdleQuickDropUI:canAd()
-- return GFunc.getConstIntValue("idle_drop_fast_times_1") > DataManager.HangUpData:getAdCount()
end
function IdleQuickDropUI:canDiamond()
-- return GFunc.getConstIntValue("idle_drop_fast_times_2") > DataManager.HangUpData:getDiamondCount()
end
return IdleQuickDropUI

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a67f1d468f6bcda4ca363648ef1b928b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e83a8b9091de9064a9751667ccf0f7c3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarActivityCell = class("SideBarActivityCell", SideBarBaseCellComp)
-- icon图标资源路径,为空时不显示
function SideBarActivityCell:getIconRes()
return "main_btn_sevenday"
end
return SideBarActivityCell

View File

@ -1,6 +1,5 @@
local SideBarBaseCellComp = class("SideBarBaseCellComp", BaseCell)
local DEFAULT_ICON_BG_NAME = "main_bg_1"
local DEFAULT_ICON_SIZE_X = 80
local DEFAULT_ICON_SIZE_Y = 80
local DEFAULT_ICON_POS_X = 0
@ -9,31 +8,10 @@ local DEFAULT_RED_POINT_POS_X = 30
local DEFAULT_RED_POINT_POS_Y = 30
local DEFAULT_RED_POINT_SCALE = 0.6
function SideBarBaseCellComp:initBase(parentUI)
if not self.initComp then
self.initComp = true
local uiMap = self:getUIMap()
self.iconBg = uiMap["side_bar_base_cell.bg"]
self.iconImg = uiMap["side_bar_base_cell.icon"]
self.infoTx = uiMap["side_bar_base_cell.info"]
self.rpRoot = uiMap["side_bar_base_cell.rpRoot"]
-- 基础信息
if self:getIconRes() then
self.iconBg:setSprite(GConst.ATLAS_PATH.MAIN, DEFAULT_ICON_BG_NAME)
self.iconBg:setAnchoredPosition(self:getIconAnchoredPosition())
self.iconBg:setSizeDelta(self:getIconSize())
self.iconImg:setSprite(GConst.ATLAS_PATH.MAIN, self:getIconRes())
self.iconImg:setAnchoredPosition(self:getIconAnchoredPosition())
self.iconImg:setSizeDelta(self:getIconSize())
end
else
self:refreshIcon()
end
end
-- 需要继承重写的部分 ***********************************************************
function SideBarBaseCellComp:getIsOpen()
return false
end
-- icon图标资源路径,为空时不显示
function SideBarBaseCellComp:getIconRes()
@ -91,58 +69,37 @@ function SideBarBaseCellComp:getAdPointScale()
end
function SideBarBaseCellComp:refreshIcon()
self.icon:setSprite(GConst.ATLAS_PATH.MAIN, self:getIconRes())
end
function SideBarBaseCellComp:onClick()
end
-- 常规逻辑 ***********************************************************
function SideBarBaseCellComp:setText(text)
if self.infoTx then
self.infoTx:setText(text)
end
function SideBarBaseCellComp:init()
local uiMap = self.baseObject:genAllChildren()
self.icon = uiMap["side_bar_cell.icon"]
self.baseObject:addClickListener(function()
self:onClick()
end)
end
function SideBarBaseCellComp:refresh(parentUI, isOpen, showShake, isRed, isAdPoint, x, y, forceDisVisible, clickCallback)
if not isOpen then
GFunc.getShakeSeq(self.baseObject, true)
self.baseObject:setVisible(false)
else
self:initBase(parentUI)
self:addClickListener(clickCallback)
-- 位置与表现
if self:getHasShake() and showShake then
GFunc.getShakeSeq(self.baseObject, nil, 1, true)
else
GFunc.getShakeSeq(self.baseObject, true)
end
self.baseObject:setVisible(true)
if forceDisVisible then
self.baseObject:setVisible(false)
end
self.baseObject:setAnchoredPosition(x, y)
-- 信息
if self:getHasInfo() then
self.infoTx:setText(self:getInfo())
end
-- 红点
if isRed then
local rpPosX, rpPosY = self:getRedPointPosition()
local rpScale = self:getRedPointScale()
self.rpRoot:addRedPoint(rpPosX, rpPosY, rpScale, nil, nil, true)
else
self.rpRoot:removeRedPoint()
function SideBarBaseCellComp:refresh()
self:refreshIcon()
end
if not isRed then
-- 广告红点
if isAdPoint then
local rpPosX, rpPosY = self:getAdPointPosition()
local rpScale = self:getAdPointScale()
self.rpRoot:addRedPoint(rpPosX, rpPosY, rpScale, GFunc.getAdSprite(), nil, true)
else
self.rpRoot:removeRedPoint()
end
function SideBarBaseCellComp:setAnchoredPositionY(y)
self.baseObject:setAnchoredPositionY(y)
end
function SideBarBaseCellComp:getCellPath()
return self.cellPath
end
function SideBarBaseCellComp:setCellPath(cellPath)
self.cellPath = cellPath
end
return SideBarBaseCellComp

View File

@ -1,19 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarBountyCell = class("SideBarBountyCell", SideBarBaseCellComp)
-- icon图标资源路径,为空时不显示
function SideBarBountyCell:getIconRes()
return "main_btn_bounty"
end
-- 是否有数据显示
function SideBarBountyCell:getHasInfo()
return false
end
-- 具体内容
function SideBarBountyCell:getInfo()
return GConst.EMPTY_STRING
end
return SideBarBountyCell

View File

@ -1,9 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarHandbookCell = class("SideBarHandbookCell", SideBarBaseCellComp)
-- icon图标资源路径,为空时不显示
function SideBarHandbookCell:getIconRes()
return "main_btn_collection"
end
return SideBarHandbookCell

View File

@ -0,0 +1,16 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarIdleCell = class("SideBarIdleCell", SideBarBaseCellComp)
function SideBarIdleCell:getIsOpen()
return true
end
function SideBarIdleCell:getIconRes()
return "main_btn_idle"
end
function SideBarIdleCell:onClick()
ModuleManager.IdleManager:showIdleDropUI()
end
return SideBarIdleCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: af866bdef8f75d049a6652d80e4d8fd1
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,15 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarMailCell = class("SideBarMailCell", SideBarBaseCellComp)
function SideBarMailCell:getIsOpen()
return true
end
function SideBarMailCell:getIconRes()
return "main_btn_mail"
end
function SideBarMailCell:onClick()
end
return SideBarMailCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7e49deed89eef454ab79c3dd35a4be9d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,13 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarMonthlyCardCell = class("SideBarMonthlyCardCell", SideBarBaseCellComp)
-- icon图标资源路径,为空时不显示
function SideBarMonthlyCardCell:getIconRes()
return "main_btn_idle"
end
-- 是否有shake效果
function SideBarMonthlyCardCell:getHasShake()
return true
end
return SideBarMonthlyCardCell

View File

@ -0,0 +1,16 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarSettingCell = class("SideBarMailCell", SideBarBaseCellComp)
function SideBarSettingCell:getIsOpen()
return true
end
function SideBarSettingCell:getIconRes()
return "maincity_gm"
end
function SideBarSettingCell:onClick()
ModuleManager.GameSettingManager:showSettingUI()
end
return SideBarSettingCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3d6207c01bdc5884b8306334809a2a99
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,16 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarSevenDaysCell = class("SideBarSevenDaysCell", SideBarBaseCellComp)
function SideBarSevenDaysCell:getIsOpen()
return true
end
function SideBarSevenDaysCell:getIconRes()
return "main_btn_sevenday"
end
function SideBarSevenDaysCell:onClick()
end
return SideBarSevenDaysCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c2ea2cd63c0189a46b808d14b397a1d1
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,24 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarSpeedUpCell = class("SideBarSpeedUpCell", SideBarBaseCellComp)
-- icon图标资源路径,为空时不显示
function SideBarSpeedUpCell:getIconRes()
return "main_btn_act_speed"
end
-- 是否有数据显示
function SideBarSpeedUpCell:getHasInfo()
return true
end
-- 具体内容
function SideBarSpeedUpCell:getInfo()
local remainCd = DataManager.AccelerationData:getRemainCd()
if remainCd > 0 and DataManager.AccelerationData:isActive() then
return I18N:getGlobalText(I18N.GlobalConst.ACCELERATION) .. "\n" .. Time:formatNumTimeMS(remainCd)
else
return I18N:getGlobalText(I18N.GlobalConst.BATTLE_SPEED_UP_DESC_2)
end
end
return SideBarSpeedUpCell

View File

@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 5ee1b9588f0fffc4b8f09a83d1952034
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,22 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarStrengthCell = class("SideBarStrengthCell", SideBarBaseCellComp)
local DEFAULT_RED_POINT_POS_X = 30
local DEFAULT_RED_POINT_POS_Y = 18
-- icon图标资源路径,为空时不显示
function SideBarStrengthCell:getIconRes()
local acticeStr = DataManager.BlessingData:getBlessingActive()
return "main_btn_blessing_" .. acticeStr
end
function SideBarStrengthCell:refreshIcon()
self.iconImg:setSprite(GConst.ATLAS_PATH.MAIN, self:getIconRes())
end
-- 广告红点偏移位置
function SideBarBaseCellComp:getAdPointPosition()
return DEFAULT_RED_POINT_POS_X, DEFAULT_RED_POINT_POS_Y
end
return SideBarStrengthCell

View File

@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 6d90e530df2fd5342a942fe00098dec0
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,9 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarTaskCell = class("SideBarTaskCell", SideBarBaseCellComp)
-- icon图标资源路径,为空时不显示
function SideBarTaskCell:getIconRes()
return "main_btn_task"
end
return SideBarTaskCell

View File

@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 87daf7c7b050cd3458f656f03917bf13
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,9 +1,10 @@
local UIPrefabObject = require "app/bf/unity/uiprefab_object"
local MainCityUI = class("MainCityUI", BaseUI)
local BF_UI_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_UI_HELPER
local HERO_COMP = "app/ui/hero/hero_comp"
local MAIN_COMP = "app/ui/main_city/component/main_comp"
local STAGE_COMP = "app/ui/stage/stage_comp"
local BOTTOM_BTN_CELL = "app/ui/main_city/cell/bottom_btn_cell"
@ -54,6 +55,7 @@ end
function MainCityUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.uiMap = uiMap
self.bottomBgSelected = uiMap["main_ui.bottom_node.bottom_bg_selected"]
self.bottomBgSelected:setLocalPositionX(-178)
@ -68,6 +70,11 @@ function MainCityUI:onLoadRootComplete()
end, 1)
end
function MainCityUI:onRefresh()
self:refreshLeftBtns()
self:refreshRightBtns()
end
function MainCityUI:onReshow()
self:checkMainPop()
end
@ -87,6 +94,7 @@ end
function MainCityUI:_display()
self:initBottomUI()
self:initComp()
self:initLeftRightBtns()
self:refreshBottom()
end
@ -128,32 +136,6 @@ function MainCityUI:_bind()
self.subComps[self.selectedIndex]:refreshStageFormaion()
end
end)
-- self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE_VIT, function(params)
-- params = params or {}
-- local page = params.page or self.selectedIndex
-- if page == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE then
-- self.showStoreIdx = params.storeIdx
-- elseif page == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
-- self.patternIdx = params.patternIdx
-- end
-- self:refreshBottom(page, false)
-- self:refreshRoleInfo()
-- end)
-- self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(params)
-- params = params or {}
-- local page = params.page or self.selectedIndex
-- if page == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE then
-- self.showStoreIdx = params.storeIdx
-- self.storeOffsetY = params.storeOffsetY
-- elseif page == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
-- self.patternIdx = params.patternIdx
-- end
-- self:refreshBottom(page, true)
-- self:refreshRoleInfo()
-- end)
end
function MainCityUI:initBottomUI()
@ -246,6 +228,106 @@ function MainCityUI:refreshBottomCell(showAni)
end
end
function MainCityUI:initLeftRightBtns()
self.leftSideBar = self.uiMap["main_ui.left_node.side_bar"]
self.rightSideBar = self.uiMap["main_ui.right_node.side_bar"]
self.sideBarCellObject = self.uiMap["main_ui.cache_node.side_bar_cell"]
if self.leftBarList == nil then
self.leftBarList = {}
end
if self.rightBarList == nil then
self.rightBarList = {}
end
if self.sideBarClassMap == nil then
self.sideBarClassMap = {}
end
if self.sideBarCellMap == nil then
self.sideBarCellMap = {}
end
end
function MainCityUI:addSideBarCellComp(cellClassPath)
local prefab = CS.UnityEngine.Object.Instantiate(self.sideBarCellObject:getGameObject())
local prefabObject = UIPrefabObject:create()
prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab)
prefabObject:initPrefabHelper()
prefabObject:genAllChildren()
return prefabObject:addLuaComponent(cellClassPath)
end
function MainCityUI:refreshLeftBtns()
local list = GConst.MainCityConst.LEFT_SIDE_BARS
if #list <= 0 then
self:clearSideBarList(self.leftBarList)
return
end
for k, v in ipairs(list) do
local CellClass = self.sideBarClassMap[v]
if CellClass == nil then
CellClass = require(v)
self.sideBarClassMap[v] = CellClass
end
if CellClass:getIsOpen() then
local cell = self.sideBarCellMap[v]
if cell == nil then
cell = self:addSideBarCellComp(v)
cell:getBaseObject():setParent(self.leftSideBar, false)
end
cell:setCellPath(v)
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
end
end
function MainCityUI:refreshRightBtns()
local list = GConst.MainCityConst.RIGHT_SIDE_BARS
if #list <= 0 then
self:clearSideBarList(self.rightBarList)
return
end
for k, v in ipairs(list) do
local CellClass = self.sideBarClassMap[v]
if CellClass == nil then
CellClass = require(v)
self.sideBarClassMap[v] = CellClass
end
if CellClass:getIsOpen() then
local cell = self.sideBarCellMap[v]
if cell == nil then
cell = self:addSideBarCellComp(v)
cell:getBaseObject():setParent(self.rightSideBar, false)
end
cell:setCellPath(v)
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
end
end
function MainCityUI:clearSideBarList(sideBarList)
local count = #sideBarList
for i = 1, count do
local cell = table.remove(sideBarList)
self.sideBarCellMap[cell:getCellPath()] = cell
end
end
function MainCityUI:setSideBarVisible(visible)
self.leftSideBar:setVisible(visible)
self.rightSideBar:setVisible(visible)
end
function MainCityUI:switchComp(index)
index = index or self.selectedIndex
for i, comp in pairs(self.subComps) do
@ -258,6 +340,9 @@ function MainCityUI:switchComp(index)
self:updateCurrencyBar()
if self.selectedIndex == MAIN_COMP_INDEX then
self:checkMainPop()
self:setSideBarVisible(true)
else
self:setSideBarVisible(false)
end
end

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 79ad94662b68c4a4e928efa98eaff097
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6de5c15e421575d43a8631dee02abdea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: ef6c3d6d6879f8c43a44edea3d10add2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6c5aad18b7c407847b1774e6e7c40c6d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: d906c3a6b70c16d47a4c72435a41664f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,93 +0,0 @@
local ChapterCell = class("ChapterCell", BaseCell)
local chapterCfg = ConfigManager:getConfig("chapter")
function ChapterCell:init()
self.Data = DataManager.ChallengeData
local uiMap = self:getUIMap()
self.normalTitleImg = uiMap["cell.title_img.normal_title_img"]
self.titleTxNormal = uiMap["cell.title_img.normal_title_img.title_tx"]
self.greyTitleImg = uiMap["cell.title_img.grey_title_img"]
self.titleTxGrey = uiMap["cell.title_img.grey_title_img.title_tx"]
self.lockImg = uiMap["cell.title_img.grey_title_img.lock_img"]
self.picItemImgs = {
uiMap["cell.pic_img_1"],
uiMap["cell.pic_img_2"],
uiMap["cell.pic_img_3"]
}
self.maskBgs = {
uiMap["cell.pic_img_1.mask_img"],
uiMap["cell.pic_img_2.mask_img"],
uiMap["cell.pic_img_3.mask_img"]
}
self.checkImgs = {
uiMap["cell.pic_img_1.check_img"],
uiMap["cell.pic_img_2.check_img"],
uiMap["cell.pic_img_3.check_img"]
}
self.passedTxs = {
uiMap["cell.pic_img_1.passed_tx"],
uiMap["cell.pic_img_2.passed_tx"],
uiMap["cell.pic_img_3.passed_tx"]
}
self.lockTxs = {
uiMap["cell.pic_img_1.lock_tx"],
uiMap["cell.pic_img_2.lock_tx"],
uiMap["cell.pic_img_3.lock_tx"]
}
end
function ChapterCell:refresh(cfgdatas)
self.cfgDatas = cfgdatas
self.chapterId = self.cfgDatas[1].cfg.chapter
self.chapterCfg = chapterCfg[self.chapterId]
self.chapterIndex = DataManager.StageData:getChapter(self.chapterId)
self:initConstantTxt()
local canChapterChallenge = self.Data:canChallengeChapter(self.chapterId)
self:initPicItem(canChapterChallenge)
self.normalTitleImg:setActive(canChapterChallenge)
self.greyTitleImg:setActive(not canChapterChallenge)
self:bindEvent()
end
function ChapterCell:initConstantTxt()
local strCfg = I18N:getConfig("chapter")[self.chapterId]
self.titleTxNormal:setText(strCfg.name)
self.titleTxGrey:setText(I18N:getGlobalText(I18N.GlobalConst.PASSED_CHAPTER_TO_UNLOCK_DESC, self.chapterIndex))
for i = 1, 3 do
self.passedTxs[i]:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_GOT_DESC))
self.lockTxs[i]:setText(I18N:getGlobalText(I18N.GlobalConst.PASSED_BEFORE_CHALLENGE_TO_UNLOCK_DESC))
end
end
function ChapterCell:initPicItem(canChapterChallenge)
for i = 1, 3 do
self.picItemImgs[i]:setActive(canChapterChallenge)
if canChapterChallenge then
self.picItemImgs[i]:setSprite(GConst.ATLAS_PATH.UI_CHALLENGE, self.cfgDatas[1].cfg.icon)
local passed = self.Data:getIsPassed(self.cfgDatas[i].cfgid)
self.passedTxs[i]:setActive(passed)
self.checkImgs[i]:setActive(passed)
local canChallenge = self.Data:canChallengeByCfgId(self.cfgDatas[i].cfgid)
self.lockTxs[i]:setActive(not canChallenge)
self.maskBgs[i]:setActive(passed or (not canChallenge))
end
end
end
function ChapterCell:bindEvent()
for i = 1, 3 do
self.picItemImgs[i]:addClickListener(function()
local canChallenge = self.Data:canChallengeByCfgId(self.cfgDatas[i].cfgid)
if not canChallenge then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.PASSED_BEFORE_CHALLENGE_TO_UNLOCK_DESC))
return
end
-- 打开挑战界面
local params = {}
params.cfgData = self.cfgDatas[i]
ModuleManager.ChallengeManager:showChallengeReadyUI(params)
end)
end
end
return ChapterCell

View File

@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 2caa68f00f1473146b03262e5fb6c7a3
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,36 +0,0 @@
local StageComp = class("StageComp", LuaComponent)
local STAGE_CELL = "app/ui/stage/cell/chapter_cell"
function StageComp:init()
local uiMap = self.baseObject:genAllChildren()
self.cellList = uiMap["challenge_ui.scrollrect"]
-- 刷新UI
self:bind(DataManager.StageData, "isDirty", function(binder, value)
self:refresh()
end)
end
function StageComp:refresh()
self:initScrollRect()
end
function StageComp:initScrollRect()
local listCfgs = self.Data:getListChallengeCfg()
self.scrollRect = self.cellList:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRect:addInitCallback(function()
return STAGE_CELL
end)
self.scrollRect:addRefreshCallback(function(index, cell)
cell:refresh(listCfgs[index])
end)
self.scrollRect:clearCells()
self.scrollRect:setTotalCount(#listCfgs)
self.scrollRect:refillCells(#listCfgs)
self.scrollRect:moveToIndex(self.Data:getFirstNotPassedChallengeIndex())
end
function StageComp:onDestroy()
self:unBindAll()
end
return StageComp

View File

@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 4bdb95384e09f054a81ac063e25b0d4a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b4d1c7aadb8577c458291535ce7bff51
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1c51403c23b2d7d498691bcf412da02a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,7 +3,6 @@ local UIManager = {}
local MESSAGE_BOX_PATH = "assets/prefabs/ui/common/message_box.prefab"
local CHEATING_BOX_PATH = "assets/prefabs/ui/common/cheating_box.prefab"
local TUTORIAL_PATH = "assets/prefabs/ui/tutorial/tutorial_ui.prefab"
local BF_BASE_SORTING_ORDER_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_BASE_SORTING_ORDER_HELPER
UIManager.UI_TYPE = {
DEFAULT = 0,
@ -37,7 +36,9 @@ UIManager.LOADING_TYPE = {
CLOUD = 2
}
local UI_CACHE_SIZE = 5 -- ui缓存上限
-- ui缓存上限
local UI_CACHE_SIZE = 5
-- 根据以往项目的经验提前申请一个值,避免动态扩容导致的开销,可根据项目实际情况调整
local MAIN_CANVAS_HIERARCHY_CAPACITY = 20480
local MAIN_CANVAS_ORDER = 1000
local UI_INTERVAL_ORDER = 400
@ -53,7 +54,7 @@ local OTHER_CANVAS_INTERVAL_ORDER = {
SWALLOW_TOUCH = 5,
MESSAGE_BOX_TOP = 6,
LOADING_TOP = 7,
-- 这里要注意一下不要超过sortingOrder的最大值32767,目前UI_MAX_ORDER + UI_INTERVAL_ORDER*LOADING_TOP = 30800 小于 32767
-- 这里要注意一下不要超过sortingOrder的最大值32767,目前UI_MAX_ORDER + UI_INTERVAL_ORDER * LOADING_TOP:28000 + 400 * 7 = 30800 小于 32767
}
function UIManager:init(callback)

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 28cfda60d5df0b143a8fbd0347f13e1d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: e55326236c838c6409240fc113249261
guid: 94af4a46c89697843a6f28e41e14a7e8
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,498 @@
local SevenDayData = class("SevenDayData", BaseData)
local TASK_CFG = ConfigManager:getConfig("act_sevenday_quest")
local TASK_REWARD_CFG = ConfigManager:getConfig("act_sevenday_quest_reward")
local TASK_MAX_COUNT = ConfigManager:getConfigNum("act_sevenday_quest")
local TASK_REWARD_MAX_COUNT = ConfigManager:getConfigNum("act_sevenday_quest_reward")
function SevenDayData:getBg()
return "assets/arts/textures/background/activity/activity_dec_1.png"
end
function SevenDayData:getTitleBg()
return "common_menu_bg_2"
end
function SevenDayData:getTitleIcon()
return "activity_dec_1"
end
function SevenDayData:getTitle()
return I18N:getGlobalText(I18N.GlobalConst.SEVEN_DAY_DESC_1)
end
function SevenDayData:showTimeNode()
return true
end
function SevenDayData:getTimeStr()
local str
local time = self.endTime - Time:getServerTime()
if time > 0 then
str = Time:formatNumTime(time)
else
str = I18N:getGlobalText(I18N.GlobalConst.ACT_OVER_DESC)
end
return str
end
function SevenDayData:getRp()
return self:showRedPoint()
end
function SevenDayData:gotoBtnFunc()
ModuleManager.SevenDayManager:showUI()
end
function SevenDayData:getIsOpen()
local nowTime = Time:getServerTime()
if self.endTime < nowTime or self.openTs > nowTime then
return false
end
if self.collectTaskCount >= TASK_MAX_COUNT and self.collectStepCount > TASK_REWARD_MAX_COUNT then
return false
end
return true
end
function SevenDayData:ctor()
self:clear()
end
function SevenDayData:clear()
self.data.isDirty = false
self.collectTaskCount = 0
self.collectStepCount = 0
self.openTs = 0
self.endTime = 0
self.tasks = {}
self.stepRewards = {}
DataManager:unregisterCrossDayFunc("SevenDayData")
end
function SevenDayData:init(data)
data = data or {}
self.openTs = GFunc.formatTimeStep(data.open_day_ts)
self.endTime = self.openTs
if self.openTs > 0 then
self.endTime = self.openTs + self:getDurationTime()
end
self.tasks = data.tasks or {}
self.stepRewards = data.Claimed or {}
self.actDay = data.login_day or 1
self:calCollectTaskCount()
self:initTaskListener()
DataManager:registerCrossDayFunc("SevenDayData", function()
self.actDay = self.actDay + 1
self:setDirty()
end)
end
function SevenDayData:getDurationTime()
if not self.durationTime then
self.durationTime = GFunc.getConstIntValue("seven_day_time") * 86400
end
return self.durationTime
end
function SevenDayData:getActDay()
return self.actDay or 1
end
function SevenDayData:getEndTime()
return self.endTime
end
function SevenDayData:refreshTasks(data)
if not data then
return
end
for id, task in pairs(data) do
self.tasks[id] = task
end
self:calCollectTaskCount()
end
function SevenDayData:refreshClaimed(data)
if not data then
return
end
for id, b in pairs(data) do
self.stepRewards[id] = b
end
end
function SevenDayData:opened()
return self.openTs > 0
end
function SevenDayData:setOpen()
if self.openTs > 0 then
return
end
self.collectTaskCount = 0
self.collectStepCount = 0
self.stepRewards = {}
self.openTs = Time:getServerTime()
self.endTime = self.openTs + self:getDurationTime()
self.actDay = 1
end
function SevenDayData:setDirty()
self.data.isDirty = not self.data.isDirty
end
function SevenDayData:calCollectTaskCount()
self.collectTaskCount = 0
for id, info in ipairs(TASK_CFG) do
if self:taskCollected(id) then
self.collectTaskCount = self.collectTaskCount + 1
end
end
self.collectStepCount = 0
for id, info in ipairs(TASK_REWARD_CFG) do
if self:getStepCollected(id) then
self.collectStepCount = self.collectStepCount + 1
end
end
end
function SevenDayData:getTaskListByDay(day)
if not self.taskList then
self.taskList = {}
for id, info in ipairs(TASK_CFG) do
if not self.taskList[info.day] then
self.taskList[info.day] = {}
end
table.insert(self.taskList[info.day], id)
end
end
return self.taskList[day] or {}
end
function SevenDayData:getStepRewardList()
if not self.stepRewardList then
self.stepRewardList = {}
for id, info in ipairs(TASK_REWARD_CFG) do
table.insert(self.stepRewardList, id)
end
end
return self.stepRewardList
end
function SevenDayData:getCollectedCount()
return self.collectTaskCount
end
function SevenDayData:getTotalCount()
return ConfigManager:getConfigNum("act_sevenday_quest")
end
function SevenDayData:getTaskInfo(id)
if not self.tasks[id] then
self.tasks[id] = {
id = id,
progress = 0,
claimed = false
}
end
return self.tasks[id]
end
function SevenDayData:taskCollected(id)
return self:getTaskInfo(id).claimed
end
function SevenDayData:taskCount(id)
return self:getTaskInfo(id).progress
end
function SevenDayData:taskTotalCount(id)
local cfg = TASK_CFG[id]
if not cfg then
return 1 -- 防止除法报错
end
return cfg.number or 1
end
function SevenDayData:getTaskReward(id)
local cfg = TASK_CFG[id]
if not cfg then
return
end
return cfg.reward
end
function SevenDayData:getTaskDay(id)
local cfg = TASK_CFG[id]
if not cfg then
return 1
end
return cfg.day
end
function SevenDayData:getTaskType(id)
local cfg = TASK_CFG[id]
if not cfg then
return
end
return cfg.type
end
function SevenDayData:getTaskDayLimit(id)
local cfg = TASK_CFG[id]
if not cfg or not cfg.count_type then
return
end
return cfg.day
end
function SevenDayData:getTaskListByType(taskType)
if not self.taskTypeMap then
self.taskTypeMap = {}
for id, info in ipairs(TASK_CFG) 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 SevenDayData:addTaskProgress(id, count)
if not self:getIsOpen() then
return
end
local dayLimit = self:getTaskDayLimit(id)
if dayLimit and dayLimit > self:getActDay() then
return
end
self:getTaskInfo(id).progress = self:getTaskInfo(id).progress + count
self:setDirty()
end
function SevenDayData:setTaskProgress(id, count)
if not self:getIsOpen() then
return
end
local dayLimit = self:getTaskDayLimit(id)
if dayLimit and dayLimit > self:getActDay() then
return
end
if self:getTaskInfo(id).progress > count then
return
end
self:getTaskInfo(id).progress = count
self:setDirty()
end
function SevenDayData:canClaimTask(id)
if self:taskCollected(id) then
return false
end
return self:taskTotalCount(id) <= self:taskCount(id)
end
function SevenDayData:getStepNum(id)
local cfg = TASK_REWARD_CFG[id]
if not cfg then
return 1 -- 防止除法为0
end
return cfg.num
end
function SevenDayData:getStepCollected(id)
return self.stepRewards[id] == true
end
function SevenDayData:getStepReward(id)
local cfg = TASK_REWARD_CFG[id]
if not cfg then
return
end
return cfg.reward
end
function SevenDayData:canClaimStepTask(id)
if self:getStepCollected(id) then
return false
end
return self:stepOver(id)
end
function SevenDayData:stepOver(id)
return self.collectTaskCount >= self:getStepNum(id)
end
function SevenDayData:showRedPoint(day)
if day then
local list = self:getTaskListByDay(day)
for _, id in ipairs(list) do
if self:canClaimTask(id) then
return true
end
end
else
local day = self:getActDay()
for id, info in pairs(self.tasks) do
local cfg = TASK_CFG[id]
if cfg and cfg.day <= day then
if self:canClaimTask(id) then
return true
end
end
end
local list = self:getStepRewardList()
for _, id in ipairs(list) do
if self:canClaimStepTask(id) then
return true
end
end
end
return false
end
function SevenDayData:initTaskListener()
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.PASS_CHAPTER, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.PASS_CHAPTER)
for _, id in ipairs(list) do
self:setTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_WATCH_AD, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_WATCH_AD)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", 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)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_WEAPON_SUMMON, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_WEAPON_SUMMON)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_PROTECTIVE_SUMMON, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_PROTECTIVE_SUMMON)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_LEGACY_SUMMON, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_LEGACY_SUMMON)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE)
for _, id in ipairs(list) do
self:setTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE)
for _, id in ipairs(list) do
self:setTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE)
for _, id in ipairs(list) do
self:setTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", 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("SevenDayData", GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_BOOM_USE, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_BOOM_USE)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_RESEARCH_USE, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_RESEARCH_USE)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_MINE_DISTANCE, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_MINE_DISTANCE)
for _, id in ipairs(list) do
self:setTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_BLESSING_GOT, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_BLESSING_GOT)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_RUNE_GOT, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_RUNE_GOT)
for _, id in ipairs(list) do
self:addTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_TRAIN_ATK, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_TRAIN_ATK)
for _, id in ipairs(list) do
self:setTaskProgress(id, count)
end
end)
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_TRAIN_HP, function(count)
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_TRAIN_HP)
for _, id in ipairs(list) do
self:setTaskProgress(id, count)
end
end)
end
return SevenDayData

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0e7a1584508c3f64dba2bdf419b1ddf5
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: d75588bcefb20e644920b3a8c6b75d5f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 23e4bc8b94ae62a44a0935ac434a76cb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 46124ce19f4fd6a49a249fb54b5f08a1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f392d58484a40f74d9e6cea8fe7fa133
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 611d8d8c24b069b40adc151f25808171
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 4317cfebd540c7a4f89cafbbc1d37c35
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 04b08530f649de94093dbccc6bac02bf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 135c94b4361e44840abe13f1f193daa9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0246f6e43a613cc46a4473d41607f0ba
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 77fd485b68c4c0145bf9606f309940aa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: fabcab895a2f08c48af68a6957993b63
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9e1a8ff2abac63843a2405984496a414
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More