miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffView.lua

110 lines
3.5 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

BuffView ={}
BuffView.__index = BuffView
function BuffView.New(go, buff, icon)
local instance = {}
setmetatable(instance, BuffView)
instance.go = go
instance.buff = buff
instance.buffPropertyName = buff.propertyName
instance.buffValue = buff.Value
instance.buffCt = buff.changeType
instance.buffDamageType = buff.damageType
instance.buffDamageFactor = buff.damagePro
instance.buffCtrlType = buff.ctrlType
instance.healValue = buff.healValue
instance.immuneType = buff.immuneType
instance.curseType = buff.curseType
instance.buffSignType = buff.signType
instance.levelText = Util.GetGameObject(go, "level"):GetComponent("Text")
instance.layerText = Util.GetGameObject(go, "layer"):GetComponent("Text")
instance.roundText = Util.GetGameObject(go, "round"):GetComponent("Text")
instance.duration = buff.duration
instance.icon = go:GetComponent("Image")
instance.spLoader = SpriteLoader.New()
instance.icon.sprite = instance.spLoader:LoadSprite(icon)
instance.icon.color = Color.New(1,1,1,1)
-- if buff.layer and buff.cover then
-- instance.levelText.text = tostring(buff.layer)
-- instance.count = buff.layer
-- else
-- instance.levelText.text = ""
-- instance.count = 1
-- end
instance.levelText.text = ""
instance.count = 1
instance.layerText.text = ""
instance.roundText.text = ""
instance.hideFlag = false
instance:SetRound(buff)
return instance
end
function BuffView:Dispose()
self.spLoader:Destroy()
BattlePool.RecycleItem(self.go, BATTLE_POOL_TYPE.BUFF_VIEW)
end
function BuffView:SetCount(count)
-- if self.tweener then
-- self.tweener:Kill()
-- self.icon.color = Color.New(1,1,1,1)
-- end
if not count then
count = self.count
end
--if not self.buff.cover then
if count == 1 then --只有1个独立buff不显示数字
self.layerText.text = ""
self.count = 1
else
self.layerText.text = tostring(count)
self.count = count
end
--end
end
function BuffView:SetLayer(buff)
-- if self.tweener then
-- self.tweener:Kill()
-- self.icon.color = Color.New(1,1,1,1)
-- end
self.buff = buff
if buff.layer and buff.cover then
self.levelText.text = tostring(buff.layer)
end
end
function BuffView:SetRound(buff)
-- body
self.buff = buff
self.roundText.text = ""
if buff.roundDuration then
local leftRound = buff.roundDuration - buff.roundPass
if leftRound > 0 then
self.roundText.text = tostring(leftRound)
end
end
end
function BuffView:Update()
-- if self.buff.frameDuration > 0 then
-- local num = (self.buff.frameDuration - self.buff.framePass) / BattleLogic.GameFrameRate
-- if num < 1 and self.count == 1 and not self.hideFlag then --当不可叠加的buff只剩一个且持续时间小于1秒时播闪烁效果
-- self.hideFlag = true
-- self.tweener = self.icon:DOFade(0, 0.2):OnComplete(function ()
-- self.tweener = self.icon:DOFade(1, 0.2):OnComplete(function ()
-- self.tweener = self.icon:DOFade(0, 0.2):OnComplete(function ()
-- self.tweener = self.icon:DOFade(1, 0.2):OnComplete(function ()
-- self.tweener = self.icon:DOFade(0, 0.2)
-- end)
-- end)
-- end)
-- end)
-- end
-- end
end