战斗逻辑

back_recharge
lvxinran 2019-12-31 16:35:42 +08:00
parent f1cbb7b63e
commit 2f9fb3c349
13 changed files with 28 additions and 29 deletions

View File

@ -1,5 +1,4 @@
Buff = {}
local floor = math.floor
local buffPoolList = {}
@ -50,7 +49,7 @@ BuffManager = {}
BuffManager.__index = BuffManager
function BuffManager.New()
local instance = {owner=0, buffQueue = BattleQueue.New(), buffList = BattleDictionary.New()}
local instance = {owner=0, buffQueue = BattleQueue.New(), buffDic = BattleDictionary.New()}
setmetatable(instance, BuffManager)
return instance
end
@ -59,15 +58,15 @@ function BuffManager:Init()
while self.buffQueue.size > 0 do
putBuff(self.buffQueue:Dequeue())
end
for i = 1, self.buffList.size do
local list = self.buffList.vList[i]
for i = 1, self.buffDic.size do
local list = self.buffDic.vList[i]
for j=1, list.size do
putBuff(list.buffer[j])
end
list:Clear()
buffListPool:Put(list)
end
self.buffList:Clear()
self.buffDic:Clear()
end
function BuffManager:AddBuff(target, buff)
@ -89,8 +88,8 @@ function BuffManager:AddBuff(target, buff)
end
function BuffManager:QueryBuff(target, checkFunc)
for i=1, self.buffList.size do
local list = self.buffList.vList[i]
for i=1, self.buffDic.size do
local list = self.buffDic.vList[i]
for j=1, list.size do
local buff = list.buffer[j]
if buff.target == target then
@ -103,8 +102,8 @@ function BuffManager:QueryBuff(target, checkFunc)
end
function BuffManager:HasBuff(target, type, checkFunc)
if self.buffList.kvList[type] then
local buffList = self.buffList.kvList[type]
if self.buffDic.kvList[type] then
local buffList = self.buffDic.kvList[type]
for i=1, buffList.size do
local v = buffList.buffer[i]
if v.target == target then
@ -119,8 +118,8 @@ end
--func为nil时无条件清除否则判定clear值执行func
function BuffManager:ClearBuff(target, func)
for i = 1, self.buffList.size do
local list = self.buffList.vList[i]
for i = 1, self.buffDic.size do
local list = self.buffDic.vList[i]
if list.size > 0 then
local idx = 1
while idx <= list.size do
@ -143,8 +142,8 @@ function BuffManager:PutBuff(buff)
end
function BuffManager:GetBuffCount(type)
if self.buffList[type] then
return self.buffList[type].size
if self.buffDic[type] then
return self.buffDic[type].size
end
return 0
end
@ -153,11 +152,11 @@ function BuffManager:Update()
while self.buffQueue.size > 0 do
local buff = self.buffQueue:Dequeue()
local buffList
if not self.buffList.kvList[buff.type] then
if not self.buffDic.kvList[buff.type] then
buffList = buffListPool:Get()
self.buffList:Add(buff.type, buffList)
self.buffDic:Add(buff.type, buffList)
else
buffList = self.buffList.kvList[buff.type]
buffList = self.buffDic.kvList[buff.type]
end
if buff.cover and buffList.size > 0 then
local isCovered = false
@ -186,8 +185,8 @@ function BuffManager:Update()
buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff)
end
end
for i=1, self.buffList.size do
local buffList = self.buffList.vList[i]
for i=1, self.buffDic.size do
local buffList = self.buffDic.vList[i]
if buffList.size > 0 then
local index = 1
while index <= buffList.size do

View File

@ -1505,11 +1505,17 @@ local effectList = {
local f1 = args[1]
local f2 = args[2]
BattleLogic.WaitForTrigger(interval, function ()
local lastTrigger = 0
local OnPassiveDamaging = function(damagingFunc, atkRole, damage)
lastTrigger = lastTrigger + 1
if lastTrigger > 1 then --加入限定避免循环触发
return
end
if not target.isDead then
damagingFunc(floor(damage * f1))
BattleUtil.ApplyDamage(atkRole, target, BattleUtil.CalShield(atkRole, target, floor(damage * f1)))
end
lastTrigger = 0
end
local list = BattleLogic.GetNeighbor(target, 1)
for i=1, #list do

View File

@ -1188,7 +1188,7 @@ local passivityList = {
if BattleLogic.BuffMgr:HasBuff(role, BuffName.Shield, function (buff) return true end) then
BattleUtil.RandomAction(f1, function ()
local val = floor(BattleUtil.FP_Mul(role:GetRoleData(propertyList[pro1]), f2))
BattleUtil.CalTreat(skill.owner, skill.owner, val)
BattleUtil.CalTreat(role, skill.owner, val)
end)
end
end
@ -1212,7 +1212,7 @@ local passivityList = {
local f2 = args[3]
BattleLogic.Event:AddEvent(BattleEventName.BattleRoleDead, function (defRole, atkRole)
if atkRole.isTeam then
if role.isDead or atkRole.isTeam then
return
end
if defRole.camp == role.camp then

View File

@ -12,7 +12,7 @@ local curFrame
local playerSkillUsable
local enemySkillUsable
BattleLogic.Type = 0 --1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战 8 兽潮
BattleLogic.Type = 0 --1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战 8 兽潮 9巅峰战
BattleLogic.IsEnd = false
BattleLogic.Result = -1
BattleLogic.Event = BattleEvent.New()

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
Aura = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
Brand = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
Control = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
DOT = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
HOT = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
Immune = Buff:New()
local immune1 = function(buff)

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
PropertyChange = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值

View File

@ -1,4 +1,3 @@
require("Modules/Battle/Logic/Base/Buff")
Shield = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值

View File

@ -206,10 +206,12 @@ end
function RoleLogic:AddBuff(buff)
if self.isDead then
BattleLogic.BuffMgr:PutBuff(buff)
return
end
for i=1, self.buffFilter.size do
if self.buffFilter.buffer[i](buff) then
BattleLogic.BuffMgr:PutBuff(buff)
return
end
end