Merge branch 'dev' of http://git.juzugame.com/b6-client/b6-lua into dev
This commit is contained in:
commit
c0eedc10ce
@ -17,10 +17,11 @@ BattleConst.SKILL_TYPE_ACTIVE = 1
|
|||||||
BattleConst.SKILL_SELECT_COUNT = 3
|
BattleConst.SKILL_SELECT_COUNT = 3
|
||||||
BattleConst.DEFAULT_FACTOR = 10000
|
BattleConst.DEFAULT_FACTOR = 10000
|
||||||
BattleConst.INIT_POS_X = 200 -- 战斗单位初始化的坐标
|
BattleConst.INIT_POS_X = 200 -- 战斗单位初始化的坐标
|
||||||
BattleConst.UNIT_FRONT_POS_X = 160 -- 战斗单位身前的坐标
|
BattleConst.UNIT_FRONT_POS_X = 0 -- 战斗单位身前的坐标
|
||||||
BattleConst.UNIT_BODY_WIDTH = 100
|
BattleConst.UNIT_BODY_WIDTH = 200
|
||||||
BattleConst.UNIT_FRONT_DISTANCE = 50
|
BattleConst.UNIT_FRONT_DISTANCE = 50
|
||||||
BattleConst.MOVE_SPEED = 500 -- 战斗单位的移动速度
|
BattleConst.MOVE_SPEED = 500 -- 战斗单位的移动速度
|
||||||
|
BattleConst.HURT_STATE_CRIT = 1 -- 暴击
|
||||||
|
|
||||||
-- 为方便存储,这里使用字符串
|
-- 为方便存储,这里使用字符串
|
||||||
BattleConst.BATTLE_TYPE = {
|
BattleConst.BATTLE_TYPE = {
|
||||||
@ -30,6 +31,7 @@ BattleConst.BATTLE_TYPE = {
|
|||||||
BattleConst.TYPEOF_LUA_COMP = {
|
BattleConst.TYPEOF_LUA_COMP = {
|
||||||
BATTLE_HERO_COMPONENT = "app/module/battle/component/battle_hero_comp",
|
BATTLE_HERO_COMPONENT = "app/module/battle/component/battle_hero_comp",
|
||||||
BATTLE_MONSTER_COMPONENT = "app/module/battle/component/battle_monster_comp",
|
BATTLE_MONSTER_COMPONENT = "app/module/battle/component/battle_monster_comp",
|
||||||
|
BATTLE_NUMBER_COMPONENT = "app/module/battle/component/battle_number_comp",
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleConst.SKILL_MOVE_TYPE = {
|
BattleConst.SKILL_MOVE_TYPE = {
|
||||||
@ -48,7 +50,16 @@ BattleConst.UNIT_STATE = {
|
|||||||
|
|
||||||
BattleConst.SPINE_ANIMATION_NAME = {
|
BattleConst.SPINE_ANIMATION_NAME = {
|
||||||
IDLE = "idle",
|
IDLE = "idle",
|
||||||
ATTACK = "attack01",
|
ATTACK = "atk1",
|
||||||
|
MOVE = "move",
|
||||||
|
HIT = "hit",
|
||||||
|
}
|
||||||
|
|
||||||
|
BattleConst.EFFECT_TYPE = {
|
||||||
|
DIRECT = 1, -- 直接伤害
|
||||||
|
DOT = 2, -- 间接伤害
|
||||||
|
HEAL = 101,
|
||||||
|
HOT = 102,
|
||||||
}
|
}
|
||||||
|
|
||||||
---- 格子类型
|
---- 格子类型
|
||||||
|
|||||||
31
lua/app/module/battle/component/battle_number_comp.lua
Normal file
31
lua/app/module/battle/component/battle_number_comp.lua
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
local BattleNumberComp = class("BattleNumberComp", LuaComponent)
|
||||||
|
|
||||||
|
function BattleNumberComp:init()
|
||||||
|
local uiMap = self.baseObject:genAllChildren()
|
||||||
|
self.animator = self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
|
||||||
|
self.effectText = uiMap["battle_number.text_number"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT)
|
||||||
|
self.time = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleNumberComp:showEffectNumber(num, x, y)
|
||||||
|
self.effectText.text = tostring(num)
|
||||||
|
self.baseObject:setLocalPosition(x, y, 0)
|
||||||
|
self.animator:Play("battle_number_move", -1, 0)
|
||||||
|
self.time = 1.367
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleNumberComp:setEnabled(enabled)
|
||||||
|
local scale = enabled and 1 or 0
|
||||||
|
self.baseObject:setLocalScale(scale, scale, scale)
|
||||||
|
self.animator.enabled = enabled
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleNumberComp:getDuration()
|
||||||
|
return self.time
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleNumberComp:tick(dt)
|
||||||
|
self.time = self.time - dt
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleNumberComp
|
||||||
10
lua/app/module/battle/component/battle_number_comp.lua.meta
Normal file
10
lua/app/module/battle/component/battle_number_comp.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 419e735a79d18ab47b041145aedc0750
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -1,10 +1,13 @@
|
|||||||
local BattleConst = require "app/module/battle/battle_const"
|
local BattleConst = require "app/module/battle/battle_const"
|
||||||
|
local BattleHelper = require "app/module/battle/helper/battle_helper"
|
||||||
|
local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle"
|
||||||
|
|
||||||
local BattleUnitComp = class("BattleUnitComp", LuaComponent)
|
local BattleUnitComp = class("BattleUnitComp", LuaComponent)
|
||||||
|
|
||||||
local UNIT_STATE = BattleConst.UNIT_STATE
|
local UNIT_STATE = BattleConst.UNIT_STATE
|
||||||
local SIDE_ATK = BattleConst.SIDE_ATK
|
local SIDE_ATK = BattleConst.SIDE_ATK
|
||||||
local SPINE_ANIMATION_NAME = BattleConst.SPINE_ANIMATION_NAME
|
local SPINE_ANIMATION_NAME = BattleConst.SPINE_ANIMATION_NAME
|
||||||
|
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
|
||||||
|
|
||||||
function BattleUnitComp:ctor()
|
function BattleUnitComp:ctor()
|
||||||
end
|
end
|
||||||
@ -58,6 +61,11 @@ function BattleUnitComp:hideOutsideScreen()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:playAnimation(name, loop, forceRefresh)
|
function BattleUnitComp:playAnimation(name, loop, forceRefresh)
|
||||||
|
if name == SPINE_ANIMATION_NAME.HIT then
|
||||||
|
self.isPlayHurt = 1
|
||||||
|
else
|
||||||
|
self.isPlayHurt = 0
|
||||||
|
end
|
||||||
self.currAnimationName = name
|
self.currAnimationName = name
|
||||||
self.baseObject:playAnimation(name, loop, forceRefresh)
|
self.baseObject:playAnimation(name, loop, forceRefresh)
|
||||||
end
|
end
|
||||||
@ -72,6 +80,7 @@ function BattleUnitComp:getAnimationDuration(aniName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:useNormalSkill(count, callback)
|
function BattleUnitComp:useNormalSkill(count, callback)
|
||||||
|
self.baseObject:getTransform():SetAsLastSibling()
|
||||||
self.actionOverCallback = callback
|
self.actionOverCallback = callback
|
||||||
self.normalSkillCount = count
|
self.normalSkillCount = count
|
||||||
if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then
|
if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then
|
||||||
@ -139,6 +148,15 @@ function BattleUnitComp:updateIdle(dt)
|
|||||||
self:updateHurt(dt)
|
self:updateHurt(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:playHurt()
|
||||||
|
self.hurtTime = 0
|
||||||
|
if self.currHitDuration == nil then
|
||||||
|
self.currHitDuration = self:getAnimationDuration(SPINE_ANIMATION_NAME.HIT)
|
||||||
|
end
|
||||||
|
self:playAnimation(SPINE_ANIMATION_NAME.HIT, false, false)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUnitComp:updateHurt(dt)
|
function BattleUnitComp:updateHurt(dt)
|
||||||
if self.isPlayHurt == 0 then
|
if self.isPlayHurt == 0 then
|
||||||
return
|
return
|
||||||
@ -149,11 +167,6 @@ function BattleUnitComp:updateHurt(dt)
|
|||||||
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
||||||
self.isPlayHurt = 0
|
self.isPlayHurt = 0
|
||||||
end
|
end
|
||||||
elseif self.isPlayHurt == 2 then
|
|
||||||
self.hurtTime = self.hurtTime + dt
|
|
||||||
if self.hurtTime >= self.currHitGroundDuration then
|
|
||||||
self.isPlayHurt = 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -161,10 +174,11 @@ function BattleUnitComp:enterNormalAttackState()
|
|||||||
self.attackOver = false
|
self.attackOver = false
|
||||||
self.attackTime = 0
|
self.attackTime = 0
|
||||||
|
|
||||||
self.currAttackKeyTime = 0.1
|
self.currAttackKeyTime = 0.3
|
||||||
local skill = self.unitEntity:getNormalSkill()
|
local skill = self.unitEntity:getNormalSkill()
|
||||||
if skill:getMoveType() == BattleConst.SKILL_MOVE_TYPE.MOVE then
|
if skill:getMoveType() == BattleConst.SKILL_MOVE_TYPE.MOVE then
|
||||||
self.isMove = true
|
self.isMove = true
|
||||||
|
self:playAnimation(BattleConst.SPINE_ANIMATION_NAME.MOVE, true, false)
|
||||||
self.positionX = self.baseObject:fastGetLocalPosition()
|
self.positionX = self.baseObject:fastGetLocalPosition()
|
||||||
if self.side == BattleConst.SIDE_ATK then
|
if self.side == BattleConst.SIDE_ATK then
|
||||||
self.targetX = BattleConst.UNIT_FRONT_POS_X
|
self.targetX = BattleConst.UNIT_FRONT_POS_X
|
||||||
@ -175,6 +189,7 @@ function BattleUnitComp:enterNormalAttackState()
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.isMove = false
|
self.isMove = false
|
||||||
|
self.attackTime = 0
|
||||||
local attackName = skill:getRandomNormalAttackName()
|
local attackName = skill:getRandomNormalAttackName()
|
||||||
self.currAttackDuration = self:getAnimationDuration(attackName)
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
self:playAnimation(attackName, false, false)
|
self:playAnimation(attackName, false, false)
|
||||||
@ -199,7 +214,11 @@ function BattleUnitComp:updateNormalAttack(dt)
|
|||||||
callback()
|
callback()
|
||||||
end
|
end
|
||||||
else -- 到位置该攻击了
|
else -- 到位置该攻击了
|
||||||
self:playAnimation(SPINE_ANIMATION_NAME.ATTACK, false, false)
|
self.attackTime = 0
|
||||||
|
local skill = self.unitEntity:getNormalSkill()
|
||||||
|
local attackName = skill:getRandomNormalAttackName()
|
||||||
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
|
self:playAnimation(attackName, false, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.baseObject:setLocalPosition(self.positionX, 0, 0)
|
self.baseObject:setLocalPosition(self.positionX, 0, 0)
|
||||||
@ -213,6 +232,7 @@ function BattleUnitComp:updateNormalAttack(dt)
|
|||||||
local skill = self.unitEntity:getNormalSkill()
|
local skill = self.unitEntity:getNormalSkill()
|
||||||
if skill:getMoveType() == BattleConst.SKILL_MOVE_TYPE.MOVE then
|
if skill:getMoveType() == BattleConst.SKILL_MOVE_TYPE.MOVE then
|
||||||
self.isMove = true
|
self.isMove = true
|
||||||
|
self:playAnimation(BattleConst.SPINE_ANIMATION_NAME.MOVE, true, false)
|
||||||
self.positionX = self.baseObject:fastGetLocalPosition()
|
self.positionX = self.baseObject:fastGetLocalPosition()
|
||||||
if self.side == BattleConst.SIDE_ATK then
|
if self.side == BattleConst.SIDE_ATK then
|
||||||
self.targetX = -BattleConst.INIT_POS_X
|
self.targetX = -BattleConst.INIT_POS_X
|
||||||
@ -232,12 +252,102 @@ function BattleUnitComp:updateNormalAttack(dt)
|
|||||||
return
|
return
|
||||||
else -- 继续攻击
|
else -- 继续攻击
|
||||||
self.attackTime = 0
|
self.attackTime = 0
|
||||||
self:playAnimation(SPINE_ANIMATION_NAME.ATTACK, false, false)
|
local skill = self.unitEntity:getNormalSkill()
|
||||||
end
|
local attackName = skill:getRandomNormalAttackName()
|
||||||
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
|
self:playAnimation(attackName, false, false)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
if self.currAttackKeyTime > 0 and self.attackTime >= self.currAttackKeyTime then -- 到达关键后使用
|
if self.currAttackKeyTime > 0 and self.attackTime >= self.currAttackKeyTime then -- 到达关键后使用
|
||||||
self.currAttackKeyTime = self.currAttackDuration
|
self.currAttackKeyTime = 0
|
||||||
|
local skill = self.unitEntity:getNormalSkill()
|
||||||
|
self:onSkillTakeEffect(skill)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:onSkillTakeEffect(skill)
|
||||||
|
local effectList = skill:getEffectList()
|
||||||
|
if effectList == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local targetType = skill:getTargetType()
|
||||||
|
local target
|
||||||
|
if targetType == 1 then -- 自己
|
||||||
|
target = self
|
||||||
|
else
|
||||||
|
target = self.battleController:getOtherSideMainUnit(self.side)
|
||||||
|
end
|
||||||
|
|
||||||
|
local succ = false
|
||||||
|
for k, effect in ipairs(effectList) do
|
||||||
|
if self:takeEffect(effect, target) then
|
||||||
|
succ = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:takeEffect(buff, target)
|
||||||
|
local ratio = buff:getRatio()
|
||||||
|
if ratio < DEFAULT_FACTOR then
|
||||||
|
if BattleHelper:random(1, DEFAULT_FACTOR) > ratio then -- 没有通过命中概率
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local round = buff:getRound()
|
||||||
|
local buffEffect
|
||||||
|
if round > 0 then
|
||||||
|
buffEffect = BattleHelper:getBuffEffect()
|
||||||
|
buffEffect.buff = buff
|
||||||
|
buffEffect.result = nil
|
||||||
|
buffEffect.round = round
|
||||||
|
buffEffect.target = target
|
||||||
|
buffEffect.sender = self
|
||||||
|
target:addBuff(buffEffect)
|
||||||
|
end
|
||||||
|
local func = BattleBuffHandle.takeBuffEffect[buff:getBuffType()]
|
||||||
|
if func then
|
||||||
|
local result = func(self, buff, target)
|
||||||
|
if buffEffect then
|
||||||
|
buffEffect.result = result
|
||||||
|
end
|
||||||
|
local success = result ~= nil
|
||||||
|
if success then
|
||||||
|
local fxId = buff:getBuffHitFxId()
|
||||||
|
if fxId then
|
||||||
|
target:playHurtFx(fxId)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return success
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectStatus)
|
||||||
|
if num == 0 then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
self.unitEntity:takeDamageOrCure(num)
|
||||||
|
if self.currState == UNIT_STATE.INIT or
|
||||||
|
self.currState == UNIT_STATE.IDLE then
|
||||||
|
self:playHurt()
|
||||||
|
end
|
||||||
|
local x, y, z = self.baseObject:fastGetLocalPosition()
|
||||||
|
self:showEffectNumber(num, x, y)
|
||||||
|
local hpPercent = self.unitEntity:getHpPercent()
|
||||||
|
-- self.controlUnitComp:RefreshHpBar(hpPercent)
|
||||||
|
|
||||||
|
-- local shieldHp = self.unitEntity:getShieldHp()
|
||||||
|
-- if shieldHp and shieldHp.value > 0 then
|
||||||
|
-- local percent = self.unitEntity:getShieldHpPercent()
|
||||||
|
-- self.controlUnitComp:RefreshShieldBar(percent, true)
|
||||||
|
-- else
|
||||||
|
-- self.controlUnitComp:RefreshShieldBar(0, false)
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:showEffectNumber(num, x, y)
|
||||||
|
self.battleController:showEffectNumber(num, x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:tick(dt)
|
function BattleUnitComp:tick(dt)
|
||||||
|
|||||||
@ -118,6 +118,7 @@ function BattleController:init(params)
|
|||||||
self.atkUnits = {}
|
self.atkUnits = {}
|
||||||
self.defUnits = {}
|
self.defUnits = {}
|
||||||
self.allUnits = {}
|
self.allUnits = {}
|
||||||
|
self.effectTexts = {}
|
||||||
self.instructions = {}
|
self.instructions = {}
|
||||||
self.time = 0
|
self.time = 0
|
||||||
self.battleData:init()
|
self.battleData:init()
|
||||||
@ -140,6 +141,7 @@ function BattleController:prepareFight()
|
|||||||
self.battleUI = UIManager:showUI(self:getBattleUIPath())
|
self.battleUI = UIManager:showUI(self:getBattleUIPath())
|
||||||
self.battleUI:setController(self)
|
self.battleUI:setController(self)
|
||||||
self.battleUI:addLoadUICompleteListener(function()
|
self.battleUI:addLoadUICompleteListener(function()
|
||||||
|
BattleHelper:setEffectTextCache(self.battleUI:getBattleNumber())
|
||||||
self:initAtkUnits(onPreloadFinished)
|
self:initAtkUnits(onPreloadFinished)
|
||||||
self:initDefUnits(onPreloadFinished)
|
self:initDefUnits(onPreloadFinished)
|
||||||
self:generateBoard()
|
self:generateBoard()
|
||||||
@ -176,6 +178,14 @@ function BattleController:initAtkUnits(callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleController:getOtherSideMainUnit(side)
|
||||||
|
if side == BattleConst.SIDE_ATK then
|
||||||
|
return self.defMainUnit
|
||||||
|
else
|
||||||
|
return self.atkMainUnit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function BattleController:onLoadComplete()
|
function BattleController:onLoadComplete()
|
||||||
self:battleStart()
|
self:battleStart()
|
||||||
end
|
end
|
||||||
@ -966,6 +976,14 @@ function BattleController:_tick(dt)
|
|||||||
self.time = self.time + dt
|
self.time = self.time + dt
|
||||||
for k, v in ipairs(self.allUnits) do
|
for k, v in ipairs(self.allUnits) do
|
||||||
v:tick(dt)
|
v:tick(dt)
|
||||||
|
end
|
||||||
|
local count = #self.effectTexts
|
||||||
|
for i = count, 1, -1 do
|
||||||
|
self.effectTexts[i]:tick(dt)
|
||||||
|
if self.effectTexts[i]:getDuration() < 0 then
|
||||||
|
BattleHelper:recycleEffectText(self.effectTexts[i])
|
||||||
|
table.remove(self.effectTexts, i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self:tick(dt)
|
self:tick(dt)
|
||||||
end
|
end
|
||||||
@ -987,6 +1005,12 @@ function BattleController:endBattleAndExit()
|
|||||||
ModuleManager.BattleManager:exitBattle()
|
ModuleManager.BattleManager:exitBattle()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleController:showEffectNumber(num, x, y)
|
||||||
|
local effectTextComp = BattleHelper:getEffectText(self.battleUI:getNumberNode())
|
||||||
|
effectTextComp:showEffectNumber(num, x, y)
|
||||||
|
table.insert(self.effectTexts, effectTextComp)
|
||||||
|
end
|
||||||
|
|
||||||
local function _addCurRoundAttr(self, instruction, callback)
|
local function _addCurRoundAttr(self, instruction, callback)
|
||||||
callback()
|
callback()
|
||||||
end
|
end
|
||||||
@ -1000,7 +1024,7 @@ local function _generalAttack(self, instruction, callback)
|
|||||||
if hero == nil then
|
if hero == nil then
|
||||||
return callback()
|
return callback()
|
||||||
end
|
end
|
||||||
self.mainHero = hero
|
self.atkMainUnit = hero
|
||||||
hero:useNormalSkill(instruction.count, callback)
|
hero:useNormalSkill(instruction.count, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ function BattleControllerStage:initDefUnits(callback)
|
|||||||
monsterComp:initWithEntity(modelId, unitEntity, self)
|
monsterComp:initWithEntity(modelId, unitEntity, self)
|
||||||
self.defUnits[unitEntity:getMatchType()] = monsterComp
|
self.defUnits[unitEntity:getMatchType()] = monsterComp
|
||||||
table.insert(self.allUnits, monsterComp)
|
table.insert(self.allUnits, monsterComp)
|
||||||
|
self.defMainUnit = monsterComp
|
||||||
callback()
|
callback()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
132
lua/app/module/battle/helper/battle_buff_handle.lua
Normal file
132
lua/app/module/battle/helper/battle_buff_handle.lua
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
local BattleFormula = require "app/module/battle/helper/battle_formula"
|
||||||
|
local BattleConst = require "app/module/battle/battle_const"
|
||||||
|
local BattleHelper = require "app/module/battle/helper/battle_helper"
|
||||||
|
local BattleBuffSpecial = require "app/module/battle/helper/battle_buff_special"
|
||||||
|
|
||||||
|
local BattleBuffHandle = {}
|
||||||
|
|
||||||
|
local EFFECT_TYPE = BattleConst.EFFECT_TYPE
|
||||||
|
local BUFF_NAME = BattleConst.BUFF_NAME
|
||||||
|
local ATTR_NAME = BattleConst.ATTR_NAME
|
||||||
|
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
|
||||||
|
|
||||||
|
local function _doDotWork(unitComp, buffEffect, buff)
|
||||||
|
local damage, hurtStatus = BattleFormula:getDamageOrCureResult(buffEffect.sender, buff, unitComp)
|
||||||
|
if damage <= 0 then
|
||||||
|
damage = -1
|
||||||
|
else
|
||||||
|
damage = -damage
|
||||||
|
end
|
||||||
|
unitComp:takeDamageOrCure(buffEffect.sender, buff, damage, EFFECT_TYPE.DOT, hurtStatus)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _doHotWork(unitComp, buffEffect, buff)
|
||||||
|
local cure, hurtStatus = BattleFormula:getDamageOrCureResult(buffEffect.sender, buff, unitComp)
|
||||||
|
if cure < 0 then -- 加血不能是负数
|
||||||
|
cure = 0
|
||||||
|
end
|
||||||
|
unitComp:takeDamageOrCure(buffEffect.sender, buff, cure, EFFECT_TYPE.HOT, hurtStatus)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffHandle.doBuffWork(unitComp, buffEffect)
|
||||||
|
local buff = buffEffect.buff
|
||||||
|
local buffType = buff:getBuffType()
|
||||||
|
if buffType == 2 then
|
||||||
|
_doDotWork(unitComp, buffEffect, buff)
|
||||||
|
elseif buffType == 4 then
|
||||||
|
_doHotWork(unitComp, buffEffect, buff)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffHandle.removeBuff(unitComp, buffEffect)
|
||||||
|
local buff = buffEffect.buff
|
||||||
|
local buffType = buff:getBuffType()
|
||||||
|
local func = BattleBuffHandle.removeEffect[buffType]
|
||||||
|
if func then
|
||||||
|
func(buffEffect.sender, unitComp, buff, buffEffect)
|
||||||
|
end
|
||||||
|
BattleHelper:recycleBuffEffect(buffEffect)
|
||||||
|
end
|
||||||
|
|
||||||
|
BattleBuffHandle.addAttribute = {
|
||||||
|
}
|
||||||
|
|
||||||
|
local function _takeEffectDirectHurt(unitComp, buff, target)
|
||||||
|
local damage, hurtStatus = BattleFormula:getDamageOrCureResult(unitComp, buff, target)
|
||||||
|
if damage <= 0 then
|
||||||
|
damage = -1
|
||||||
|
else
|
||||||
|
damage = -damage
|
||||||
|
end
|
||||||
|
target:takeDamageOrCure(unitComp, buff, damage, EFFECT_TYPE.DIRECT, hurtStatus)
|
||||||
|
return damage
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _takeEffectDot(unitComp, buff, target)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _takeEffectDirectCure(unitComp, buff, target)
|
||||||
|
local cure, hurtStatus = BattleFormula:getDamageOrCureResult(unitComp, buff, target)
|
||||||
|
if cure < 0 then -- 加血不能是负数
|
||||||
|
cure = 0
|
||||||
|
end
|
||||||
|
target:takeDamageOrCure(unitComp, buff, cure, EFFECT_TYPE.HEAL, hurtStatus)
|
||||||
|
return cure
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _takeEffectHot(unitComp, buff, target)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _takeEffectAttr(unitComp, buff, target)
|
||||||
|
local buffName = buff:getName()
|
||||||
|
local func = BattleBuffHandle.addAttribute[buffName]
|
||||||
|
if func then
|
||||||
|
func(target, buff:getEffectNum())
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _takeEffectControl(unitComp, buff, target)
|
||||||
|
target:addLimit(buff:getName())
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _takeEffectShield(unitComp, buff, target)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- buff添加时的效果
|
||||||
|
BattleBuffHandle.takeBuffEffect = {
|
||||||
|
[1] = _takeEffectAttr,
|
||||||
|
[2] = _takeEffectShield,
|
||||||
|
[3] = _takeEffectDirectHurt,
|
||||||
|
[4] = _takeEffectDot,
|
||||||
|
[5] = _takeEffectDirectCure,
|
||||||
|
[6] = _takeEffectHot,
|
||||||
|
[7] = BattleBuffSpecial.specialBuffOn,
|
||||||
|
[8] = _takeEffectControl,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- 还原改变的属性
|
||||||
|
local function _removeEffectAttr(buffSender, target, buff, buffEffect)
|
||||||
|
local func = BattleBuffHandle.addAttribute[buff:getName()]
|
||||||
|
if func then
|
||||||
|
func(target, -buff:getEffectNum())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _removeEffectControl(buffSender, target, buff, buffEffect)
|
||||||
|
target:removeLimit(buff:getName())
|
||||||
|
end
|
||||||
|
|
||||||
|
-- buff移除时的效果
|
||||||
|
BattleBuffHandle.removeEffect = {
|
||||||
|
[1] = _removeEffectAttr,
|
||||||
|
[7] = BattleBuffSpecial.specialBuffOff,
|
||||||
|
[8] = _removeEffectControl,
|
||||||
|
}
|
||||||
|
|
||||||
|
return BattleBuffHandle
|
||||||
10
lua/app/module/battle/helper/battle_buff_handle.lua.meta
Normal file
10
lua/app/module/battle/helper/battle_buff_handle.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7bead912fae9b39479a56308687d9c2b
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
31
lua/app/module/battle/helper/battle_buff_special.lua
Normal file
31
lua/app/module/battle/helper/battle_buff_special.lua
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
local BattleConst = require "app/module/battle/battle_const"
|
||||||
|
|
||||||
|
local BattleBuffSpecial = {}
|
||||||
|
|
||||||
|
local BUFF_NAME = BattleConst.BUFF_NAME
|
||||||
|
local ATTR_NAME = BattleConst.ATTR_NAME
|
||||||
|
|
||||||
|
local _handleOn = {
|
||||||
|
}
|
||||||
|
|
||||||
|
local _handleOff = {
|
||||||
|
}
|
||||||
|
|
||||||
|
-- 特殊buff添加时
|
||||||
|
function BattleBuffSpecial.specialBuffOn(unitComp, buff, target)
|
||||||
|
local func = _handleOn[buff:getName()]
|
||||||
|
if func then
|
||||||
|
return func(unitComp, buff, target)
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 特殊buff移除时
|
||||||
|
function BattleBuffSpecial.specialBuffOff(buffSender, target, buff, buffEffect)
|
||||||
|
local func = _handleOff[buff:getName()]
|
||||||
|
if func then
|
||||||
|
func(buffSender, target, buff, buffEffect)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleBuffSpecial
|
||||||
10
lua/app/module/battle/helper/battle_buff_special.lua.meta
Normal file
10
lua/app/module/battle/helper/battle_buff_special.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2c6fff8feb1cb11498667bea74db745e
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
37
lua/app/module/battle/helper/battle_formula.lua
Normal file
37
lua/app/module/battle/helper/battle_formula.lua
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
local BattleHelper = require "app/module/battle/helper/battle_helper"
|
||||||
|
local BattleConst = require "app/module/battle/battle_const"
|
||||||
|
|
||||||
|
local BattleFormula = {}
|
||||||
|
|
||||||
|
local DEFAULT_FACTOR = 10000
|
||||||
|
local HURT_STATE_CRIT = BattleConst.HURT_STATE_CRIT
|
||||||
|
|
||||||
|
function BattleFormula:getDamageOrCureResult(unitComp, buff, targetUnitComp)
|
||||||
|
local func = self.calculateFormula[buff:getFormula()]
|
||||||
|
if func then
|
||||||
|
return func(unitComp, buff, targetUnitComp)
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
BattleFormula.calculateFormula = {
|
||||||
|
-- 攻击力乘以系数
|
||||||
|
[1] = function(unitComp, buff, targetUnit)
|
||||||
|
local result = unitComp.unitEntity:getAtk() * buff:getEffectNum() // DEFAULT_FACTOR
|
||||||
|
local hurtState = 0
|
||||||
|
local crit = unitComp.unitEntity:getCrit()
|
||||||
|
if crit > 0 then
|
||||||
|
if BattleHelper:random(1, DEFAULT_FACTOR) <= crit then -- 暴击了
|
||||||
|
hurtState = HURT_STATE_CRIT
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result, hurtState
|
||||||
|
end,
|
||||||
|
-- 目标生命上限的百分比伤害
|
||||||
|
[2] = function(unitComp, buff, targetUnit)
|
||||||
|
local result = targetUnit.unitEntity:getMaxHp() * buff:getEffectNum() // DEFAULT_FACTOR
|
||||||
|
return result, 0
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
return BattleFormula
|
||||||
10
lua/app/module/battle/helper/battle_formula.lua.meta
Normal file
10
lua/app/module/battle/helper/battle_formula.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e6cfe3afd43ded741974e09808146a1f
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -1,9 +1,20 @@
|
|||||||
|
local UIPrefabObject = require "app/bf/unity/uiprefab_object"
|
||||||
|
|
||||||
local BattleHelper = {}
|
local BattleHelper = {}
|
||||||
|
|
||||||
function BattleHelper:init()
|
function BattleHelper:init()
|
||||||
self.isClear = false
|
self.isClear = false
|
||||||
self.characterPools = {}
|
self.characterPools = {}
|
||||||
self.characterMap = {}
|
self.characterMap = {}
|
||||||
|
self.buffEffectPool = {}
|
||||||
|
self.battleEffectTextMap = {}
|
||||||
|
self.battleEffectTextPool = {}
|
||||||
|
self.seed = tonumber(tostring(os.time()):reverse():sub(1,6))
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleHelper:random(min, max)
|
||||||
|
self.seed = (self.seed*9301 + 49297)%233280
|
||||||
|
return min + self.seed*(max - min + 1)//233280
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleHelper:loadBattleHeroModel(id, parent, callback)
|
function BattleHelper:loadBattleHeroModel(id, parent, callback)
|
||||||
@ -43,10 +54,61 @@ function BattleHelper:recycleBattleHeroModel(modelId, character)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleHelper:setEffectTextCache(effectTextCache)
|
||||||
|
self.effectTextCache = effectTextCache
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleHelper:getEffectText(parent)
|
||||||
|
if #self.battleEffectTextPool <= 0 then
|
||||||
|
local prefab = CS.UnityEngine.Object.Instantiate(self.effectTextCache:getGameObject(), parent:getTransform(), false)
|
||||||
|
local prefabObject = UIPrefabObject:create()
|
||||||
|
prefabObject:initWithPrefab(self.effectTextCache:getAssetPath(), prefab)
|
||||||
|
prefabObject:initPrefabHelper()
|
||||||
|
prefabObject:addUnloadCallback(function(obj)
|
||||||
|
ResourceManager:unload(obj:getAssetPath())
|
||||||
|
end)
|
||||||
|
local comp = prefabObject:addLuaComponent(GConst.BattleConst.TYPEOF_LUA_COMP.BATTLE_NUMBER_COMPONENT)
|
||||||
|
return comp
|
||||||
|
else
|
||||||
|
local effectComp = table.remove(self.battleEffectTextPool)
|
||||||
|
effectComp:setEnabled(true)
|
||||||
|
effectComp.baseObject:getTransform():SetAsLastSibling()
|
||||||
|
self.battleEffectTextMap[effectComp.baseObject:getInstanceID()] = effectComp
|
||||||
|
return effectComp
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleHelper:recycleEffectText(comp)
|
||||||
|
if comp:isDestroyed() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
comp:setEnabled(false)
|
||||||
|
table.insert(self.battleEffectTextPool, comp)
|
||||||
|
if self.battleEffectTextMap then
|
||||||
|
self.battleEffectTextMap[comp.baseObject:getInstanceID()] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleHelper:getBuffEffect()
|
||||||
|
if #self.buffEffectPool > 0 then
|
||||||
|
return table.remove(self.buffEffectPool)
|
||||||
|
end
|
||||||
|
local sid = self.buffSid + 1
|
||||||
|
return {sid = sid}
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleHelper:recycleBuffEffect(buffEffect)
|
||||||
|
table.insert(self.buffEffectPool, buffEffect)
|
||||||
|
end
|
||||||
|
|
||||||
function BattleHelper:clear()
|
function BattleHelper:clear()
|
||||||
self.isClear = true
|
self.isClear = true
|
||||||
self.characterPools = nil
|
self.characterPools = nil
|
||||||
self.characterMap = nil
|
self.characterMap = nil
|
||||||
|
self.effectTextCache = nil
|
||||||
|
self.buffEffectPool = nil
|
||||||
|
self.battleEffectTextMap = nil
|
||||||
|
self.battleEffectTextPool = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return BattleHelper
|
return BattleHelper
|
||||||
@ -26,6 +26,7 @@ end
|
|||||||
|
|
||||||
function BattleUI:_display()
|
function BattleUI:_display()
|
||||||
local uiMap = self.root:genAllChildren()
|
local uiMap = self.root:genAllChildren()
|
||||||
|
self.uiMap = uiMap
|
||||||
self.boardMask2D = uiMap["battle_ui.bg_2.board_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
|
self.boardMask2D = uiMap["battle_ui.bg_2.board_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
|
||||||
self.boardMask = uiMap["battle_ui.bg_2.board_mask"]
|
self.boardMask = uiMap["battle_ui.bg_2.board_mask"]
|
||||||
self.boardMask:setVisible(false)
|
self.boardMask:setVisible(false)
|
||||||
@ -34,6 +35,7 @@ function BattleUI:_display()
|
|||||||
self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"]
|
self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"]
|
||||||
self:initSkill()
|
self:initSkill()
|
||||||
self:initBattlefield()
|
self:initBattlefield()
|
||||||
|
self:initNumberNode()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUI:_addListeners()
|
function BattleUI:_addListeners()
|
||||||
@ -75,14 +77,26 @@ function BattleUI:initSkill()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleUI:initBattlefield()
|
function BattleUI:initBattlefield()
|
||||||
local uiMap = self.root:genAllChildren()
|
self.battleNode = self.uiMap["battle_ui.battle_node"]
|
||||||
self.battleNode = uiMap["battle_ui.battle_node"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUI:getBattleNode()
|
function BattleUI:getBattleNode()
|
||||||
return self.battleNode
|
return self.battleNode
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUI:initNumberNode()
|
||||||
|
self.battleNumberNode = self.uiMap["battle_ui.battle_number_node"]
|
||||||
|
self.battleNumber = self.uiMap["battle_ui.battle_number_node.battle_number"]
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:getNumberNode()
|
||||||
|
return self.battleNumberNode
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:getBattleNumber()
|
||||||
|
return self.battleNumber
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUI:refreshSkill(elementMap)
|
function BattleUI:refreshSkill(elementMap)
|
||||||
if not self.skillObjs then
|
if not self.skillObjs then
|
||||||
return
|
return
|
||||||
|
|||||||
@ -310,6 +310,7 @@ function BattleData:initHeroData()
|
|||||||
atk = heroAttr[ATTR_TYPE.atk] // DEFAULT_FACTOR,
|
atk = heroAttr[ATTR_TYPE.atk] // DEFAULT_FACTOR,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Logger.printTable(unitData)
|
||||||
table.insert(units, unitData)
|
table.insert(units, unitData)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
45
lua/app/userdata/battle/skill/battle_buff_entity.lua
Normal file
45
lua/app/userdata/battle/skill/battle_buff_entity.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
local BattleBuffEntity = class("BattleBuffEntity", BaseData)
|
||||||
|
|
||||||
|
function BattleBuffEntity:ctor()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:init(effectParams, owner, hostSkill)
|
||||||
|
self.name = effectParams.type
|
||||||
|
self.effectNum = effectParams.num
|
||||||
|
self.round = effectParams.round
|
||||||
|
self.ratio = effectParams.ratio
|
||||||
|
self.owner = owner
|
||||||
|
self.hostSkill = hostSkill
|
||||||
|
self.buffInfo = ConfigManager:getConfigWithOtherKey("buff", "name")[self.name]
|
||||||
|
self.buffType = self.buffInfo.buff_type
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getName()
|
||||||
|
return self.name
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getBuffType()
|
||||||
|
return self.buffType
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getEffectNum()
|
||||||
|
return self.effectNum
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getFormula()
|
||||||
|
return self.buffInfo.formula
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getRatio()
|
||||||
|
return self.ratio
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getRound()
|
||||||
|
return self.round
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleBuffEntity:getBuffHitFxId()
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleBuffEntity
|
||||||
10
lua/app/userdata/battle/skill/battle_buff_entity.lua.meta
Normal file
10
lua/app/userdata/battle/skill/battle_buff_entity.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3943d0171a7da3b4dae21aaa1e683656
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
|
||||||
|
|
||||||
local BattleSkillEntity = class("BattleSkillEntity", BaseData)
|
local BattleSkillEntity = class("BattleSkillEntity", BaseData)
|
||||||
|
|
||||||
function BattleSkillEntity:ctor(skillId, skillType, owner)
|
function BattleSkillEntity:ctor(skillId, skillType, owner)
|
||||||
@ -9,6 +11,18 @@ end
|
|||||||
|
|
||||||
function BattleSkillEntity:init()
|
function BattleSkillEntity:init()
|
||||||
self.skillInfo = ConfigManager:getConfig("skill")[self.skillId]
|
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, self)
|
||||||
|
table.insert(self.effectList, buffEntity)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleSkillEntity:getMoveType()
|
function BattleSkillEntity:getMoveType()
|
||||||
@ -17,7 +31,7 @@ end
|
|||||||
|
|
||||||
function BattleSkillEntity:getRandomNormalAttackName()
|
function BattleSkillEntity:getRandomNormalAttackName()
|
||||||
if self.normalSkillNameList == nil then
|
if self.normalSkillNameList == nil then
|
||||||
self.normalSkillNameList = {"attack01", "attack02", "attack03"}
|
self.normalSkillNameList = {"atk1", "atk2", "atk3"}
|
||||||
end
|
end
|
||||||
if self.normalSkillNameIndex == nil then
|
if self.normalSkillNameIndex == nil then
|
||||||
self.normalSkillNameIndex = math.random(1, #self.normalSkillNameList)
|
self.normalSkillNameIndex = math.random(1, #self.normalSkillNameList)
|
||||||
@ -30,4 +44,12 @@ function BattleSkillEntity:getRandomNormalAttackName()
|
|||||||
return self.normalSkillNameList[self.normalSkillNameIndex]
|
return self.normalSkillNameList[self.normalSkillNameIndex]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleSkillEntity:getEffectList()
|
||||||
|
return self.effectList
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleSkillEntity:getTargetType()
|
||||||
|
return self.skillInfo.obj
|
||||||
|
end
|
||||||
|
|
||||||
return BattleSkillEntity
|
return BattleSkillEntity
|
||||||
@ -9,6 +9,10 @@ end
|
|||||||
|
|
||||||
function BattleTeamEntity:init(side, data)
|
function BattleTeamEntity:init(side, data)
|
||||||
self.side = side
|
self.side = side
|
||||||
|
self.shieldHp = 0
|
||||||
|
self.hp = 0
|
||||||
|
self.maxHp = 0
|
||||||
|
self.isDead = false
|
||||||
if data then
|
if data then
|
||||||
table.sort(data.units, function(a, b)
|
table.sort(data.units, function(a, b)
|
||||||
if a.level == b.level then
|
if a.level == b.level then
|
||||||
@ -55,4 +59,52 @@ function BattleTeamEntity:getMembersCount()
|
|||||||
return self.membersCount
|
return self.membersCount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleTeamEntity:getHpPercent()
|
||||||
|
return self.hp / self.maxHp
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleTeamEntity:takeDamageOrCure(num)
|
||||||
|
if num < 0 then -- 是伤害的话处理一下护盾
|
||||||
|
num = self:handleShield(num)
|
||||||
|
if num >= 0 then -- 这次伤害被抵消了
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local hpBefore = self.hp
|
||||||
|
self.hp = self.hp + num
|
||||||
|
local hurtEventNum = 0
|
||||||
|
if self.hp <= 0 then -- 死了
|
||||||
|
hurtEventNum = -hpBefore
|
||||||
|
self:die()
|
||||||
|
elseif self.hp < self.maxHp then
|
||||||
|
hurtEventNum = num
|
||||||
|
else -- 满血了
|
||||||
|
-- 这是加血
|
||||||
|
hurtEventNum = 0
|
||||||
|
self.hp = self.maxHp
|
||||||
|
end
|
||||||
|
return hurtEventNum
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleTeamEntity:handleShield(damageNum)
|
||||||
|
if self.shieldHp == nil then
|
||||||
|
return damageNum
|
||||||
|
end
|
||||||
|
self.shieldHp = self.shieldHp + damageNum
|
||||||
|
if self.shieldHp >= 0 then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
damageNum = self.shieldHp
|
||||||
|
self.shieldHp = 0
|
||||||
|
return damageNum
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleTeamEntity:die()
|
||||||
|
if self.isDead then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.isDead = true
|
||||||
|
end
|
||||||
|
|
||||||
return BattleTeamEntity
|
return BattleTeamEntity
|
||||||
@ -64,4 +64,12 @@ function BattleUnitEntity:getNormalSkill()
|
|||||||
return self.normalSkill
|
return self.normalSkill
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUnitEntity:takeDamageOrCure(num)
|
||||||
|
return self.team:takeDamageOrCure(num)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUnitEntity:getHpPercent()
|
||||||
|
return self.team:getHpPercent()
|
||||||
|
end
|
||||||
|
|
||||||
return BattleUnitEntity
|
return BattleUnitEntity
|
||||||
@ -64,6 +64,7 @@ end
|
|||||||
|
|
||||||
function HeroEntity:updateAttr()
|
function HeroEntity:updateAttr()
|
||||||
self:updateBaseAttr()
|
self:updateBaseAttr()
|
||||||
|
self:updateAllAttr()
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:updateBaseAttr()
|
function HeroEntity:updateBaseAttr()
|
||||||
@ -95,6 +96,12 @@ function HeroEntity:getCfgAtk(lv)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroEntity:updateAllAttr()
|
||||||
|
for k, v in pairs(self.baseAttrOriginal) do
|
||||||
|
self.allAttr[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function HeroEntity:getAtk()
|
function HeroEntity:getAtk()
|
||||||
return self.allAttr[GConst.ATTR_TYPE.atk] or 0
|
return self.allAttr[GConst.ATTR_TYPE.atk] or 0
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user