184 lines
4.4 KiB
Lua
184 lines
4.4 KiB
Lua
local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
|
|
|
|
local BattleSkillEntity = class("BattleSkillEntity", BaseData)
|
|
|
|
BattleSkillEntity.sid = 0
|
|
|
|
function BattleSkillEntity:ctor(skillId, skillType, owner)
|
|
self.skillType = skillType
|
|
self.skillId = skillId
|
|
self.owner = owner
|
|
BattleSkillEntity.sid = BattleSkillEntity.sid + 1
|
|
self.sid = BattleSkillEntity.sid
|
|
self:init()
|
|
end
|
|
|
|
function BattleSkillEntity:init()
|
|
self.skillInfo = ConfigManager:getConfig("skill")[self.skillId]
|
|
self.coolingRounds = self.skillInfo.cd or 0
|
|
if self.skillInfo.cd_start then -- 开场就进入cd
|
|
self.cd = self.skillInfo.cd_start
|
|
else
|
|
self.cd = 0
|
|
end
|
|
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:startUse()
|
|
self.skillCanUseTimes = self.owner:getSkillExtraUseTimes(self.skillId) + 1
|
|
end
|
|
|
|
function BattleSkillEntity:getSkillCanUseTimes()
|
|
return self.skillCanUseTimes
|
|
end
|
|
|
|
function BattleSkillEntity:cooldown(round)
|
|
if self.cd > 0 then
|
|
self.cd = self.cd - (round or 1)
|
|
if self.cd < 0 then
|
|
self.cd = 0
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 技能是否可用
|
|
function BattleSkillEntity:getIsAvailable()
|
|
return self.cd == 0
|
|
end
|
|
|
|
-- 技能释放完毕
|
|
function BattleSkillEntity:endUse()
|
|
self.cd = self.coolingRounds
|
|
if self.skillCanUseTimes then
|
|
self.skillCanUseTimes = self.skillCanUseTimes - 1
|
|
end
|
|
end
|
|
|
|
function BattleSkillEntity:addSkillEffectParams(effect)
|
|
local buffEntity
|
|
for _, entity in ipairs(self.effectList) do
|
|
if entity:getName() == effect.type then
|
|
buffEntity = entity
|
|
break
|
|
end
|
|
end
|
|
if not buffEntity then
|
|
buffEntity = BattleBuffEntity:create()
|
|
buffEntity:init(effect, self.owner)
|
|
table.insert(self.effectList, buffEntity)
|
|
else
|
|
buffEntity:setEffectNum(buffEntity:getEffectNum() + effect.num)
|
|
end
|
|
end
|
|
|
|
function BattleSkillEntity:addSkillEffectRound(effect)
|
|
local buffEntity
|
|
for _, entity in ipairs(self.effectList) do
|
|
if entity:getName() == effect.type then
|
|
buffEntity = entity
|
|
break
|
|
end
|
|
end
|
|
if not buffEntity then
|
|
buffEntity = BattleBuffEntity:create()
|
|
buffEntity:init(effect, self.owner)
|
|
table.insert(self.effectList, buffEntity)
|
|
else
|
|
buffEntity:setRound(buffEntity:getRound() + effect.round)
|
|
end
|
|
end
|
|
|
|
function BattleSkillEntity:getSkillid()
|
|
return self.skillId
|
|
end
|
|
|
|
function BattleSkillEntity:getIsPassiveType()
|
|
return self.skillType == GConst.BattleConst.SKILL_TYPE_PASSIVE
|
|
end
|
|
|
|
function BattleSkillEntity:changeSkillId(skillId)
|
|
self.skillId = skillId
|
|
self:init()
|
|
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
|
|
|
|
function BattleSkillEntity:getSid()
|
|
return self.sid
|
|
end
|
|
|
|
function BattleSkillEntity:getPassiveTriggerValue()
|
|
return self.skillInfo.trigger_value
|
|
end
|
|
|
|
function BattleSkillEntity:getPassiveTriggerId()
|
|
return self.skillInfo.trigger
|
|
end
|
|
|
|
function BattleSkillEntity:getRecordData(name)
|
|
if self.recordData == nil then
|
|
self.recordData = {}
|
|
end
|
|
return self.recordData[name]
|
|
end
|
|
|
|
function BattleSkillEntity:setRecordData(name, value)
|
|
if self.recordData == nil then
|
|
self.recordData = {}
|
|
end
|
|
self.recordData[name] = value
|
|
end
|
|
|
|
function BattleSkillEntity:clearRecordData()
|
|
if self.recordData then
|
|
for k, v in pairs(self.recordData) do
|
|
self.recordData[k] = nil
|
|
end
|
|
end
|
|
end
|
|
|
|
return BattleSkillEntity |