上阵
This commit is contained in:
parent
903e4899ca
commit
4b621b0e07
@ -11,6 +11,7 @@ local MODULE_PATHS = {
|
||||
ToastManager = "app/ui/common/toast",
|
||||
TaskManager = "app/module/task/task_manager",
|
||||
BattleManager = "app/module/battle/battle_manager",
|
||||
FormationManager = "app/module/formation/formation_manager",
|
||||
}
|
||||
|
||||
-- 这里的key对应func_open里的id
|
||||
|
||||
20
lua/app/module/formation/formation_manager.lua
Normal file
20
lua/app/module/formation/formation_manager.lua
Normal file
@ -0,0 +1,20 @@
|
||||
local FormationManager = class("FormationManager", BaseModule)
|
||||
|
||||
function FormationManager:upHeroToStageFormation(heroId, matchType)
|
||||
local formation = DataManager.FormationData:getStageFormation()
|
||||
if formation[matchType] == heroId then
|
||||
return
|
||||
end
|
||||
local args = {
|
||||
formationType = GConst.BattleConst.BATTLE_TYPE.STAGE,
|
||||
matchType = matchType,
|
||||
heroId = heroId
|
||||
}
|
||||
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPDATE_FORMATION, args, function(msgData)
|
||||
if msgData.status == 0 then
|
||||
DataManager.FormationData:upHeroToFormation(GConst.BattleConst.BATTLE_TYPE.STAGE, matchType, heroId)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return FormationManager
|
||||
10
lua/app/module/formation/formation_manager.lua.meta
Normal file
10
lua/app/module/formation/formation_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5234cdd00d84e543a3afe369d8a4c4d
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -8,4 +8,22 @@ function ServerFormationData:init(data)
|
||||
end
|
||||
end
|
||||
|
||||
function ServerFormationData:getFormation(formationType)
|
||||
local formation = self.data.formations[formationType]
|
||||
if formation == nil then
|
||||
formation = {}
|
||||
self.data.formations[formationType] = formation
|
||||
end
|
||||
return formation
|
||||
end
|
||||
|
||||
function ServerFormationData:upHeroToFormation(formationType, matchType, heroId)
|
||||
local formation = self:getFormation(formationType)
|
||||
if formation[matchType] == heroId then
|
||||
return false
|
||||
end
|
||||
formation[matchType] = heroId
|
||||
return true
|
||||
end
|
||||
|
||||
return ServerFormationData
|
||||
8
lua/app/server/manager.meta
Normal file
8
lua/app/server/manager.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09d17db485e3192459d5fcd0a0cefb49
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
lua/app/server/manager/server_formation_manager.lua
Normal file
27
lua/app/server/manager/server_formation_manager.lua
Normal file
@ -0,0 +1,27 @@
|
||||
local ServerFormationManager = {}
|
||||
|
||||
function ServerFormationManager:updateFormation(params, callback)
|
||||
local result = {
|
||||
status = 1
|
||||
}
|
||||
if params == nil then
|
||||
if callback then
|
||||
callback(result)
|
||||
end
|
||||
return
|
||||
end
|
||||
local formationType = params.formationType
|
||||
local matchType = tostring(params.matchType)
|
||||
local heroId = params.heroId
|
||||
if formationType and matchType and heroId then
|
||||
local ServerGameData = require "app/server/server_game_data"
|
||||
if ServerGameData.FormationData:upHeroToFormation(formationType, matchType, heroId) then
|
||||
result.status = 0
|
||||
end
|
||||
end
|
||||
if callback then
|
||||
callback(result)
|
||||
end
|
||||
end
|
||||
|
||||
return ServerFormationManager
|
||||
10
lua/app/server/manager/server_formation_manager.lua.meta
Normal file
10
lua/app/server/manager/server_formation_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f6f74ff6268bec4593ef0e060480d93
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -8,6 +8,7 @@ ServerDataConst.REWARD_TYPE = {
|
||||
ServerDataConst.DATA_OP_BEHAVIOR = {
|
||||
SYNC_DATA = "SYNC_DATA",
|
||||
CROSS_DAY = "CROSS_DAY",
|
||||
UPDATE_FORMATION = "UPDATE_FORMATION"
|
||||
}
|
||||
|
||||
return ServerDataConst
|
||||
@ -3,6 +3,7 @@ local ServerGameData = require "app/server/server_game_data"
|
||||
local ServerDataManager = {}
|
||||
|
||||
function ServerDataManager:init()
|
||||
self.ServerFormationManager = require("app/server/manager/server_formation_manager")
|
||||
end
|
||||
|
||||
function ServerDataManager:saveData()
|
||||
@ -40,7 +41,7 @@ function ServerDataManager:dataOperate(behavior, params, callback)
|
||||
end
|
||||
end)
|
||||
-- TODO临时处理
|
||||
LocalData:save()
|
||||
ServerGameData:saveData()
|
||||
else
|
||||
Logger.logError("Undefined data operation function, please check :%s", behavior)
|
||||
end
|
||||
@ -57,6 +58,7 @@ end
|
||||
|
||||
ServerDataManager.OP_FUNC = {
|
||||
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA] = function (...) ServerDataManager:onSyncData(...) end,
|
||||
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPDATE_FORMATION] = function (...) ServerDataManager.ServerFormationManager:updateFormation(...) end,
|
||||
}
|
||||
|
||||
return ServerDataManager
|
||||
@ -70,9 +70,8 @@ function ServerGameData:initData()
|
||||
end
|
||||
end
|
||||
end
|
||||
self:saveData()
|
||||
self:setNotNewPlayer()
|
||||
LocalData:save()
|
||||
self:saveData()
|
||||
else
|
||||
for k, v in pairs(self.dataMap) do
|
||||
v:init(v:loadLocalData())
|
||||
@ -100,6 +99,7 @@ function ServerGameData:saveData()
|
||||
for k, v in pairs(self.dataMap) do
|
||||
v:saveLocalData()
|
||||
end
|
||||
LocalData:save()
|
||||
end
|
||||
|
||||
-- 根据配置表添加奖励
|
||||
|
||||
@ -7,6 +7,11 @@ function HeroCell:init()
|
||||
self.check = uiMap["hero_cell.hero_bg.mask"]
|
||||
self.matchImg = uiMap["hero_cell.hero_bg.match_img"]
|
||||
self.isGray = false
|
||||
self.baseObject:addClickListener(function()
|
||||
if self.clickCallback then
|
||||
self.clickCallback()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function HeroCell:refresh(heroEntity, isGray)
|
||||
@ -20,6 +25,7 @@ function HeroCell:refreshWithCfgId(id, isGray)
|
||||
end
|
||||
|
||||
function HeroCell:_refresh(heroInfo, isGray)
|
||||
self.clickCallback = nil
|
||||
if isGray then
|
||||
self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_GRAY_QLT[heroInfo.qlt])
|
||||
else
|
||||
@ -31,6 +37,14 @@ function HeroCell:_refresh(heroInfo, isGray)
|
||||
self:setGray(isGray)
|
||||
end
|
||||
|
||||
function HeroCell:showCheck(visible)
|
||||
self.check:setVisible(visible)
|
||||
end
|
||||
|
||||
function HeroCell:addClickListener(callback)
|
||||
self.clickCallback = callback
|
||||
end
|
||||
|
||||
function HeroCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
@ -17,7 +17,7 @@ function HeroListCell:init()
|
||||
self.titleTx = self.uiMap["hero_list_cell.title.title_desc"]
|
||||
end
|
||||
|
||||
function HeroListCell:refresh(index, heroList, allHeroCount, activeCount)
|
||||
function HeroListCell:refresh(index, heroList, stageFormation, allHeroCount, activeCount)
|
||||
if activeCount > 0 and index == 1 then
|
||||
self.title:setVisible(true)
|
||||
self.titleTx:setText("临时文本:已解锁")
|
||||
@ -38,7 +38,14 @@ function HeroListCell:refresh(index, heroList, allHeroCount, activeCount)
|
||||
for i = 1, 4 do
|
||||
if heroIndex <= activeCount then
|
||||
self.heroCells[i]:setVisible(true)
|
||||
self.heroCells[i]:refresh(DataManager.HeroData:getHeroById(heroList[heroIndex]), false)
|
||||
local heroId = heroList[heroIndex]
|
||||
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
||||
local matchType = heroEntity:getMatchType()
|
||||
self.heroCells[i]:refresh(heroEntity, false)
|
||||
self.heroCells[i]:showCheck(stageFormation[matchType] == heroId)
|
||||
self.heroCells[i]:addClickListener(function()
|
||||
ModuleManager.FormationManager:upHeroToStageFormation(heroId, matchType)
|
||||
end)
|
||||
elseif heroIndex <= allHeroCount then
|
||||
if heroStartIndex <= activeCount then
|
||||
self.heroCells[i]:setVisible(false)
|
||||
|
||||
@ -9,7 +9,7 @@ function HeroComp:init()
|
||||
return HERO_LIST_CELL
|
||||
end)
|
||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(index, self.heroList, self.allHeroCount, self.activeCount)
|
||||
cell:refresh(index, self.heroList, self.stageFormation, self.allHeroCount, self.activeCount)
|
||||
end)
|
||||
self.heroList = {}
|
||||
local heroCfg = ConfigManager:getConfig("hero")
|
||||
@ -19,9 +19,15 @@ function HeroComp:init()
|
||||
end
|
||||
|
||||
function HeroComp:refresh()
|
||||
self.stageFormation = DataManager.FormationData:getStageFormation()
|
||||
self:refreshStageFormation()
|
||||
self:refreshScrollRect()
|
||||
end
|
||||
|
||||
function HeroComp:refreshStageFormation()
|
||||
|
||||
end
|
||||
|
||||
function HeroComp:refreshScrollRect()
|
||||
self:sortHeroList()
|
||||
self.allHeroCount = #self.heroList
|
||||
|
||||
@ -119,13 +119,17 @@ function MainCityUI:_bind()
|
||||
self.subComps[self.selectedIndex]:refreshChapter()
|
||||
end
|
||||
end)
|
||||
|
||||
self:bind(DataManager.PlayerData, "dirty", function(binder, value)
|
||||
self:refreshRoleInfo()
|
||||
end, true)
|
||||
self:bind(DataManager.PlayerData, "lvUpDirty", function(binder, value)
|
||||
self:checkMainPop()
|
||||
end)
|
||||
self:bind(DataManager.FormationData, "dirty", function(binder, value)
|
||||
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then
|
||||
self.subComps[self.selectedIndex]:refresh()
|
||||
end
|
||||
end)
|
||||
|
||||
-- self:bind(DataManager.BagData.ItemData, "dirty", function(binder, value)
|
||||
-- UIManager:refreshCurrencyBarTxt()
|
||||
|
||||
@ -1,7 +1,17 @@
|
||||
local FormationData = class("FormationData", BaseData)
|
||||
|
||||
function FormationData:init(data)
|
||||
self.formations = data and data.formations or {}
|
||||
self.data.dirty = false
|
||||
self.formations = {}
|
||||
if data and data.formations then
|
||||
for formationType, formation in pairs(data.formations) do
|
||||
local clientFormation = {}
|
||||
self.formations[formationType] = clientFormation
|
||||
for matchTypeStr, heroId in pairs(formation) do
|
||||
clientFormation[tonumber(matchTypeStr)] = heroId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function FormationData:getStageFormation()
|
||||
@ -17,4 +27,17 @@ function FormationData:getFormation(formationType)
|
||||
return formation
|
||||
end
|
||||
|
||||
function FormationData:upHeroToFormation(formationType, matchType, heroId)
|
||||
local formation = self:getFormation(formationType)
|
||||
if formation[matchType] == heroId then
|
||||
return
|
||||
end
|
||||
formation[matchType] = heroId
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function FormationData:setDirty()
|
||||
self.data.dirty = not self.data.dirty
|
||||
end
|
||||
|
||||
return FormationData
|
||||
Loading…
x
Reference in New Issue
Block a user