小兵战斗 添加后台战斗
parent
0450b49ab5
commit
5e14cc49e5
|
|
@ -1262,7 +1262,9 @@ function this.RecycleAllDelayRes()
|
||||||
for _, v in pairs(this._delayRecycleList) do
|
for _, v in pairs(this._delayRecycleList) do
|
||||||
for i=1, #v do
|
for i=1, #v do
|
||||||
Util.SetGray(v[i].go, false)
|
Util.SetGray(v[i].go, false)
|
||||||
poolManager:UnLoadAsset(v[i].path, v[i].go, PoolManager.AssetType.GameObject)
|
if v[i].go then
|
||||||
|
poolManager:UnLoadAsset(v[i].path, v[i].go, PoolManager.AssetType.GameObject)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
this._delayRecycleList = {}
|
this._delayRecycleList = {}
|
||||||
|
|
|
||||||
|
|
@ -285,12 +285,21 @@ function FloatNode:ArtFloatingOnHook(type, color, value,frameColor)
|
||||||
local animTxtC = animTxt:GetComponent("Text")
|
local animTxtC = animTxt:GetComponent("Text")
|
||||||
animTxtC.text = text
|
animTxtC.text = text
|
||||||
--主要用于给白色字体染色成其他颜色,color 参数只能填白色
|
--主要用于给白色字体染色成其他颜色,color 参数只能填白色
|
||||||
|
|
||||||
|
|
||||||
-- 层级和动画
|
-- 层级和动画
|
||||||
anim:GetComponent("Canvas").sortingOrder = BattleManager.GetBattleSorting() + 100
|
if anim then
|
||||||
anim:GetComponent("Animator"):Play(ArtFloatingAnim[type])
|
anim:GetComponent("Canvas").sortingOrder = BattleManager.GetBattleSorting() + 100
|
||||||
|
--anim:GetComponent("Animator"):Play(ArtFloatingAnim[type])
|
||||||
BattleManager.AddDelayRecycleRes(floatingEffect, go, 0.5)
|
end
|
||||||
|
|
||||||
|
-- if floatingEffect then
|
||||||
|
-- BattleManager.AddDelayRecycleRes(floatingEffect, go,1)
|
||||||
|
-- end
|
||||||
|
local endTime=nil
|
||||||
|
endTime= Timer.New(function ()
|
||||||
|
if go then
|
||||||
|
poolManager:UnLoadAsset(floatingEffect,go, PoolManager.AssetType.GameObject)
|
||||||
|
end
|
||||||
|
end,1,1.5):Start()
|
||||||
|
|
||||||
end
|
end
|
||||||
return FloatNode
|
return FloatNode
|
||||||
|
|
@ -548,16 +548,31 @@ function this.ShowBattleInfo()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local battleTime=0
|
||||||
|
local bossHp=0
|
||||||
|
local curAttack=0
|
||||||
|
local allAttacck=0
|
||||||
function this.BattleLogic()
|
function this.BattleLogic()
|
||||||
if this.battleTimer then
|
if this.battleTimer then
|
||||||
this.battleTimer:Stop()
|
this.battleTimer:Stop()
|
||||||
this.battleTimer = nil
|
this.battleTimer = nil
|
||||||
end
|
end
|
||||||
local cd=0
|
local cd=0
|
||||||
local battleTime=curSoliderStageConfig.Time
|
|
||||||
local bossHp=curSoliderStageConfig.Hp
|
|
||||||
local isHit=false
|
local isHit=false
|
||||||
|
--如果切回这个界面还在打这个boss
|
||||||
|
local bossInfo=SmallSoldierManager.bossInfo
|
||||||
|
if bossInfo and bossInfo.id==FightPointPassManager.soldierLayerId then
|
||||||
|
local curTime=GetTimeStamp()
|
||||||
|
local cha=math.floor(curTime - bossInfo.leaveTime)
|
||||||
|
battleTime=battleTime- cha
|
||||||
|
bossHp=bossHp-math.floor(cha/timeStamp)*bossInfo.attack
|
||||||
|
else
|
||||||
|
battleTime=curSoliderStageConfig.Time
|
||||||
|
bossHp=curSoliderStageConfig.Hp
|
||||||
|
end
|
||||||
|
this.timeTxt.text=battleTime
|
||||||
|
this.hpTxt.text=bossHp
|
||||||
LogError("curSoliderStageConfig.Time===="..curSoliderStageConfig.Time.." curSoliderStageConfig.Hp=="..curSoliderStageConfig.Hp)
|
LogError("curSoliderStageConfig.Time===="..curSoliderStageConfig.Time.." curSoliderStageConfig.Hp=="..curSoliderStageConfig.Hp)
|
||||||
this.battleTimer = Timer.New(function()
|
this.battleTimer = Timer.New(function()
|
||||||
cd=cd+1
|
cd=cd+1
|
||||||
|
|
@ -565,6 +580,7 @@ function this.BattleLogic()
|
||||||
|
|
||||||
if cd==timeStamp then
|
if cd==timeStamp then
|
||||||
--英雄攻击
|
--英雄攻击
|
||||||
|
allAttacck=0
|
||||||
for i=1,6 do
|
for i=1,6 do
|
||||||
if this.heroList[i].spine then
|
if this.heroList[i].spine then
|
||||||
this.heroList[i].effect.transform.position =this.heroList[i].pos.transform.position
|
this.heroList[i].effect.transform.position =this.heroList[i].pos.transform.position
|
||||||
|
|
@ -580,7 +596,8 @@ function this.BattleLogic()
|
||||||
local proList=HeroPropManager.GetHeroProp(this.heroList[i].data.dynamicId, FormationTypeDef.FORMATION_NORMAL)
|
local proList=HeroPropManager.GetHeroProp(this.heroList[i].data.dynamicId, FormationTypeDef.FORMATION_NORMAL)
|
||||||
--LogError("prolist[2]==============="..proList[2])
|
--LogError("prolist[2]==============="..proList[2])
|
||||||
--for i=1,5 do
|
--for i=1,5 do
|
||||||
bossHp=bossHp-proList[2]
|
bossHp=bossHp-proList[2]
|
||||||
|
allAttacck=allAttacck+proList[2]
|
||||||
this.Floater:ArtFloatingOnHook(ArtFloatingType.Damage,ArtFloatingColor.White,proList[2])
|
this.Floater:ArtFloatingOnHook(ArtFloatingType.Damage,ArtFloatingColor.White,proList[2])
|
||||||
--end
|
--end
|
||||||
isHit=true
|
isHit=true
|
||||||
|
|
@ -607,18 +624,14 @@ function this.BattleLogic()
|
||||||
if aaa.effect then
|
if aaa.effect then
|
||||||
aaa.effect:SetActive(false)
|
aaa.effect:SetActive(false)
|
||||||
end
|
end
|
||||||
|
local attack=math.floor(aaa.data.attributes[2].value*(1+add)+0.5)
|
||||||
--aaa.spine.AnimationState:SetAnimation(0, "idle", true)
|
bossHp=bossHp-attack
|
||||||
-- for i=1,5 do
|
allAttacck=allAttacck+attack
|
||||||
--LogError("aaa.data.attributes[2].value=="..aaa.data.attributes[2].value)
|
this.Floater:ArtFloatingOnHook(ArtFloatingType.Damage,ArtFloatingColor.White,attack)
|
||||||
local attack=math.floor(aaa.data.attributes[2].value*(1+add)+0.5)
|
|
||||||
bossHp=bossHp-attack
|
|
||||||
this.Floater:ArtFloatingOnHook(ArtFloatingType.Damage,ArtFloatingColor.White,attack)
|
|
||||||
-- end
|
|
||||||
end)
|
end)
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
|
curAttack=allAttacck
|
||||||
cd=0
|
cd=0
|
||||||
end
|
end
|
||||||
bossSpine.AnimationState:SetAnimation(0, "idle", true)
|
bossSpine.AnimationState:SetAnimation(0, "idle", true)
|
||||||
|
|
@ -637,10 +650,12 @@ function this.BattleLogic()
|
||||||
if bossHp<=0 then
|
if bossHp<=0 then
|
||||||
LogError("boss被击败")
|
LogError("boss被击败")
|
||||||
this.battleTimer:Stop()
|
this.battleTimer:Stop()
|
||||||
NetManager.SoldierFightCheckRequest(function(msg)
|
NetManager.SoldierFightCheckRequest(1,function(msg)
|
||||||
--战斗成功
|
--战斗成功
|
||||||
if msg.result==1 then
|
if msg.result==1 then
|
||||||
FightPointPassManager.soldierLayerId=curSoliderStageConfig.NextId
|
if curSoliderStageConfig.NextId~=0 then
|
||||||
|
FightPointPassManager.soldierLayerId=curSoliderStageConfig.NextId
|
||||||
|
end
|
||||||
curSoliderStageConfig=ConfigManager.GetConfigData(ConfigName.SoldierStageConfig,FightPointPassManager.soldierLayerId)
|
curSoliderStageConfig=ConfigManager.GetConfigData(ConfigName.SoldierStageConfig,FightPointPassManager.soldierLayerId)
|
||||||
local heroData = ConfigManager.GetConfigData(ConfigName.HeroConfig,curSoliderStageConfig.Hero)
|
local heroData = ConfigManager.GetConfigData(ConfigName.HeroConfig,curSoliderStageConfig.Hero)
|
||||||
local name=GetResourcePath(heroData.Live)
|
local name=GetResourcePath(heroData.Live)
|
||||||
|
|
@ -1266,6 +1281,14 @@ function FightPointPassMainPanel:OnClose()
|
||||||
this.skillTimer:Stop()
|
this.skillTimer:Stop()
|
||||||
this.skillTimer = nil
|
this.skillTimer = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local bossInfo={}
|
||||||
|
bossInfo.hp=bossHp
|
||||||
|
bossInfo.id=FightPointPassManager.soldierLayerId
|
||||||
|
bossInfo.attack=curAttack
|
||||||
|
bossInfo.time=battleTime
|
||||||
|
bossInfo.leaveTime=GetTimeStamp()
|
||||||
|
SmallSoldierManager.bossInfo=bossInfo
|
||||||
end
|
end
|
||||||
|
|
||||||
--界面销毁时调用(用于子类重写)
|
--界面销毁时调用(用于子类重写)
|
||||||
|
|
@ -1303,6 +1326,7 @@ function FightPointPassMainPanel:OnDestroy()
|
||||||
if this.battleTimer then
|
if this.battleTimer then
|
||||||
this.battleTimer:Stop()
|
this.battleTimer:Stop()
|
||||||
LogError("停止战斗---------------------------------")
|
LogError("停止战斗---------------------------------")
|
||||||
|
|
||||||
this.battleTimer=nil
|
this.battleTimer=nil
|
||||||
end
|
end
|
||||||
this.Floater:Dispose()
|
this.Floater:Dispose()
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ this.upEndTime=0
|
||||||
function this.Initialize()
|
function this.Initialize()
|
||||||
|
|
||||||
this.soldierList={}
|
this.soldierList={}
|
||||||
|
--界面boss信息
|
||||||
|
this.bossInfo=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.InitData(msg)
|
function this.InitData(msg)
|
||||||
|
|
@ -16,12 +18,9 @@ function this.InitData(msg)
|
||||||
this.soldierList={}
|
this.soldierList={}
|
||||||
this.level=msg.level
|
this.level=msg.level
|
||||||
this.upEndTime=msg.upLvEndTime
|
this.upEndTime=msg.upLvEndTime
|
||||||
--this.soldierList=msg.soldiers
|
|
||||||
--LogError("this.level============"..this.level.." endtime============"..this.upEndTime.." msg.soldiers len==="..#msg.soldiers)
|
|
||||||
if msg.soldiers then
|
if msg.soldiers then
|
||||||
for i=1,#msg.soldiers do
|
for i=1,#msg.soldiers do
|
||||||
local v= msg.soldiers[i]
|
local v= msg.soldiers[i]
|
||||||
--LogError("position====================="..v.position)
|
|
||||||
if v.position==-1 then
|
if v.position==-1 then
|
||||||
this.changeSolider=v
|
this.changeSolider=v
|
||||||
else
|
else
|
||||||
|
|
@ -33,11 +32,35 @@ function this.InitData(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
for k, v in pairs(this.soldierList) do
|
|
||||||
LogError("k============="..k)
|
|
||||||
end
|
|
||||||
--LogError("服务器发过来的小兵 this.soldierList=================len=="..#this.soldierList.." msg.soldiers===="..#msg.soldiers)
|
--LogError("服务器发过来的小兵 this.soldierList=================len=="..#this.soldierList.." msg.soldiers===="..#msg.soldiers)
|
||||||
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Solider)
|
||||||
|
|
||||||
|
local cd=60
|
||||||
|
Timer.New(function()
|
||||||
|
cd=cd-1
|
||||||
|
--LogError("cd============================"..cd)
|
||||||
|
if cd<=0 then
|
||||||
|
if UIManager.GetOpenPanel(UIName.FightPointPassMainPanel)==nil then
|
||||||
|
LogError("发送小兵挂机战斗请求======================================================")
|
||||||
|
NetManager.SoldierFightCheckRequest(0,function (msg)
|
||||||
|
if msg.result==1 then
|
||||||
|
local lvConfig=ConfigManager.GetConfigData(ConfigName.SoldierStageConfig,FightPointPassManager.soldierLayerId)
|
||||||
|
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
|
||||||
|
end
|
||||||
|
if cd==0 then
|
||||||
|
cd=120
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, 1, -1, true):Start()
|
||||||
|
|
||||||
end
|
end
|
||||||
--获取所有的加成属性
|
--获取所有的加成属性
|
||||||
function this.GetAllAddPro()
|
function this.GetAllAddPro()
|
||||||
|
|
|
||||||
|
|
@ -7876,15 +7876,16 @@ function NetManager.UpSoldierLevelRequest(_pos, _func)
|
||||||
end
|
end
|
||||||
|
|
||||||
--小兵战斗校验
|
--小兵战斗校验
|
||||||
function NetManager.SoldierFightCheckRequest(_func)
|
function NetManager.SoldierFightCheckRequest(_type,_func)
|
||||||
local data=MapInfoProto_pb.ReplaceSoldierRequest()
|
local data=MapInfoProto_pb.ReplaceSoldierRequest()
|
||||||
--data.operate=_pos
|
--data.operate=_pos
|
||||||
|
local type=_type
|
||||||
local msg = data:SerializeToString()
|
local msg = data:SerializeToString()
|
||||||
Network:SendMessageWithCallBack(MessageTypeProto_pb.SoldierFightCheckRequest,MessageTypeProto_pb.SoldierFightCheckResponse,msg,function(buffer)
|
Network:SendMessageWithCallBack(MessageTypeProto_pb.SoldierFightCheckRequest,MessageTypeProto_pb.SoldierFightCheckResponse,msg,function(buffer)
|
||||||
local data = buffer:DataByte()
|
local data = buffer:DataByte()
|
||||||
local msg = MapInfoProto_pb.SoldierFightCheckResponse()
|
local msg = MapInfoProto_pb.SoldierFightCheckResponse()
|
||||||
msg:ParseFromString(data)
|
msg:ParseFromString(data)
|
||||||
if msg.drop then
|
if msg.drop and type==1 then
|
||||||
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1)
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1)
|
||||||
end
|
end
|
||||||
if _func then
|
if _func then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue