2021-04-20 13:58:00 +08:00
|
|
|
|
FloatNode = {}
|
2020-11-01 15:46:48 +08:00
|
|
|
|
|
|
|
|
|
local floatingEffect = "FloatingText"
|
|
|
|
|
local buffFloatingEffect = "BuffFloatingText"
|
2021-01-09 14:06:00 +08:00
|
|
|
|
local floor = math.floor
|
2020-11-01 15:46:48 +08:00
|
|
|
|
-- 普通文字
|
|
|
|
|
TextFloatingColor = {
|
|
|
|
|
Blue = 1,
|
|
|
|
|
Red = 2,
|
|
|
|
|
Purple = 3,
|
|
|
|
|
Green = 4,
|
|
|
|
|
}
|
|
|
|
|
local _FloatingTypeToColor = {
|
|
|
|
|
[TextFloatingColor.Blue] = Color.New(31, 237, 255, 255) / 255,
|
|
|
|
|
[TextFloatingColor.Red] = Color.New(236, 4, 4, 255) / 255,
|
|
|
|
|
[TextFloatingColor.Purple] = Color.New(235, 17, 255, 255) / 255,
|
|
|
|
|
[TextFloatingColor.Green] = Color.New(17, 255, 17, 255) / 255,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- 艺术字
|
|
|
|
|
ArtFloatingType = {
|
|
|
|
|
CritDamage = 1, -- 暴击
|
|
|
|
|
Damage = 2,
|
|
|
|
|
Treat = 3,
|
|
|
|
|
FireDamage = 4,
|
|
|
|
|
PoisonDamage = 5,
|
|
|
|
|
}
|
|
|
|
|
local ArtFloatingAnim = {
|
|
|
|
|
[1] = "Crit_Attack_Float",
|
|
|
|
|
[2] = "Normal_Attack_Float",
|
|
|
|
|
[3] = "floatingTextAnim",
|
|
|
|
|
[4] = "floatingTextAnim",
|
|
|
|
|
[5] = "floatingTextAnim",
|
|
|
|
|
}
|
|
|
|
|
--角色受到的暴击伤害(无论什么类型) - 红色字体 (字符顺序:40-49 ,0-9)(110, -)(111, +)(33, 暴击)(35, 灼烧)
|
|
|
|
|
--角色造成的点击技伤害 - 白色字体 (字符顺序:50-59 ,0-9)(112, -)(113, +)
|
|
|
|
|
--角色造成的滑动技伤害 - 黄色字体 (字符顺序:60-69 ,0-9)(114, -)(115, +)
|
|
|
|
|
--角色恢复量 - 绿色字体 (字符顺序:70-79 ,0-9)(116, -)(117, +)
|
|
|
|
|
--角色造成的异妖技伤害 - 紫色字体 (字符顺序:80-89 ,0-9)(118, -)(119, +)(34, 中毒)
|
|
|
|
|
ArtFloatingColor = {
|
|
|
|
|
Red = 0,
|
|
|
|
|
White = 1,
|
|
|
|
|
Yellow = 2,
|
|
|
|
|
Green = 3,
|
|
|
|
|
Purple = 4,
|
|
|
|
|
Poison = 5,
|
|
|
|
|
Fire = 6,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function FloatNode.New(unit, root, node)
|
|
|
|
|
local o = {}
|
|
|
|
|
setmetatable(o, {__index = FloatNode})
|
|
|
|
|
o:ctor(unit, root, node)
|
|
|
|
|
return o
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FloatNode:ctor(unit, root, node)
|
|
|
|
|
self.owner = unit
|
|
|
|
|
self.RootPanel = root
|
|
|
|
|
self.GameObject = node
|
|
|
|
|
|
|
|
|
|
self.LastBuffTextTime = Time.realtimeSinceStartup
|
|
|
|
|
self.BuffTextCount = 0
|
|
|
|
|
|
|
|
|
|
self.LastFloatingTime = Time.realtimeSinceStartup
|
|
|
|
|
self.FloatingCount = 0
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FloatNode:TextBuffFloating(type, text)
|
|
|
|
|
local color = _FloatingTypeToColor[type]
|
|
|
|
|
|
|
|
|
|
local go = BattleManager.LoadAsset(buffFloatingEffect)
|
|
|
|
|
local baseY = 0
|
|
|
|
|
go.transform:SetParent(self.RootPanel.transform)
|
|
|
|
|
go.transform.localScale = Vector3.one
|
|
|
|
|
go.transform.position = self.GameObject.transform.position
|
|
|
|
|
go:SetActive(true)
|
|
|
|
|
|
|
|
|
|
if Time.realtimeSinceStartup - self.LastBuffTextTime < BattleLogic.GameDeltaTime then
|
|
|
|
|
self.BuffTextCount = self.BuffTextCount + 1
|
|
|
|
|
else
|
|
|
|
|
self.BuffTextCount = 0
|
|
|
|
|
end
|
|
|
|
|
self.LastBuffTextTime = Time.realtimeSinceStartup
|
|
|
|
|
local v2 = go:GetComponent("RectTransform").anchoredPosition
|
|
|
|
|
go:GetComponent("RectTransform").anchoredPosition = v2 + Vector2.New(0,baseY + self.BuffTextCount * 60)
|
|
|
|
|
|
|
|
|
|
local battleSorting = BattleManager.GetBattleSorting()
|
|
|
|
|
Util.GetGameObject(go, "anim"):GetComponent("Canvas").sortingOrder = battleSorting + 200
|
|
|
|
|
Util.GetGameObject(go, "anim/text"):SetActive(true)
|
|
|
|
|
Util.GetGameObject(go, "anim/text"):GetComponent("Text").text = text
|
|
|
|
|
Util.GetGameObject(go, "anim/text"):GetComponent("Text").color = color
|
|
|
|
|
Util.GetGameObject(go, "anim/grid"):SetActive(false)
|
|
|
|
|
|
|
|
|
|
BattleManager.AddDelayRecycleRes(buffFloatingEffect, go, 1.3)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
function FloatNode:ImageBuffFloating(textImg, numImg, numTxt)
|
|
|
|
|
|
|
|
|
|
local go = BattleManager.LoadAsset(buffFloatingEffect)
|
|
|
|
|
local baseY = 0
|
|
|
|
|
go.transform:SetParent(self.RootPanel.transform)
|
|
|
|
|
go.transform.localScale = Vector3.one
|
|
|
|
|
go.transform.position = self.GameObject.transform.position
|
|
|
|
|
go:SetActive(true)
|
|
|
|
|
|
|
|
|
|
if Time.realtimeSinceStartup - self.LastBuffTextTime < BattleLogic.GameDeltaTime then
|
|
|
|
|
self.BuffTextCount = self.BuffTextCount + 1
|
|
|
|
|
else
|
|
|
|
|
self.BuffTextCount = 0
|
|
|
|
|
end
|
|
|
|
|
self.LastBuffTextTime = Time.realtimeSinceStartup
|
|
|
|
|
local v2 = go:GetComponent("RectTransform").anchoredPosition
|
|
|
|
|
go:GetComponent("RectTransform").anchoredPosition = v2 + Vector2.New(0,baseY + self.BuffTextCount * 60)
|
|
|
|
|
|
|
|
|
|
local battleSorting = BattleManager.GetBattleSorting()
|
|
|
|
|
Util.GetGameObject(go, "anim"):GetComponent("Canvas").sortingOrder = battleSorting + 200
|
|
|
|
|
Util.GetGameObject(go, "anim/text"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(go, "anim/grid"):SetActive(true)
|
|
|
|
|
|
|
|
|
|
local img1 = Util.GetGameObject(go, "anim/grid/Image1"):GetComponent("Image")
|
|
|
|
|
local img2 = Util.GetGameObject(go, "anim/grid/Image2"):GetComponent("Image")
|
|
|
|
|
local txt3 = Util.GetGameObject(go, "anim/grid/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
if textImg then
|
|
|
|
|
img1.gameObject:SetActive(true)
|
|
|
|
|
img1.sprite = Util.LoadSprite(textImg)
|
|
|
|
|
img1:SetNativeSize()
|
|
|
|
|
else
|
|
|
|
|
img1.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if numImg then
|
|
|
|
|
img2.gameObject:SetActive(true)
|
|
|
|
|
img2.sprite = Util.LoadSprite(numImg)
|
|
|
|
|
img2:SetNativeSize()
|
|
|
|
|
else
|
|
|
|
|
img2.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if numTxt then
|
|
|
|
|
txt3.gameObject:SetActive(true)
|
|
|
|
|
txt3.text = numTxt
|
|
|
|
|
else
|
|
|
|
|
txt3.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
BattleManager.AddDelayRecycleRes(buffFloatingEffect, go, 1.3)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FloatNode:GetArtText(type, color, value)
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local sp = ""
|
2020-11-01 15:46:48 +08:00
|
|
|
|
local text = ""
|
2021-01-09 14:06:00 +08:00
|
|
|
|
value=floor(value)
|
2020-11-01 15:46:48 +08:00
|
|
|
|
if type == ArtFloatingType.CritDamage then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
sp = "r_zhandou_baoji_zh" -- 暴击
|
2020-11-01 15:46:48 +08:00
|
|
|
|
text = text .. string.char((color*2)+110) -- 减号
|
|
|
|
|
elseif type == ArtFloatingType.Damage then
|
|
|
|
|
text = text .. string.char((color*2)+110) -- 减号
|
|
|
|
|
elseif type == ArtFloatingType.Treat then
|
|
|
|
|
text = text..string.char((color*2)+111) -- 加号
|
|
|
|
|
elseif type == ArtFloatingType.FireDamage then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
sp = "z_zhandou_zhuoshao_zh" -- 灼烧
|
|
|
|
|
-- text = text .. string.char(35) -- 灼烧文字
|
2020-11-01 15:46:48 +08:00
|
|
|
|
text = text .. string.char((color*2)+110) -- 减号
|
|
|
|
|
elseif type == ArtFloatingType.PoisonDamage then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
sp = "z_zhandou_zhongdu_zh" -- 灼烧
|
|
|
|
|
-- text = text .. string.char(34) -- 中毒文字
|
2020-11-01 15:46:48 +08:00
|
|
|
|
text = text .. string.char((color*2)+110) -- 减号
|
|
|
|
|
end
|
|
|
|
|
-- 数字
|
|
|
|
|
local str = tostring(value)
|
|
|
|
|
for i=1,#str do
|
|
|
|
|
text = text..string.char((string.byte(str,i) - 48) + color*10 + 40)
|
|
|
|
|
end
|
2021-01-26 17:08:39 +08:00
|
|
|
|
return sp, text
|
2020-11-01 15:46:48 +08:00
|
|
|
|
end
|
|
|
|
|
function FloatNode:ArtFloating(type, color, value)
|
|
|
|
|
local go = BattleManager.LoadAsset(floatingEffect)
|
|
|
|
|
go.transform:SetParent(self.RootPanel.transform)
|
|
|
|
|
go.transform.localScale = Vector3.one * 0.7
|
|
|
|
|
go.transform.position = self.GameObject.transform.position
|
|
|
|
|
go:SetActive(true)
|
|
|
|
|
|
|
|
|
|
if Time.realtimeSinceStartup - self.LastFloatingTime < BattleLogic.GameDeltaTime then
|
|
|
|
|
self.FloatingCount = self.FloatingCount + 1
|
|
|
|
|
else
|
|
|
|
|
self.FloatingCount = 0
|
|
|
|
|
end
|
|
|
|
|
self.LastFloatingTime = Time.realtimeSinceStartup
|
|
|
|
|
local v2 = go:GetComponent("RectTransform").anchoredPosition
|
|
|
|
|
v2 = v2 + Vector2.New(0, self.owner.role.camp * 100 + 100)
|
|
|
|
|
go:GetComponent("RectTransform").anchoredPosition = v2 + Vector2.New(0, 50) * (self.FloatingCount+1)
|
|
|
|
|
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local sp, text = self:GetArtText(type, color, value)
|
2020-11-01 15:46:48 +08:00
|
|
|
|
local anim = Util.GetGameObject(go, "anim")
|
2021-01-26 17:08:39 +08:00
|
|
|
|
-- 伤害文字
|
|
|
|
|
local img = Util.GetGameObject(anim, "Image"):GetComponent("Image")
|
|
|
|
|
if sp and sp ~= "" then
|
|
|
|
|
img.sprite = Util.LoadSprite(sp)
|
|
|
|
|
img.gameObject:SetActive(true)
|
|
|
|
|
else
|
|
|
|
|
img.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
-- 伤害数值
|
|
|
|
|
local animTxt = Util.GetGameObject(go, "anim/anim")
|
|
|
|
|
local animTxtC = animTxt:GetComponent("Text")
|
|
|
|
|
animTxtC.text = text
|
|
|
|
|
-- 层级和动画
|
2020-11-01 15:46:48 +08:00
|
|
|
|
anim:GetComponent("Canvas").sortingOrder = BattleManager.GetBattleSorting() + 100
|
|
|
|
|
anim:GetComponent("Animator"):Play(ArtFloatingAnim[type])
|
2021-01-26 17:08:39 +08:00
|
|
|
|
|
2020-11-01 15:46:48 +08:00
|
|
|
|
BattleManager.AddDelayRecycleRes(floatingEffect, go, 2)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return FloatNode
|