伤害数字
This commit is contained in:
parent
b8517ba934
commit
5303638b99
@ -25,6 +25,18 @@ BattleConst.UNIT_FRONT_DISTANCE = 50
|
|||||||
BattleConst.MOVE_SPEED = 2000 -- 战斗单位攻击时的移动速度
|
BattleConst.MOVE_SPEED = 2000 -- 战斗单位攻击时的移动速度
|
||||||
BattleConst.MOVE_SPEED_ENTER = 500 -- 战斗单位入场时的移动速度
|
BattleConst.MOVE_SPEED_ENTER = 500 -- 战斗单位入场时的移动速度
|
||||||
BattleConst.HURT_STATE_CRIT = 1 -- 暴击
|
BattleConst.HURT_STATE_CRIT = 1 -- 暴击
|
||||||
|
BattleConst.EFFECT_COLOR_WHITE = 1
|
||||||
|
BattleConst.EFFECT_COLOR_RED = 2
|
||||||
|
BattleConst.EFFECT_COLOR_YELLOW = 3
|
||||||
|
BattleConst.EFFECT_COLOR_GREEN = 4
|
||||||
|
BattleConst.EFFECT_TYPE_MOVE_L = 1
|
||||||
|
BattleConst.EFFECT_TYPE_MOVE_R = 2
|
||||||
|
BattleConst.EFFECT_TYPE_CRIT = 3
|
||||||
|
BattleConst.EFFECT_TYPE_BUFF = 4
|
||||||
|
BattleConst.ANIMATOR_HASH_NAME_NUMBER_MOVE_L = -526518883
|
||||||
|
BattleConst.ANIMATOR_HASH_NAME_NUMBER_MOVE_R = 445827326
|
||||||
|
BattleConst.ANIMATOR_HASH_NAME_NUMBER_CRIT = -1734531349
|
||||||
|
BattleConst.ANIMATOR_HASH_NAME_NUMBER_BUFF = 1364146828
|
||||||
|
|
||||||
BattleConst.BATTLE_ROUND_STEP = {
|
BattleConst.BATTLE_ROUND_STEP = {
|
||||||
WAIT_BEGIN = 0, -- 等待开始
|
WAIT_BEGIN = 0, -- 等待开始
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
local BattleConst = require "app/module/battle/battle_const"
|
||||||
local BattleNumberComp = class("BattleNumberComp", LuaComponent)
|
local BattleNumberComp = class("BattleNumberComp", LuaComponent)
|
||||||
|
|
||||||
function BattleNumberComp:init()
|
function BattleNumberComp:init()
|
||||||
@ -7,10 +8,19 @@ function BattleNumberComp:init()
|
|||||||
self.time = 0
|
self.time = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleNumberComp:showEffectNumber(num, x, y)
|
function BattleNumberComp:showEffectNumber(effectType, num, x, y)
|
||||||
self.effectText.text = tostring(num)
|
self.effectText.text = tostring(num)
|
||||||
self.baseObject:setLocalPosition(x, y, 0)
|
self.baseObject:setLocalPosition(x, y, 0)
|
||||||
self.animator:Play("battle_number_move", -1, 0)
|
|
||||||
|
if effectType == BattleConst.EFFECT_TYPE_MOVE_L then
|
||||||
|
self.animator:Play(BattleConst.ANIMATOR_HASH_NAME_NUMBER_MOVE_L, -1, 0)
|
||||||
|
elseif effectType == BattleConst.EFFECT_TYPE_MOVE_R then
|
||||||
|
self.animator:Play(BattleConst.ANIMATOR_HASH_NAME_NUMBER_MOVE_R, -1, 0)
|
||||||
|
elseif effectType == BattleConst.EFFECT_TYPE_CRIT then
|
||||||
|
self.animator:Play(BattleConst.ANIMATOR_HASH_NAME_NUMBER_CRIT, -1, 0)
|
||||||
|
else
|
||||||
|
self.animator:Play(BattleConst.ANIMATOR_HASH_NAME_NUMBER_BUFF, -1, 0)
|
||||||
|
end
|
||||||
self.time = 1.367
|
self.time = 1.367
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -20,6 +30,14 @@ function BattleNumberComp:setEnabled(enabled)
|
|||||||
self.animator.enabled = enabled
|
self.animator.enabled = enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleNumberComp:setColorType(colorType)
|
||||||
|
self.colorType = colorType
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleNumberComp:getColorType()
|
||||||
|
return self.colorType
|
||||||
|
end
|
||||||
|
|
||||||
function BattleNumberComp:getDuration()
|
function BattleNumberComp:getDuration()
|
||||||
return self.time
|
return self.time
|
||||||
end
|
end
|
||||||
|
|||||||
@ -10,6 +10,8 @@ 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
|
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
|
||||||
local PASSIVE_EVENT = BattleConst.PASSIVE_EVENT
|
local PASSIVE_EVENT = BattleConst.PASSIVE_EVENT
|
||||||
|
local HURT_STATE_CRIT = BattleConst.HURT_STATE_CRIT
|
||||||
|
local EFFECT_TYPE = BattleConst.EFFECT_TYPE
|
||||||
|
|
||||||
function BattleUnitComp:ctor()
|
function BattleUnitComp:ctor()
|
||||||
end
|
end
|
||||||
@ -1022,8 +1024,29 @@ function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectSta
|
|||||||
if shieldHpDiff < 0 then -- 说明护盾减少了
|
if shieldHpDiff < 0 then -- 说明护盾减少了
|
||||||
self:handleShield(shieldHpDiff, self)
|
self:handleShield(shieldHpDiff, self)
|
||||||
end
|
end
|
||||||
local x, y, z = self.baseObject:fastGetLocalPosition()
|
local x, y = self.baseObject:fastGetLocalPosition()
|
||||||
self:showEffectNumber(num, x, y)
|
if effectStatus == HURT_STATE_CRIT then
|
||||||
|
self:showEffectNumber(BattleConst.EFFECT_COLOR_YELLOW, BattleConst.EFFECT_TYPE_CRIT, num, x, y)
|
||||||
|
else
|
||||||
|
if num < 0 then -- 伤害
|
||||||
|
if effectType == EFFECT_TYPE.DOT then
|
||||||
|
if self.side == BattleConst.SIDE_ATK then
|
||||||
|
self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_MOVE_L, num, x, y)
|
||||||
|
else
|
||||||
|
self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_MOVE_R, num, x, y)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if self.side == BattleConst.SIDE_ATK then
|
||||||
|
self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_MOVE_L, num, x, y)
|
||||||
|
else
|
||||||
|
self:showEffectNumber(BattleConst.EFFECT_COLOR_WHITE, BattleConst.EFFECT_TYPE_MOVE_R, num, x, y)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif num > 0 then -- 治疗
|
||||||
|
self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local hp = self.unitEntity:getHp()
|
local hp = self.unitEntity:getHp()
|
||||||
local hpPercent = self.unitEntity:getHpPercent()
|
local hpPercent = self.unitEntity:getHpPercent()
|
||||||
self.battleController:refreshHp(self.side, hp, hpPercent)
|
self.battleController:refreshHp(self.side, hp, hpPercent)
|
||||||
@ -1043,8 +1066,8 @@ function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectSta
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:showEffectNumber(num, x, y)
|
function BattleUnitComp:showEffectNumber(colorType, effectType, num, x, y)
|
||||||
self.battleController:showEffectNumber(num, x, y)
|
self.battleController:showEffectNumber(colorType, effectType, num, x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:playDead(callback)
|
function BattleUnitComp:playDead(callback)
|
||||||
|
|||||||
@ -242,7 +242,10 @@ 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())
|
BattleHelper:setEffectTextCache(self.battleUI:getBattleNumber(),
|
||||||
|
self.battleUI:getBattleNumberRed(),
|
||||||
|
self.battleUI:getBattleNumberYellow(),
|
||||||
|
self.battleUI:getBattleNumberGreen())
|
||||||
self:initAtkUnits(onPreloadFinished)
|
self:initAtkUnits(onPreloadFinished)
|
||||||
self:initDefUnits(onPreloadFinished)
|
self:initDefUnits(onPreloadFinished)
|
||||||
end)
|
end)
|
||||||
@ -1578,9 +1581,9 @@ function BattleController:endBattleAndExit()
|
|||||||
ModuleManager.BattleManager:exitBattle()
|
ModuleManager.BattleManager:exitBattle()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:showEffectNumber(num, x, y)
|
function BattleController:showEffectNumber(colorType, effectType, num, x, y)
|
||||||
local effectTextComp = BattleHelper:getEffectText(self.battleUI:getNumberNode())
|
local effectTextComp = BattleHelper:getEffectText(self.battleUI:getNumberNode(), colorType)
|
||||||
effectTextComp:showEffectNumber(num, x, y)
|
effectTextComp:showEffectNumber(effectType, num, x, y)
|
||||||
table.insert(self.effectTexts, effectTextComp)
|
table.insert(self.effectTexts, effectTextComp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -79,23 +79,31 @@ function BattleHelper:recycleBattleHeroModel(modelId, character)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleHelper:setEffectTextCache(effectTextCache)
|
function BattleHelper:setEffectTextCache(cache1, cache2, cache3, cache4)
|
||||||
self.effectTextCache = effectTextCache
|
if self.effectTextCacheList == nil then
|
||||||
|
self.effectTextCacheList = {}
|
||||||
|
end
|
||||||
|
self.effectTextCacheList[1] = cache1
|
||||||
|
self.effectTextCacheList[2] = cache2
|
||||||
|
self.effectTextCacheList[3] = cache3
|
||||||
|
self.effectTextCacheList[4] = cache4
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleHelper:getEffectText(parent)
|
function BattleHelper:getEffectText(parent, colorType)
|
||||||
if #self.battleEffectTextPool <= 0 then
|
local pool = self.battleEffectTextPool[colorType]
|
||||||
local prefab = CS.UnityEngine.Object.Instantiate(self.effectTextCache:getGameObject())
|
if #pool <= 0 then
|
||||||
|
local prefab = CS.UnityEngine.Object.Instantiate(self.effectTextCacheList[colorType]:getGameObject())
|
||||||
local prefabObject = UIPrefabObject:create()
|
local prefabObject = UIPrefabObject:create()
|
||||||
prefabObject:initWithPrefab(self.effectTextCache:getAssetPath(), prefab)
|
prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab)
|
||||||
prefabObject:initPrefabHelper()
|
prefabObject:initPrefabHelper()
|
||||||
prefabObject:getTransform():SetAsLastSibling()
|
prefabObject:getTransform():SetAsLastSibling()
|
||||||
prefabObject:setParent(parent, false)
|
prefabObject:setParent(parent, false)
|
||||||
local comp = prefabObject:addLuaComponent(GConst.BattleConst.TYPEOF_LUA_COMP.BATTLE_NUMBER_COMPONENT)
|
local comp = prefabObject:addLuaComponent(GConst.BattleConst.TYPEOF_LUA_COMP.BATTLE_NUMBER_COMPONENT)
|
||||||
|
comp:setColorType(colorType)
|
||||||
comp:setEnabled(true)
|
comp:setEnabled(true)
|
||||||
return comp
|
return comp
|
||||||
else
|
else
|
||||||
local effectComp = table.remove(self.battleEffectTextPool)
|
local effectComp = table.remove(pool)
|
||||||
effectComp:setEnabled(true)
|
effectComp:setEnabled(true)
|
||||||
effectComp.baseObject:getTransform():SetAsLastSibling()
|
effectComp.baseObject:getTransform():SetAsLastSibling()
|
||||||
self.battleEffectTextMap[effectComp.baseObject:getInstanceID()] = effectComp
|
self.battleEffectTextMap[effectComp.baseObject:getInstanceID()] = effectComp
|
||||||
@ -108,7 +116,9 @@ function BattleHelper:recycleEffectText(comp)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
comp:setEnabled(false)
|
comp:setEnabled(false)
|
||||||
table.insert(self.battleEffectTextPool, comp)
|
local colorType = comp:getColorType()
|
||||||
|
local pool = self.battleEffectTextPool[colorType]
|
||||||
|
table.insert(pool, comp)
|
||||||
if self.battleEffectTextMap then
|
if self.battleEffectTextMap then
|
||||||
self.battleEffectTextMap[comp.baseObject:getInstanceID()] = nil
|
self.battleEffectTextMap[comp.baseObject:getInstanceID()] = nil
|
||||||
end
|
end
|
||||||
|
|||||||
@ -329,7 +329,10 @@ end
|
|||||||
|
|
||||||
function BattleUI:initNumberNode()
|
function BattleUI:initNumberNode()
|
||||||
self.battleNumberNode = self.uiMap["battle_ui.battle_number_node"]
|
self.battleNumberNode = self.uiMap["battle_ui.battle_number_node"]
|
||||||
self.battleNumber = self.uiMap["battle_ui.battle_number_node.battle_number"]
|
self.battleNumber = self.uiMap["battle_ui.cache_node.battle_number"]
|
||||||
|
self.battleNumberRed = self.uiMap["battle_ui.cache_node.battle_number_red"]
|
||||||
|
self.battleNumberGreen = self.uiMap["battle_ui.cache_node.battle_number_green"]
|
||||||
|
self.battleNumberYellow = self.uiMap["battle_ui.cache_node.battle_number_yellow"]
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUI:getNumberNode()
|
function BattleUI:getNumberNode()
|
||||||
@ -340,6 +343,18 @@ function BattleUI:getBattleNumber()
|
|||||||
return self.battleNumber
|
return self.battleNumber
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUI:getBattleNumberRed()
|
||||||
|
return self.battleNumberRed
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:getBattleNumberGreen()
|
||||||
|
return self.battleNumberGreen
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:getBattleNumberYellow()
|
||||||
|
return self.battleNumberYellow
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUI:initHpNode()
|
function BattleUI:initHpNode()
|
||||||
self.hpProgressLeft = self.uiMap["battle_ui.top_node.bg_l.atk_slider_green"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
self.hpProgressLeft = self.uiMap["battle_ui.top_node.bg_l.atk_slider_green"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
self.hpProgressRight = self.uiMap["battle_ui.top_node.bg_r.def_slider_red"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
self.hpProgressRight = self.uiMap["battle_ui.top_node.bg_r.def_slider_red"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user