c1_lua/lua/app/userdata/battle/skill/battle_skill_entity.lua
2023-04-17 18:40:39 +08:00

63 lines
1.8 KiB
Lua

local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
local BattleSkillEntity = class("BattleSkillEntity", BaseData)
function BattleSkillEntity:ctor(skillId, skillType, owner)
self.skillType = skillType
self.skillId = skillId
self.owner = owner
self:init()
end
function BattleSkillEntity:init()
self.skillInfo = ConfigManager:getConfig("skill")[self.skillId]
self:initSkillEffect()
end
function BattleSkillEntity:initSkillEffect()
self.effectList = {}
if self.skillInfo.effect then
for k, v in ipairs(self.skillInfo.effect) do
local buffEntity = BattleBuffEntity:create()
buffEntity:init(v, self.owner)
table.insert(self.effectList, buffEntity)
end
end
end
function BattleSkillEntity:getMoveType()
return self.skillInfo.position
end
function BattleSkillEntity:getRandomNormalAttackName()
if self.normalSkillNameList == nil then
local normalSkillNameList, count = self.owner:getNormalSkillNameList()
self.normalSkillNameList = {}
for i = 1, count do
self.normalSkillNameList[i] = normalSkillNameList[i]
end
end
if self.normalSkillNameIndex == nil then
self.normalSkillNameIndex = math.random(1, #self.normalSkillNameList)
else
local temp = self.normalSkillNameList[#self.normalSkillNameList]
self.normalSkillNameList[#self.normalSkillNameList] = self.normalSkillNameList[self.normalSkillNameIndex]
self.normalSkillNameList[self.normalSkillNameIndex] = temp
self.normalSkillNameIndex = math.random(1, #self.normalSkillNameList - 1)
end
return self.normalSkillNameList[self.normalSkillNameIndex]
end
function BattleSkillEntity:getSkillAttackName()
return self.skillInfo.name_act
end
function BattleSkillEntity:getEffectList()
return self.effectList
end
function BattleSkillEntity:getTargetType()
return self.skillInfo.obj
end
return BattleSkillEntity