miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Monster/Monster.lua

119 lines
3.3 KiB
Lua

require("Modules.Battle.Logic.Monster.MonsterSkill.MSkillManager")
Monster = {}
function Monster:New()
local o = {
data=RoleData.New(),
buffFilter=BattleList.New(),
Event = BattleEvent:New()
}
setmetatable(o, self)
self.__index = self
return o
end
-- 初始化
function Monster:Init(data)
self.type = BattleUnitType.Monster
self.camp = data.camp
-- if data.position==10 then
-- self.type = BattleUnitType.Player
-- end
self.position = data.position
self.star = data.star
self.uid= data.id
self.teamDamage=data.teamDamage
self.roleData = data
self.sex=data.sex
self.addAttack=0
self.data:Init(self, data.property)
self.buffFilter:Clear() --buff屏蔽列表
self.Event:ClearEvent()
self.exileTargets={}--已经被放逐过的目标
-- self.skillGroup = MSkillManager.CreateMSkillGroup(self, data.skill)
-- self.skillList=data.skill
self.skillGroupList = {}
for i = 1, #data.skill do
-- LogError("---------------------"..data.skill[i].skillData.effect[1])
--LogError("monster skill id=="..data.skill[i])
self.skillGroupList[i] = MSkillManager.CreateMSkillGroup(self, i, data.skill[i])
end
if data.passivity and #data.passivity > 0 then
table.sort(data.passivity,function(a,b)
return a[1] < b[1]
end)
for i = 1, #data.passivity do
local v = data.passivity[i]
local passivityId = tonumber(v[1])
local judge=v[2]
local id = tonumber(v[3])
local args = {}
for j = 4, #v do
args[j-3] = v[j]
end
if BattleUtil.Passivity[id] then
BattleUtil.Passivity[id](self, args,passivityId,judge)
BattleLogManager.Log(
"Add Passive",
"id", tostring(id),
"camp", tostring(self.camp),
"pos", tostring(self.position),
"passivityId", tostring(passivityId),
"judge", tostring(judge)
)
end
end
end
end
function Monster:AddBuff(buff)
-- buff的miss率
local missF = 0
-- 检测被动对miss概率的影响
local cl = {}
local function _CallBack(v, ct)
if v then
table.insert(cl, {v, ct})
end
end
BattleLogic.Event:DispatchEvent(BattleEventName.RoleAddBuffMiss, _CallBack, self, buff)
missF = BattleUtil.CountChangeList(missF, cl)
-- 如果概率为0 或者没有miss
if missF == 0 or not BattleUtil.RandomAction(missF, function() BattleLogic.BuffMgr:PutBuff(buff) end) then
for i=1, self.buffFilter.size do
if self.buffFilter.buffer[i](buff) then
BattleLogic.BuffMgr:PutBuff(buff)
return
end
end
BattleLogic.BuffMgr:AddBuff(self, buff)
end
end
function Monster:GetRoleData(property)
local tarPro = self.data:GetData(property)
return tarPro
end
function Monster:GetCamp()
return self.camp
end
function Monster:GetPosition()
return self.position
end
function Monster:GetStar()
return self.star
end
-- 数据回收
function Monster:Dispose()
end
return Monster