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