226 lines
10 KiB
Lua
226 lines
10 KiB
Lua
SmallSoldierManager = {}
|
|
local this = SmallSoldierManager
|
|
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local settingConfig=ConfigManager.GetConfig(ConfigName.SoldiersSetting)
|
|
local propertyConfig=ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
this.level=1
|
|
this.changeSolider=nil
|
|
this.upEndTime=0
|
|
local timeStamp=4
|
|
local specialConfig=ConfigManager.GetConfigData(ConfigName.SpecialConfig,179)
|
|
if specialConfig and specialConfig.Value then
|
|
timeStamp=tonumber(specialConfig.Value)
|
|
end
|
|
function this.Initialize()
|
|
this.isFirst=true
|
|
this.soldierList={}
|
|
--界面boss信息
|
|
this.bossInfo=nil
|
|
this.soliderAdd=0
|
|
this.isAuto=false
|
|
end
|
|
|
|
function this.InitData(msg)
|
|
--LogError("初始化============================================小兵管理器")
|
|
this.soldierList={}
|
|
this.level=msg.level
|
|
this.upEndTime=msg.upLvEndTime
|
|
this.soliderAdd=msg.attackUp
|
|
--LogError("msg.attackUp================================================================="..msg.attackUp)
|
|
if msg.soldiers then
|
|
for i=1,#msg.soldiers do
|
|
local v= msg.soldiers[i]
|
|
if v.position==-1 then
|
|
this.changeSolider=v
|
|
else
|
|
if v.position then
|
|
this.soldierList[v.position] = v
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
end
|
|
--LogError("服务器发过来的小兵 this.soldierList=================len=="..#this.soldierList.." msg.soldiers===="..#msg.soldiers)
|
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
|
|
|
--local cd=10
|
|
--local attackCD=0
|
|
--local bossHp=0
|
|
-- Timer.New(function()
|
|
-- if FightPointPassManager.soldierLayerId>1 then
|
|
|
|
-- --LogError("cd============================"..cd)
|
|
-- --if cd<=0 then
|
|
-- if UIManager.GetOpenPanel(UIName.FightPointPassMainPanel)==nil then
|
|
-- if this.isFirst and SmallSoldierManager.bossInfo then
|
|
-- cd=SmallSoldierManager.bossInfo.time
|
|
-- bossHp=SmallSoldierManager.bossInfo.hp
|
|
-- this.isFirst=false
|
|
-- end
|
|
-- attackCD=attackCD+1
|
|
-- --到达攻击间隔
|
|
-- if attackCD>=timeStamp then
|
|
-- bossHp=bossHp - this.GetCurrAllAttack()
|
|
-- attackCD=0
|
|
-- if bossHp<=0 then
|
|
-- -- LogError("后台挂机boss被击败------------------------------------")
|
|
-- end
|
|
-- end
|
|
-- cd=cd-1
|
|
-- if cd<=0 or bossHp<=0 then
|
|
-- --LogError("发送小兵挂机战斗请求======================================================")
|
|
-- local curConfig=ConfigManager.GetConfigData(ConfigName.SoldierStageConfig,FightPointPassManager.soldierLayerId)
|
|
-- LogError("GetOpenServerDayNum()========================="..GetOpenServerDayNum().." FightPointPassManager.soldierLayerId=="..FightPointPassManager.soldierLayerId)
|
|
-- if curConfig.OpenRule[1][2]<=GetOpenServerDayNum() then
|
|
-- NetManager.SoldierFightCheckRequest(0,function (msg)
|
|
|
|
-- local lvConfig=ConfigManager.GetConfigData(ConfigName.SoldierStageConfig,FightPointPassManager.soldierLayerId)
|
|
-- if msg.result==1 then
|
|
-- if lvConfig and lvConfig.NextId and lvConfig.NextId~=0 then
|
|
-- FightPointPassManager.soldierLayerId = lvConfig.NextId
|
|
-- local curConfig=ConfigManager.GetConfigData(ConfigName.SoldierStageConfig,FightPointPassManager.soldierLayerId)
|
|
-- if curConfig then
|
|
-- cd=curConfig.Time
|
|
-- end
|
|
-- bossHp=lvConfig.Hp
|
|
-- end
|
|
-- if cd==0 then
|
|
-- cd=lvConfig.Time
|
|
-- bossHp=lvConfig.Hp
|
|
-- end
|
|
-- else
|
|
-- cd=lvConfig.Time
|
|
-- bossHp=lvConfig.Hp
|
|
-- if PlayerPrefs.GetInt("SmallSoldierFailed"..PlayerManager.uid)~=FightPointPassManager.soldierLayerId then
|
|
-- if not GuideManager.IsInMainGuide() and UIManager.GetOpenPanel(UIName.BattlePanel)==nil and UIManager.GetOpenPanel(UIName.BattleWinPopup)==nil then
|
|
-- UIManager.OpenPanel(UIName.SmallSoldierFailPop)
|
|
-- end
|
|
-- PlayerPrefs.SetInt("SmallSoldierFailed"..PlayerManager.uid,FightPointPassManager.soldierLayerId)
|
|
-- end
|
|
-- end
|
|
-- end)
|
|
-- else
|
|
-- cd=curConfig.Time
|
|
-- bossHp=curConfig.Hp
|
|
-- if PlayerPrefs.GetInt("SmallSoldierFailed"..PlayerManager.uid)~=FightPointPassManager.soldierLayerId then
|
|
-- if not GuideManager.IsInMainGuide() and UIManager.GetOpenPanel(UIName.BattlePanel)==nil and UIManager.GetOpenPanel(UIName.BattleWinPopup)==nil then
|
|
-- UIManager.OpenPanel(UIName.SmallSoldierFailPop)
|
|
-- end
|
|
-- PlayerPrefs.SetInt("SmallSoldierFailed"..PlayerManager.uid,FightPointPassManager.soldierLayerId)
|
|
-- end
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- end
|
|
-- --end
|
|
-- end
|
|
|
|
|
|
-- end, 1, -1, true):Start()
|
|
|
|
end
|
|
|
|
--获取当前所有战斗力
|
|
function this.GetCurrAllAttack()
|
|
local team=FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
|
|
local allAttack=0
|
|
for i=1,6 do
|
|
if team.teamHeroInfos[i] then
|
|
local heroId=team.teamHeroInfos[i].heroId
|
|
--local proList=HeroPropManager.GetHeroProp(heroId, FormationTypeDef.FORMATION_NORMAL)
|
|
-- prolist[2]
|
|
local power=HeroPowerManager.GetHeroPower(heroId, FormationTypeDef.FORMATION_NORMAL)
|
|
if power then
|
|
allAttack=allAttack+ math.floor(power*(1+this.soliderAdd/100)+0.5)
|
|
end
|
|
end
|
|
end
|
|
local lotteryConfig=ConfigManager.GetConfigData(ConfigName.SoldiersLotteryConfig,SmallSoldierManager.level)
|
|
local add=lotteryConfig.SoldiersUP/10000
|
|
for k, v in pairs(this.soldierList) do
|
|
local power=0
|
|
for p=1, 4 do
|
|
power=power + (v.attributes[p].value*propertyConfig[p].Score)
|
|
end
|
|
power=math.floor(power)
|
|
local add=math.floor(power*(1+add)+0.5)
|
|
--LogError("add============================"..add.." math.floor(add*(1+this.soliderAdd/100)+0.5=="..math.floor(add*(1+this.soliderAdd/100)+0.5))
|
|
allAttack=allAttack+ math.floor(add*(1+this.soliderAdd/100)+0.5)
|
|
end
|
|
--LogError("挂机总伤害===================================================="..allAttack)
|
|
return allAttack
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--获取所有的加成属性
|
|
function this.GetAllHeroAddPro()
|
|
local allAddPro={}
|
|
local list=HeroManager.GetAllHeroList() --FormationManager.GetAllMainFormationHeroId()
|
|
-- LogError("获取所有加成属性============================= list len=="..#list)
|
|
for key, hero in pairs(list) do
|
|
local id=key
|
|
--LogError("id======================================"..id)
|
|
local heroData=HeroManager.GetSingleHeroData(id)
|
|
--便利队伍里每个英雄
|
|
if heroData and allAddPro[heroData.id]==nil then
|
|
--便利队伍里所有小兵给这个英雄加的属性
|
|
local proList={}
|
|
for k, v in pairs(this.soldierList) do
|
|
local addPro=0
|
|
--便利阵营
|
|
for j=1, #settingConfig[v.id].PropertyName do
|
|
local aaa=settingConfig[v.id].PropertyName[j]
|
|
if aaa then
|
|
if aaa[1]==0 then
|
|
addPro=addPro+aaa[2]
|
|
--LogError("111111111111111111111111111111")
|
|
elseif heroData.heroConfig.PropertyName==aaa[1] then
|
|
addPro=addPro+aaa[2]
|
|
end
|
|
end
|
|
end
|
|
for j=1, #settingConfig[v.id].Profession do
|
|
local aaa=settingConfig[v.id].Profession[j]
|
|
if aaa then
|
|
if aaa[1]==0 then
|
|
addPro=addPro+aaa[2]
|
|
elseif heroData.heroConfig.Profession==aaa[1] then
|
|
addPro=addPro+aaa[2]
|
|
end
|
|
end
|
|
end
|
|
-- for prok, prov in pairs(v.attributes) do
|
|
|
|
|
|
-- end
|
|
--LogError("addpro============================"..addPro)
|
|
for j=1,#v.attributes do
|
|
local prov=v.attributes[j]
|
|
if proList[prov.id] then
|
|
proList[prov.id]=proList[prov.id]+math.floor(prov.value*addPro/10000+0.5)
|
|
else
|
|
proList[prov.id]=math.floor(prov.value*addPro/10000+0.5)
|
|
|
|
end
|
|
end
|
|
end
|
|
|
|
allAddPro[heroData.id]=proList
|
|
-- for k, v in pairs(proList) do
|
|
-- LogError("k============"..k.." value======="..v.." herodata.name=="..heroData.heroConfig.ReadingName)
|
|
-- end
|
|
end
|
|
end
|
|
|
|
return allAddPro
|
|
end
|
|
|
|
|
|
return this |