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