阵容
This commit is contained in:
parent
45506b2638
commit
882d4ca6fe
@ -1,20 +1,21 @@
|
||||
local FormationManager = class("FormationManager", BaseModule)
|
||||
|
||||
-- 主线编队
|
||||
function FormationManager:upHeroToStageFormation(heroId, matchType)
|
||||
function FormationManager:upHeroToStageFormation(heroIds, matchType)
|
||||
local formation = DataManager.FormationData:getStageFormation()
|
||||
if formation[matchType] == heroId then
|
||||
return
|
||||
end
|
||||
local args = {
|
||||
id = heroId
|
||||
type = 1,
|
||||
heroes = heroIds
|
||||
}
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.HeroPutOnReq, args, {}, self.upHeroToStageFormationFinish)
|
||||
self:sendMessage(ProtoMsgType.FromMsgEnum.FormationSetReq, args, {}, self.upHeroToStageFormationFinish)
|
||||
end
|
||||
|
||||
function FormationManager:upHeroToStageFormationFinish(result)
|
||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||
DataManager.FormationData:initStage(result)
|
||||
DataManager.FormationData:initStage(result.reqData.heroes)
|
||||
DataManager.HeroData:setDirty()
|
||||
|
||||
local data = {}
|
||||
|
||||
@ -143,7 +143,10 @@ function HeroComp:refreshStageFormation()
|
||||
self.curFormation = DataManager.FormationData:getStageFormation()
|
||||
|
||||
self.onClickUseFunc = function(id, type)
|
||||
ModuleManager.FormationManager:upHeroToStageFormation(id, type)
|
||||
local formation = DataManager.FormationData:getStageFormation()
|
||||
local cfg = DataManager.HeroData:getHeroConfig(id)
|
||||
formation[cfg.position] = id
|
||||
ModuleManager.FormationManager:upHeroToStageFormation(formation, type)
|
||||
end
|
||||
|
||||
self:refreshScrollRect()
|
||||
|
||||
@ -26,18 +26,8 @@ end
|
||||
|
||||
-- 初始化主线阵容
|
||||
function FormationData:initStage(data)
|
||||
data = data or {}
|
||||
self.formations = self.formations or {}
|
||||
|
||||
if data.heroes then
|
||||
local clientFormation = {}
|
||||
for matchType, heroId in pairs(data.heroes) do
|
||||
clientFormation[tonumber(matchType)] = heroId
|
||||
end
|
||||
self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = clientFormation
|
||||
else
|
||||
self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = {0,0,0,0,0}
|
||||
end
|
||||
self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = data or {0,0,0,0,0}
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user