Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
local BuffCtrl = class("BuffCtrl", BaseCtrl)
|
||||
BuffCtrl._mapNodeConfig = {
|
||||
goBuffGrid = {},
|
||||
rtPool = {sComponentName = "Transform"},
|
||||
buffContent = {sComponentName = "Transform"}
|
||||
}
|
||||
BuffCtrl._mapEventConfig = {}
|
||||
function BuffCtrl:Awake()
|
||||
self.mapBuff = {}
|
||||
self.tbPool = {}
|
||||
self.tbAllCtrl = {}
|
||||
end
|
||||
function BuffCtrl:FadeIn()
|
||||
end
|
||||
function BuffCtrl:FadeOut()
|
||||
end
|
||||
function BuffCtrl:OnEnable()
|
||||
self.nActiveCount = 0
|
||||
end
|
||||
function BuffCtrl:OnDisable()
|
||||
if self.nEntityId ~= nil then
|
||||
self:UnbindEntity()
|
||||
end
|
||||
end
|
||||
function BuffCtrl:OnDestroy()
|
||||
end
|
||||
function BuffCtrl:OnRelease()
|
||||
end
|
||||
function BuffCtrl:AddShield()
|
||||
if self.buffGrid ~= nil then
|
||||
return
|
||||
end
|
||||
local shieldGrid = self:GetBuffGrid()
|
||||
shieldGrid.gameObject.transform:SetAsFirstSibling()
|
||||
self.buffGrid = shieldGrid
|
||||
self.buffGrid:SetShield()
|
||||
end
|
||||
function BuffCtrl:RemoveShield()
|
||||
if self.buffGrid == nil then
|
||||
return
|
||||
end
|
||||
if self.buffGrid ~= nil then
|
||||
local buffGrid = self.buffGrid
|
||||
self.buffGrid = nil
|
||||
local animCallback = function()
|
||||
self:RecycleBuffGrid(buffGrid)
|
||||
end
|
||||
buffGrid:CancelBuff(animCallback)
|
||||
end
|
||||
end
|
||||
function BuffCtrl:OnEvent_BuffUI(nUid, nBuffId, nTime, nCount)
|
||||
local mapBuff = ConfigTable.GetData_Buff(nBuffId)
|
||||
if mapBuff == nil then
|
||||
printError("Buff Data Missing:" .. nBuffId)
|
||||
return
|
||||
end
|
||||
if not mapBuff.IsShow then
|
||||
return
|
||||
end
|
||||
if nTime == 0 or nCount == 0 then
|
||||
if self.mapBuff[nUid] == nil then
|
||||
print("0时间或层数buff 不处理")
|
||||
return
|
||||
else
|
||||
local removedCtrl = self.mapBuff[nUid]
|
||||
self.mapBuff[nUid] = nil
|
||||
local animCallback = function()
|
||||
self:RecycleBuffGrid(removedCtrl)
|
||||
end
|
||||
removedCtrl:CancelBuff(animCallback)
|
||||
self.nActiveCount = self.nActiveCount - 1
|
||||
end
|
||||
else
|
||||
if self.nActiveCount > 40 then
|
||||
printError("buff数量过多本次不处理")
|
||||
return
|
||||
end
|
||||
if self.mapBuff[nUid] == nil then
|
||||
self.mapBuff[nUid] = self:GetBuffGrid()
|
||||
self.nActiveCount = self.nActiveCount + 1
|
||||
end
|
||||
self.mapBuff[nUid]:SetBuff(nBuffId, nCount, nTime)
|
||||
end
|
||||
end
|
||||
function BuffCtrl:GetBuffGrid()
|
||||
if #self.tbPool > 0 then
|
||||
local mapGoCtrl = table.remove(self.tbPool)
|
||||
mapGoCtrl.gameObject.transform:SetParent(self._mapNode.buffContent)
|
||||
local rtGo = mapGoCtrl.gameObject:GetComponent("RectTransform")
|
||||
mapGoCtrl:InterrputAnim()
|
||||
rtGo.localPosition = Vector3.zero
|
||||
rtGo.localScale = Vector3.one
|
||||
rtGo.sizeDelta = Vector2(46, 64)
|
||||
mapGoCtrl.gameObject:SetActive(true)
|
||||
return mapGoCtrl
|
||||
else
|
||||
local goGrid = instantiate(self._mapNode.goBuffGrid)
|
||||
goGrid.transform:SetParent(self._mapNode.buffContent)
|
||||
local rtGo = goGrid.gameObject:GetComponent("RectTransform")
|
||||
rtGo.localPosition = Vector3.zero
|
||||
rtGo.localScale = Vector3.one
|
||||
rtGo.sizeDelta = Vector2(46, 64)
|
||||
goGrid:SetActive(true)
|
||||
local mapCtrl = self:BindCtrlByNode(goGrid, "Game.UI.Hud.Buff.BuffGridCtrl")
|
||||
table.insert(self.tbAllCtrl, mapCtrl)
|
||||
return mapCtrl
|
||||
end
|
||||
end
|
||||
function BuffCtrl:RecycleBuffGrid(mapGridCtrl)
|
||||
table.insert(self.tbPool, mapGridCtrl)
|
||||
mapGridCtrl:InterrputAnim()
|
||||
mapGridCtrl.gameObject:SetActive(false)
|
||||
mapGridCtrl.gameObject.transform:SetParent(self._mapNode.rtPool)
|
||||
end
|
||||
function BuffCtrl:BindEntity(nEntityId)
|
||||
if self.nEntityId ~= nil then
|
||||
printError(string.format("buff已被绑定 当前:%d,绑定:%d", self.nEntityId, nEntityId))
|
||||
return
|
||||
end
|
||||
self.nEntityId = nEntityId
|
||||
EventManager.AddEntityEvent("BuffUIEvent", nEntityId, self, self.OnEvent_BuffUI)
|
||||
self:ClearAllBuffGrid()
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local tbBuffInfo = AdventureModuleHelper.GetEntityBuffList(self.nEntityId)
|
||||
if tbBuffInfo ~= nil then
|
||||
local nBuffCount = tbBuffInfo.Count - 1
|
||||
for l = 0, nBuffCount do
|
||||
local eftInfo = tbBuffInfo[l]
|
||||
local nUid = eftInfo:GetUid()
|
||||
local nTime = eftInfo:GetBuffLeftTime():AsInt()
|
||||
self:OnEvent_BuffUI(nUid, eftInfo.buffConfig.Id, nTime, eftInfo:GetBuffNum())
|
||||
end
|
||||
end
|
||||
end
|
||||
function BuffCtrl:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("BuffUIEvent", self.nEntityId, self, self.OnEvent_BuffUI)
|
||||
self.nEntityId = nil
|
||||
self:ClearAllBuffGrid()
|
||||
end
|
||||
function BuffCtrl:ClearAllBuffGrid()
|
||||
self.mapBuff = {}
|
||||
self.tbPool = {}
|
||||
self.nActiveCount = 0
|
||||
for _, mapCtrl in ipairs(self.tbAllCtrl) do
|
||||
self:UnbindCtrlByNode(mapCtrl)
|
||||
end
|
||||
self.buffGrid = nil
|
||||
self.tbAllCtrl = {}
|
||||
if self._mapNode.rtPool and type(self._mapNode.rtPool) ~= "number" then
|
||||
delChildren(self._mapNode.rtPool)
|
||||
end
|
||||
if self._mapNode.buffContent and type(self._mapNode.buffContent) ~= "number" then
|
||||
delChildren(self._mapNode.buffContent)
|
||||
end
|
||||
end
|
||||
return BuffCtrl
|
||||
@@ -0,0 +1,98 @@
|
||||
local BuffGridCtrl = class("BuffGridCtrl", BaseCtrl)
|
||||
local nImpendingTime = 2
|
||||
local DefaultWidth = 46
|
||||
local DefaultHeight = 64
|
||||
BuffGridCtrl._mapNodeConfig = {
|
||||
imgBuffBg = {sComponentName = "Image"},
|
||||
TMPCount = {sComponentName = "TMP_Text"},
|
||||
canvasGroup = {
|
||||
sComponentName = "CanvasGroup",
|
||||
sNodeName = "imgBuffBg"
|
||||
}
|
||||
}
|
||||
BuffGridCtrl._mapEventConfig = {}
|
||||
function BuffGridCtrl:Awake()
|
||||
end
|
||||
function BuffGridCtrl:FadeIn()
|
||||
end
|
||||
function BuffGridCtrl:FadeOut()
|
||||
end
|
||||
function BuffGridCtrl:OnEnable()
|
||||
self.compRtAnim = self.gameObject:GetComponent("HpBarRectTransform")
|
||||
self.rootAnim = self.gameObject:GetComponent("Animator")
|
||||
self.rtRoot = self.gameObject:GetComponent("RectTransform")
|
||||
self.timer = nil
|
||||
end
|
||||
function BuffGridCtrl:OnDisable()
|
||||
end
|
||||
function BuffGridCtrl:OnDestroy()
|
||||
end
|
||||
function BuffGridCtrl:OnRelease()
|
||||
end
|
||||
function BuffGridCtrl:SetBuff(nBuffId, nCount, nTime)
|
||||
self.rtRoot.sizeDelta = Vector2(DefaultWidth, DefaultHeight)
|
||||
local mapBuff = ConfigTable.GetData_Buff(nBuffId)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup, 1)
|
||||
self:SetPngSprite(self._mapNode.imgBuffBg, mapBuff.Icon)
|
||||
self.rootAnim:Play("rtBuff_in")
|
||||
if 1 < nCount then
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCount, string.format("×%d", nCount))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCount, "")
|
||||
end
|
||||
if nTime < 0 then
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
self.timer = nil
|
||||
end
|
||||
elseif nTime <= nImpendingTime then
|
||||
self:BuffImpendingAnim(0, true)
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
self.timer = nil
|
||||
end
|
||||
else
|
||||
self:BuffImpendingAnim(0, false)
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
end
|
||||
self.timer = self:AddTimer(1, nTime - nImpendingTime, "BuffImpendingAnim", true, true, nil, true)
|
||||
end
|
||||
end
|
||||
function BuffGridCtrl:SetShield()
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
end
|
||||
self.timer = nil
|
||||
self.rtRoot.sizeDelta = Vector2(DefaultWidth, DefaultHeight)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup, 1)
|
||||
self:SetPngSprite(self._mapNode.imgBuffBg, "Icon/Buff/Icon_CommonBuff_Shield")
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPCount, "")
|
||||
self.rootAnim:Play("rtBuff_in")
|
||||
end
|
||||
function BuffGridCtrl:CancelBuff(callback)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup, 0)
|
||||
self.compRtAnim:SetTarget(Vector2(0, DefaultHeight), 0.5, 0)
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel()
|
||||
end
|
||||
self:BuffImpendingAnim(0, false)
|
||||
self.rootAnim:Play("rtBuff_out")
|
||||
local EndCallback = function()
|
||||
if callback ~= nil then
|
||||
callback()
|
||||
end
|
||||
end
|
||||
self.timer = self:AddTimer(1, 0.5, EndCallback, true, true, nil, true)
|
||||
end
|
||||
function BuffGridCtrl:BuffImpendingAnim(_, bShow)
|
||||
if bShow then
|
||||
self.rootAnim:Play("rtBuff_Impending")
|
||||
else
|
||||
self.rootAnim:Play("Empty")
|
||||
end
|
||||
end
|
||||
function BuffGridCtrl:InterrputAnim()
|
||||
self.compRtAnim.enabled = false
|
||||
end
|
||||
return BuffGridCtrl
|
||||
@@ -0,0 +1,444 @@
|
||||
local EliteMonsterHudCtrl = class("EliteMonsterHudCtrl", BaseCtrl)
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local BarHeight = 21
|
||||
local BarWidth = 175
|
||||
local ShieldWidth = 195
|
||||
local AniTimeHighlight = 0.5
|
||||
local AniTime = 0.16
|
||||
local ToughnessRecoverTime = 0.3
|
||||
local ToughnessWidth = 208
|
||||
local ToughnessHeight = 21
|
||||
local colorHide = Color(1, 1, 1, 0)
|
||||
local colorWhite = Color(1, 1, 1, 1)
|
||||
local colorShieldDelay = Color(1, 1, 1, 0.5)
|
||||
local colorRed = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 1)
|
||||
local colorRedHide = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 0)
|
||||
local colorRecover = Color(0.9921568627450981, 0.5098039215686274, 0, 1)
|
||||
EliteMonsterHudCtrl._mapNodeConfig = {
|
||||
rtHpFillDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
aniRtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelayHighlight = {
|
||||
sNodeName = "imgHpDelayHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillHighLight = {
|
||||
sNodeName = "imgHpHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillRecoverLight = {
|
||||
sNodeName = "imgHpFillRecoverLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtShield = {},
|
||||
rtShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldDelay = {sComponentName = "Image"},
|
||||
ainColorShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtShieldFill = {
|
||||
sNodeName = "imgShieldFill",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtShieldFill = {
|
||||
sNodeName = "imgShieldFill",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldFillHighLight = {sComponentName = "Image"},
|
||||
ainColorShieldFillHighLight = {
|
||||
sNodeName = "imgShieldFillHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
animRtShield = {
|
||||
sNodeName = "ShieldAnimRoot",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
rtToughness = {},
|
||||
rtNormal = {},
|
||||
imgBroken = {},
|
||||
imgToughnessMaskDelay = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
imgToughnessMask = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtHighlight = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
Highlight = {
|
||||
sNodeName = "rtHighlight",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
imgBrokenChip = {sComponentName = "Image"},
|
||||
aniRtToughnessDelay = {
|
||||
sNodeName = "imgToughnessMaskDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
aniRtToughnessFill = {
|
||||
sNodeName = "imgToughnessMask",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorToughnessHighlight = {
|
||||
sNodeName = "rtHighlight",
|
||||
sComponentName = "HpBarCanvasGroup"
|
||||
},
|
||||
ainColorToughnessBrokenChip = {
|
||||
sNodeName = "imgBrokenChip",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
toughnessLockLight = {
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
ainLockToughnessHighlight = {
|
||||
sNodeName = "toughnessLockLight",
|
||||
sComponentName = "HpBarCanvasGroup"
|
||||
},
|
||||
imgToughnessLock = {},
|
||||
rtShakeRoot = {sComponentName = "Animator"},
|
||||
rtBuff = {
|
||||
sCtrlName = "Game.UI.Hud.Buff.BuffCtrl"
|
||||
},
|
||||
imgBossIcon = {sComponentName = "Image"}
|
||||
}
|
||||
EliteMonsterHudCtrl._mapEventConfig = {}
|
||||
local multipleBossIcon = {
|
||||
[GameEnum.monsterBloodType.BOSS] = "icon_story_boss1",
|
||||
[GameEnum.monsterBloodType.MINIBOSS] = "icon_story_boss2"
|
||||
}
|
||||
function EliteMonsterHudCtrl:PlayTweenHp(hp, hpMax)
|
||||
local nWidth = 1 <= hp / hpMax and BarWidth or hp / hpMax * BarWidth
|
||||
if nWidth > BarWidth then
|
||||
nWidth = BarWidth
|
||||
end
|
||||
if hp < self.nBeforeHp then
|
||||
if self._mapNode.rtHpFill.sizeDelta.x > self._mapNode.rtHpFillDelay.sizeDelta.x then
|
||||
self._mapNode.aniRtHpDelay:SetTarget(self._mapNode.rtHpFill.sizeDelta, 0)
|
||||
end
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeHp - hp) / hpMax > self.bigDamageThreshold then
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0.1, AniTime)
|
||||
delayTime = 0.5
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime, delayTime)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + delayTime)
|
||||
else
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = self._mapNode.rtHpFill.sizeDelta
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, AniTime)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, AniTimeHighlight)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRecover)
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), AniTime, AniTime)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorRed, 0)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorRedHide, AniTimeHighlight, AniTime)
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
local nWidth = 1 <= shieldValue / shieldValueMax and ShieldWidth or shieldValue / shieldValueMax * ShieldWidth
|
||||
if shieldValue < self.nBeforeShield then
|
||||
if self._mapNode.rtShieldDelay.sizeDelta.x < self._mapNode.rtShieldFill.sizeDelta.x then
|
||||
self._mapNode.rtShieldDelay.sizeDelta = self._mapNode.rtShieldFill.sizeDelta
|
||||
end
|
||||
self._mapNode.rtShieldFill.sizeDelta = Vector2(nWidth, BarHeight)
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldFillHighLight, colorWhite)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeShield - shieldValue) / shieldValueMax > self.bigDamageThreshold then
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldDelay, colorWhite)
|
||||
self._mapNode.ainColorShieldDelay:SetTarget(colorShieldDelay, 0.1, AniTime)
|
||||
delayTime = 0.5
|
||||
end
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime, delayTime)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + delayTime)
|
||||
else
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldFillHighLight, colorWhite)
|
||||
self._mapNode.ainColorShieldDelay:SetTarget(colorShieldDelay, 0)
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + AniTime)
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:KillTweenToughness()
|
||||
self._mapNode.aniRtToughnessDelay:Stop()
|
||||
self._mapNode.aniRtToughnessFill:Stop()
|
||||
self._mapNode.ainColorToughnessHighlight:Stop()
|
||||
end
|
||||
function EliteMonsterHudCtrl:PlayTweenToughness(toughness, toughnessMax)
|
||||
if toughness == self.nBeforeToughness then
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.toughnessLockLight, 1)
|
||||
self._mapNode.ainLockToughnessHighlight:SetTarget(0, 0.3)
|
||||
end
|
||||
self._mapNode.imgToughnessLock.gameObject:SetActive(false)
|
||||
self:KillTweenToughness()
|
||||
local nWidth = 1 <= toughness / toughnessMax and ToughnessWidth or toughness / toughnessMax * ToughnessWidth
|
||||
if nWidth > ToughnessWidth then
|
||||
nWidth = ToughnessWidth
|
||||
end
|
||||
if self._mapNode.imgToughnessMaskDelay.sizeDelta.x < self._mapNode.imgToughnessMask.sizeDelta.x then
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = self._mapNode.imgToughnessMask.sizeDelta
|
||||
end
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0 < nWidth and nWidth or 0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(0 < nWidth and nWidth - 12 or 0, 0)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeToughness - toughness) / toughnessMax > self.bigDamageThreshold then
|
||||
delayTime = 0.5
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 1)
|
||||
self._mapNode.ainColorToughnessHighlight:SetTarget(0, AniTime, delayTime + AniTime)
|
||||
self._mapNode.aniRtToughnessDelay:SetTarget(Vector2(nWidth, ToughnessHeight), AniTime, delayTime)
|
||||
end
|
||||
function EliteMonsterHudCtrl:PlayTweenToughnessBroken()
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(0, 0)
|
||||
self._mapNode.rtNormal:SetActive(false)
|
||||
self._mapNode.imgBroken:SetActive(true)
|
||||
self._mapNode.ainColorToughnessBrokenChip:Play("imgBrokenChip_in")
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
if not self.bToughnessRecover then
|
||||
local callback = function()
|
||||
self._mapNode.rtToughness:SetActive(false)
|
||||
end
|
||||
self:AddTimer(1, 0.75, callback, true, true, true, nil)
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:PlayTweenToughnessRecover()
|
||||
self:KillTweenToughness()
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(ToughnessWidth - 12, 0)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 0)
|
||||
self._mapNode.rtNormal:SetActive(true)
|
||||
self._mapNode.imgBroken:SetActive(false)
|
||||
self.tweenerToughness3 = self._mapNode.aniRtToughnessFill:SetTarget(Vector2(ToughnessWidth, ToughnessHeight), ToughnessRecoverTime)
|
||||
end
|
||||
function EliteMonsterHudCtrl:ResetHit()
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, 0)
|
||||
self.nBeforeHp = 0
|
||||
self.nBeforeHpMax = 0
|
||||
self.nBeforeShield1 = 0
|
||||
self.nBeforeShield2 = 0
|
||||
self.nBeforeShield3 = 0
|
||||
self.nBeforeShield4 = 0
|
||||
self.nBeforeToughness = 0
|
||||
self._mapNode.rtNormal:SetActive(true)
|
||||
self._mapNode.imgBroken:SetActive(false)
|
||||
end
|
||||
function EliteMonsterHudCtrl:KillTween()
|
||||
self._mapNode.aniRtHpDelay:Stop()
|
||||
self._mapNode.ainColorHpDelay:Stop()
|
||||
self._mapNode.aniRtHpFill:Stop()
|
||||
self._mapNode.ainColorHpDelayHighlight:Stop()
|
||||
self._mapNode.ainColorHpFillHighLight:Stop()
|
||||
self._mapNode.ainColorHpFillRecoverLight:Stop()
|
||||
self._mapNode.aniRtShieldDelay:Stop()
|
||||
self._mapNode.ainColorShieldDelay:Stop()
|
||||
self._mapNode.aniRtShieldFill:Stop()
|
||||
self._mapNode.ainColorShieldFillHighLight:Stop()
|
||||
self._mapNode.aniRtToughnessDelay:Stop()
|
||||
self._mapNode.aniRtToughnessFill:Stop()
|
||||
self._mapNode.ainColorToughnessHighlight:Stop()
|
||||
end
|
||||
function EliteMonsterHudCtrl:Awake()
|
||||
self.monsterId = 0
|
||||
self.bigDamageThreshold = ConfigTable.GetConfigNumber("BloodSpecialEffectThresholdValue") / 100
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnEnable()
|
||||
self.monsterId = 0
|
||||
self:ResetHit()
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnDisable()
|
||||
self._mapNode.rtBuff:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessStateChanged", self.monsterId, self, self.OnEvent_ToughnessStateChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessValueChanged", self.monsterId, self, self.OnEvent_ToughnessValueChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessShowStateChanged", self.monsterId, self, self.OnEvent_ToughnessShowStateChanged)
|
||||
self.monsterId = 0
|
||||
self:KillTween()
|
||||
self:ResetHit()
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnDestroy()
|
||||
end
|
||||
function EliteMonsterHudCtrl:SetMonsterId(monsterId, nDataId, nType, bMultipleBoss)
|
||||
if self.monsterId == monsterId then
|
||||
return
|
||||
end
|
||||
local mapMonster = ConfigTable.GetData("Monster", nDataId)
|
||||
if mapMonster == nil then
|
||||
printError("Boss Data Missing:" .. nDataId)
|
||||
return
|
||||
end
|
||||
self.monsterId = monsterId
|
||||
self._mapNode.imgBossIcon.gameObject:SetActive(bMultipleBoss)
|
||||
if bMultipleBoss then
|
||||
local sIcon = multipleBossIcon[nType]
|
||||
self:SetAtlasSprite(self._mapNode.imgBossIcon, "15_battle", sIcon)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgBossIcon)
|
||||
end
|
||||
self:ResetHit()
|
||||
self:KillTween()
|
||||
local hp = AdventureModuleHelper.GetEntityHp(self.monsterId)
|
||||
local hpMax = AdventureModuleHelper.GetEntityMaxHp(self.monsterId)
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.one
|
||||
local toughness = AdventureModuleHelper.GetMonsterToughness(self.monsterId)
|
||||
local toughnessMax = AdventureModuleHelper.GetMonsterToughnessMax(self.monsterId)
|
||||
self:SetHp(hp, hpMax, true)
|
||||
self:SetToughness(toughness, toughnessMax, false, true)
|
||||
local shieldValue, shieldValueMax = AdventureModuleHelper.GetEntityShieldValue(self.monsterId)
|
||||
self:SetShield(shieldValue, shieldValueMax, true)
|
||||
self.bToughnessRecover = mapMonster.ToughnessBrokenTime > 0
|
||||
self._mapNode.rtBuff:BindEntity(self.monsterId)
|
||||
EventManager.AddEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.AddEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.AddEntityEvent("ToughnessStateChanged", self.monsterId, self, self.OnEvent_ToughnessStateChanged)
|
||||
EventManager.AddEntityEvent("ToughnessValueChanged", self.monsterId, self, self.OnEvent_ToughnessValueChanged)
|
||||
EventManager.AddEntityEvent("ToughnessShowStateChanged", self.monsterId, self, self.OnEvent_ToughnessShowStateChanged)
|
||||
if not self.bToughnessRecover and toughness <= 0 then
|
||||
self._mapNode.rtToughness:SetActive(false)
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:SetHp(hp, hpMax, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if hpMax <= 0 then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(0, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(0, BarHeight)
|
||||
elseif bChange then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
else
|
||||
self:PlayTweenHp(hp, hpMax)
|
||||
end
|
||||
self.nBeforeHp = hp
|
||||
self.nBeforeHpMax = hpMax
|
||||
end
|
||||
function EliteMonsterHudCtrl:SetToughness(toughness, toughnessMax, bState, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if toughnessMax <= 0 then
|
||||
self._mapNode.rtToughness:SetActive(false)
|
||||
elseif bChange then
|
||||
self._mapNode.rtToughness:SetActive(true)
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(toughness / toughnessMax * ToughnessWidth, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(toughness / toughnessMax * ToughnessWidth, ToughnessHeight)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 0)
|
||||
elseif bState then
|
||||
if toughness == 0 then
|
||||
self:PlayTweenToughnessBroken()
|
||||
else
|
||||
self:PlayTweenToughnessRecover()
|
||||
end
|
||||
else
|
||||
self:PlayTweenToughness(toughness, toughnessMax)
|
||||
end
|
||||
self.nBeforeToughness = toughness
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnEvent_HpChanged(hp, hpMax)
|
||||
if hp == self.nBeforeHp then
|
||||
self:SetHp(hp, hpMax, true)
|
||||
else
|
||||
self:SetHp(hp, hpMax)
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnEvent_ShieldChanged(value1, value2)
|
||||
if value1 == self.nBeforeShield then
|
||||
return
|
||||
else
|
||||
self:SetShield(value1, value2)
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnEvent_ToughnessStateChanged(bBroken, nValue, nToughnessMax)
|
||||
if bBroken then
|
||||
self:SetToughness(0, nToughnessMax, true)
|
||||
elseif nValue ~= 0 then
|
||||
self:SetToughness(nToughnessMax, nToughnessMax, true)
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnEvent_ToughnessValueChanged(toughness, toughnessMax)
|
||||
self:SetToughness(toughness, toughnessMax, false)
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnEvent_ToughnessShowStateChanged(bShow)
|
||||
if bShow then
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.one
|
||||
else
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.zero
|
||||
end
|
||||
end
|
||||
function EliteMonsterHudCtrl:SetShield(shieldValue, shieldValueMax, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if shieldValue <= 0 then
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(0, BarHeight), 0)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(0, BarHeight), 0)
|
||||
if bChange then
|
||||
self._mapNode.animRtShield:Play("rtShield_out_change")
|
||||
elseif 0 < self.nBeforeShield then
|
||||
self._mapNode.animRtShield:Play("rtShield_out")
|
||||
end
|
||||
elseif bChange then
|
||||
self._mapNode.animRtShield:Play("rtShield_in_change")
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(shieldValue / shieldValueMax * ShieldWidth, BarHeight), 0)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(shieldValue / shieldValueMax * ShieldWidth, BarHeight), 0)
|
||||
else
|
||||
if 0 >= self.nBeforeShield then
|
||||
self._mapNode.animRtShield:Play("rtShield_in")
|
||||
end
|
||||
self:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
end
|
||||
self.nBeforeShield = shieldValue
|
||||
self.nBeforeShieldMax = shieldValueMax
|
||||
end
|
||||
function EliteMonsterHudCtrl:OnEvent_Deaded()
|
||||
self._mapNode.rtBuff:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessStateChanged", self.monsterId, self, self.OnEvent_ToughnessStateChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessValueChanged", self.monsterId, self, self.OnEvent_ToughnessValueChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessShowStateChanged", self.monsterId, self, self.OnEvent_ToughnessShowStateChanged)
|
||||
EventManager.Hit("MonsterHUDChange", self.monsterId, GameEnum.monsterBloodType.ADVANCE, false)
|
||||
end
|
||||
return EliteMonsterHudCtrl
|
||||
@@ -0,0 +1,473 @@
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local HudMainCtrl = class("HudMainCtrl", BaseCtrl)
|
||||
HudMainCtrl._mapNodeConfig = {
|
||||
Root = {sNodeName = "Root"},
|
||||
DamageNumberRoot = {},
|
||||
DamageWordRoot = {},
|
||||
BattleTarget = {sComponentName = "Canvas"}
|
||||
}
|
||||
HudMainCtrl._mapEventConfig = {
|
||||
PlayerShow = "OnEvent_PlayerShowChanged",
|
||||
ShowBossHUD = "OnEvent_ShowBossHUD",
|
||||
MonsterHUDChange = "OnEvent_MonsterHUDChange",
|
||||
AllHudShow = "OnEvent_AllHudShowChanged",
|
||||
HudDestroy = "OnEvent_HudDestroyed",
|
||||
HudDamage = "OnEvent_HudDamaged",
|
||||
HudHeal = "OnEvent_HudHealed",
|
||||
HudDefence = "OnEvent_HudDefenced",
|
||||
HudDotDamage = "OnEvent_HudDotDamage",
|
||||
ADVENTURE_LEVEL_END = "OnEvent_LevelEnd",
|
||||
NPCShow = "OnEvent_NPCShow",
|
||||
TriggerElementMark = "OnEvent_HudMark",
|
||||
TestSwitchHudDamage = "OnEvent_SwitchHudDamage",
|
||||
TestSwitchHudHpBar = "OnEvent_SwitchHudHpBar",
|
||||
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
|
||||
CacheInstanceHud = "OnEvent_CacheInstanceHud",
|
||||
SpecialHudShow = "OnEvent_HuoChuiBossShow",
|
||||
ToughnessStateChangedForGlobal = "OnEvent_ToughnessStateChangedForGlobal",
|
||||
ADVENTURE_BATTLE_MONSTER_DECLARE_DIED = "OnEvent_MonsterDeclareDied"
|
||||
}
|
||||
function HudMainCtrl:Awake()
|
||||
end
|
||||
function HudMainCtrl:OnEnable()
|
||||
self.resistanceTipInterval = ConfigTable.GetConfigNumber("HudResistanceTipInterval")
|
||||
self.hudId = 0
|
||||
self.playerHuds = {}
|
||||
self.monsterHuds = {}
|
||||
self.monsterAdvHuds = {}
|
||||
self.numberHuds = {}
|
||||
self.npcHuds = {}
|
||||
self.specialHuds = {}
|
||||
self.nBloodType = 0
|
||||
self.tbBossBloodState = {}
|
||||
self.nTypeGreyResistanceTime = {}
|
||||
self.tabToughnessEntity = {}
|
||||
self.tabToughnessEntityVal = {}
|
||||
self.tabToughnessHudId = {}
|
||||
self.playerHudPrefab = self:LoadAsset("UI/HUD/PlayerHUD.prefab")
|
||||
self.monsterHudPrefab = self:LoadAsset("UI/HUD/MonsterHUD.prefab")
|
||||
self.monsterHudEpicPrefab = self:LoadAsset("UI/HUD/MonsterHUD_Epic.prefab")
|
||||
self.playerSummonerHudPrefab = self:LoadAsset("UI/HUD/MonsterHUD_PlayerSummoner.prefab")
|
||||
self.critDamageHudPrefab = self:LoadAsset("UI/HUD/CritDamageHUDNumber_UI.prefab")
|
||||
self.dotDamageHudPrefab = self:LoadAsset("UI/HUD/DotDamageHUDNumber_UI.prefab")
|
||||
self.damageHudPrefab = self:LoadAsset("UI/HUD/DamageHUDNumber_UI.prefab")
|
||||
self.minDamageHUDNumber = self:LoadAsset("UI/HUD/MinDamageHUDNumber_UI.prefab")
|
||||
self.healHudPrefab = self:LoadAsset("UI/HUD/HealHUDNumber_UI.prefab")
|
||||
self.wordHudPrefab = self:LoadAsset("UI/HUD/WordHud_UI.prefab")
|
||||
self.npcHudPrefab = self:LoadAsset("UI/HUD/NpcHud.prefab")
|
||||
self.critDamageHudPrefab_Vampire = self:LoadAsset("UI/HUD/CritDamageHUDNumber_UI_Vampire.prefab")
|
||||
self.minDamageHUDNumber_Vampire = self:LoadAsset("UI/HUD/MinDamageHUDNumber_UI_Vampire.prefab")
|
||||
self.damageHudPrefab_Vampire = self:LoadAsset("UI/HUD/DamageHUDNumber_UI_Vampire.prefab")
|
||||
self.toughnessDamageHUD = self:LoadAsset("UI/HUD/ToughnessDamageHUD_UI.prefab")
|
||||
self.TEST_VISIBLE_HUD_DAMAGE = true
|
||||
local tbParam = self:GetPanelParam()
|
||||
self.isVampireInstance = tbParam[1] or false
|
||||
local bNotAdventureEnter = tbParam[2]
|
||||
if not bNotAdventureEnter then
|
||||
self._mapNode.BattleTarget.gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnDisable()
|
||||
self:Clear()
|
||||
self.playerHudPrefab = nil
|
||||
self.monsterHudPrefab = nil
|
||||
self.monsterHudEpicPrefab = nil
|
||||
self.critDamageHudPrefab = nil
|
||||
self.dotDamageHudPrefab = nil
|
||||
self.damageHudPrefab = nil
|
||||
self.minDamageHUDNumber = nil
|
||||
self.healHudPrefab = nil
|
||||
self.wordHudPrefab = nil
|
||||
self.npcHudPrefab = nil
|
||||
self.critDamageHudPrefab_Vampire = nil
|
||||
self.minDamageHUDNumber_Vampire = nil
|
||||
self.damageHudPrefab_Vampire = nil
|
||||
self.toughnessDamageHUD = nil
|
||||
end
|
||||
function HudMainCtrl:OnDestroy()
|
||||
end
|
||||
function HudMainCtrl:Clear()
|
||||
for _, v in pairs(self.playerHuds) do
|
||||
self:DespawnPrefabInstance(v, "HUD")
|
||||
end
|
||||
for _, v in pairs(self.monsterHuds) do
|
||||
self:DespawnPrefabInstance(v, "HUD")
|
||||
end
|
||||
for _, v in pairs(self.monsterAdvHuds) do
|
||||
self:DespawnPrefabInstance(v, "HUD")
|
||||
end
|
||||
for _, v in pairs(self.numberHuds) do
|
||||
self:DespawnPrefabInstance(v, "HUD")
|
||||
end
|
||||
for _, v in pairs(self.npcHuds) do
|
||||
self:DespawnPrefabInstance(v, "HUD")
|
||||
end
|
||||
for _, v in pairs(self.specialHuds) do
|
||||
self:DespawnPrefabInstance(v, "HUD")
|
||||
end
|
||||
self.hudId = 0
|
||||
self.playerHuds = {}
|
||||
self.monsterHuds = {}
|
||||
self.monsterAdvHuds = {}
|
||||
self.numberHuds = {}
|
||||
self.npcHuds = {}
|
||||
self.specialHuds = {}
|
||||
self.nBloodType = 0
|
||||
self.tbBossBloodState = {}
|
||||
self.nTypeGreyResistanceTime = {}
|
||||
self.tabToughnessEntity = {}
|
||||
self.tabToughnessEntityVal = {}
|
||||
self.tabToughnessHudId = {}
|
||||
end
|
||||
function HudMainCtrl:MonsterShowChanged(id, showed, nType, nDataId)
|
||||
local monsterHud = self.monsterHuds[id]
|
||||
if showed then
|
||||
if monsterHud == nil then
|
||||
monsterHud = self:SpawnPrefabInstance(self.monsterHudPrefab, "Game.UI.Hud.MonsterHudCtrl", "HUD", self._mapNode.Root)
|
||||
monsterHud.gameObject.transform.localScale = Vector3.one
|
||||
self.monsterHuds[id] = monsterHud
|
||||
end
|
||||
if monsterHud ~= nil then
|
||||
monsterHud:SetMonsterId(id, nType)
|
||||
local height = AdventureModuleHelper.GetEntityMonsterBarHeight(id)
|
||||
local offset = Vector3(0, height, 0)
|
||||
AdventureModuleHelper.SetHudFollowTarget(id, monsterHud.gameObject, offset, true)
|
||||
end
|
||||
elseif monsterHud ~= nil then
|
||||
self:DespawnPrefabInstance(monsterHud, "HUD")
|
||||
self.monsterHuds[id] = nil
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:MonsterAdvShowChanged(id, showed, nType, nDataId, bMultipleBoss)
|
||||
local monsterHud = self.monsterAdvHuds[id]
|
||||
local isPlayerSummoner = nType == GameEnum.monsterBloodType.PLAYERSUMMON
|
||||
if showed then
|
||||
if monsterHud == nil then
|
||||
if isPlayerSummoner then
|
||||
printLog(tostring(id) .. "player summon")
|
||||
monsterHud = self:SpawnPrefabInstance(self.playerSummonerHudPrefab, "Game.UI.Hud.PlayerSummonerHudCtrl", "HUD", self._mapNode.Root)
|
||||
else
|
||||
printLog(tostring(id) .. "monster")
|
||||
monsterHud = self:SpawnPrefabInstance(self.monsterHudEpicPrefab, "Game.UI.Hud.EliteMonsterHudCtrl", "HUD", self._mapNode.Root)
|
||||
end
|
||||
self.monsterAdvHuds[id] = monsterHud
|
||||
monsterHud.gameObject.transform.localScale = Vector3.one
|
||||
end
|
||||
if monsterHud ~= nil then
|
||||
monsterHud:SetMonsterId(id, nDataId, nType, bMultipleBoss)
|
||||
local height = AdventureModuleHelper.GetEntityMonsterBarHeight(id)
|
||||
local offset = Vector3(0, height, 0)
|
||||
AdventureModuleHelper.SetHudFollowTarget(id, monsterHud.gameObject, offset, true)
|
||||
end
|
||||
elseif monsterHud ~= nil then
|
||||
self:DespawnPrefabInstance(monsterHud, "HUD")
|
||||
self.monsterAdvHuds[id] = nil
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_ShowBossHUD(bossId, nType, showed, nDataId, nBloodType)
|
||||
self.nBloodType = nBloodType
|
||||
showed = showed and self.tbBossBloodState[bossId] == true
|
||||
self:MonsterAdvShowChanged(bossId, showed, nType, nDataId, true)
|
||||
end
|
||||
function HudMainCtrl:OnEvent_MonsterHUDChange(id, nType, showed, nDataId)
|
||||
if nType == GameEnum.monsterBloodType.BOSSRUSH or nType == GameEnum.monsterBloodType.JOINTDRILLBOSS then
|
||||
return
|
||||
end
|
||||
if nType == GameEnum.monsterBloodType.SIMPLE or nType == GameEnum.monsterBloodType.SIMPLE2 then
|
||||
self:MonsterShowChanged(id, showed, nType, nDataId)
|
||||
else
|
||||
self.tbBossBloodState[id] = showed
|
||||
if showed and (nType == GameEnum.monsterBloodType.BOSS or nType == GameEnum.monsterBloodType.MINIBOSS) and self.nBloodType == AllEnum.BossBloodType.Single then
|
||||
showed = false
|
||||
end
|
||||
self:MonsterAdvShowChanged(id, showed, nType, nDataId)
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_PlayerShowChanged(id, showed)
|
||||
if id == 0 then
|
||||
return
|
||||
end
|
||||
local playerHud = self.playerHuds[id]
|
||||
if showed then
|
||||
if playerHud == nil then
|
||||
playerHud = self:SpawnPrefabInstance(self.playerHudPrefab, "Game.UI.Hud.PlayerHudCtrl", "HUD", self._mapNode.Root)
|
||||
self.playerHuds[id] = playerHud
|
||||
playerHud.gameObject.transform.localScale = Vector3.one
|
||||
end
|
||||
if playerHud ~= nil then
|
||||
playerHud:SetPlayerId(id)
|
||||
AdventureModuleHelper.SetHudFollowTarget(id, playerHud.gameObject, Vector3.zero, false)
|
||||
end
|
||||
elseif playerHud ~= nil then
|
||||
self:DespawnPrefabInstance(playerHud, "HUD")
|
||||
self.playerHuds[id] = nil
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_AllHudShowChanged(showed)
|
||||
if self.TEST_VISIBLE_HUD_DAMAGE == true then
|
||||
self._mapNode.Root.transform.localScale = showed and Vector3.one or Vector3.zero
|
||||
else
|
||||
self._mapNode.Root.transform.localScale = Vector3.zero
|
||||
end
|
||||
if self.TEST_VISIBLE_HUD_DAMAGE == true then
|
||||
self._mapNode.DamageNumberRoot.transform.localScale = showed and Vector3.one or Vector3.zero
|
||||
self._mapNode.DamageWordRoot.transform.localScale = showed and Vector3.one or Vector3.zero
|
||||
else
|
||||
self._mapNode.DamageNumberRoot.transform.localScale = Vector3.zero
|
||||
self._mapNode.DamageWordRoot.transform.localScale = Vector3.zero
|
||||
end
|
||||
NovaAPI.SetComponentEnable(self._mapNode.BattleTarget, showed)
|
||||
end
|
||||
function HudMainCtrl:OnEvent_HudDestroyed(id)
|
||||
local hud = self.numberHuds[id]
|
||||
if hud ~= nil then
|
||||
self:DespawnPrefabInstance(hud, "HUD")
|
||||
self.numberHuds[id] = nil
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_HudDamaged(id, value, isCrit, hitDamageConfig, formId, isMark, fromElementType, hudColorIndex)
|
||||
if self.tabToughnessEntity[id] then
|
||||
self:SetToughnessValue(id, value)
|
||||
return
|
||||
end
|
||||
local hud
|
||||
if hitDamageConfig and hitDamageConfig.IsDenseType then
|
||||
if self.isVampireInstance then
|
||||
if isCrit then
|
||||
hud = self:SpawnPrefabInstance(self.critDamageHudPrefab_Vampire, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
else
|
||||
hud = self:SpawnPrefabInstance(self.minDamageHUDNumber_Vampire, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
end
|
||||
elseif isCrit then
|
||||
hud = self:SpawnPrefabInstance(self.critDamageHudPrefab, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
else
|
||||
hud = self:SpawnPrefabInstance(self.minDamageHUDNumber, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
end
|
||||
elseif self.isVampireInstance then
|
||||
if isCrit then
|
||||
hud = self:SpawnPrefabInstance(self.critDamageHudPrefab_Vampire, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
else
|
||||
hud = self:SpawnPrefabInstance(self.damageHudPrefab_Vampire, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
end
|
||||
elseif isCrit then
|
||||
hud = self:SpawnPrefabInstance(self.critDamageHudPrefab, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
else
|
||||
hud = self:SpawnPrefabInstance(self.damageHudPrefab, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
end
|
||||
self.hudId = self.hudId + 1
|
||||
local _formId = formId
|
||||
if formId == nil then
|
||||
_formId = 0
|
||||
end
|
||||
local _fromElementType = 0
|
||||
if fromElementType ~= nil then
|
||||
_fromElementType = fromElementType
|
||||
end
|
||||
local _hudColorIndex = 4
|
||||
if hudColorIndex ~= nil then
|
||||
_hudColorIndex = hudColorIndex
|
||||
end
|
||||
AdventureModuleHelper.SetHudValue(hud.gameObject, id, self.hudId, value, false, hitDamageConfig, _formId, isCrit, false, _fromElementType, _hudColorIndex)
|
||||
self.numberHuds[self.hudId] = hud
|
||||
hud.gameObject.transform:SetAsLastSibling()
|
||||
if hudColorIndex ~= nil and hudColorIndex == 5 and (self.nTypeGreyResistanceTime[id] == nil or self.nTypeGreyResistanceTime[id] + self.resistanceTipInterval <= CS.ClientManager.Instance.serverTimeStampWithTimeZone) then
|
||||
self.nTypeGreyResistanceTime[id] = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
self:OnEvent_HudDefenced(id, 3)
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_HudDotDamage(id, value, isCrit, hitDamageConfig, formId, hudColorIndex, fromElementType)
|
||||
if self.tabToughnessEntity[id] then
|
||||
self:SetToughnessValue(id, value)
|
||||
return
|
||||
end
|
||||
local hud = self:SpawnPrefabInstance(self.dotDamageHudPrefab, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
self.hudId = self.hudId + 1
|
||||
local _formId = formId
|
||||
if formId == nil then
|
||||
_formId = 0
|
||||
end
|
||||
local _fromElementType = 0
|
||||
if fromElementType ~= nil then
|
||||
_fromElementType = fromElementType
|
||||
end
|
||||
AdventureModuleHelper.SetHudValue(hud.gameObject, id, self.hudId, value, false, hitDamageConfig, _formId, isCrit, true, _fromElementType, hudColorIndex)
|
||||
self.numberHuds[self.hudId] = hud
|
||||
hud.gameObject.transform:SetAsLastSibling()
|
||||
end
|
||||
function HudMainCtrl:OnEvent_HudHealed(id, value)
|
||||
local hud = self:SpawnPrefabInstance(self.healHudPrefab, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
self.hudId = self.hudId + 1
|
||||
AdventureModuleHelper.SetHudValue(hud.gameObject, id, self.hudId, value, true, nil, 0, false, false)
|
||||
self.numberHuds[self.hudId] = hud
|
||||
hud.gameObject.transform:SetAsLastSibling()
|
||||
end
|
||||
function HudMainCtrl:OnEvent_HudDefenced(id, valueType)
|
||||
local nWordType
|
||||
local hud = self:SpawnPrefabInstance(self.wordHudPrefab, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageWordRoot)
|
||||
self.hudId = self.hudId + 1
|
||||
local value = ""
|
||||
if valueType == 1 then
|
||||
nWordType = 8
|
||||
value = ConfigTable.GetUIText("Hud_Missing_Tip")
|
||||
elseif valueType == 2 then
|
||||
nWordType = 7
|
||||
value = ConfigTable.GetUIText("Hud_Immunity_Tip")
|
||||
elseif valueType == 3 then
|
||||
nWordType = 9
|
||||
value = ConfigTable.GetUIText("Hud_Resistance_Tip")
|
||||
end
|
||||
AdventureModuleHelper.SetHudStringValue(hud.gameObject, id, self.hudId, value, nWordType, false)
|
||||
self.numberHuds[self.hudId] = hud
|
||||
hud.gameObject.transform:SetAsLastSibling()
|
||||
end
|
||||
function HudMainCtrl:OnEvent_HudMark(id, valueType, stringKey)
|
||||
local nWordType = valueType
|
||||
local hud = self:SpawnPrefabInstance(self.wordHudPrefab, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageWordRoot)
|
||||
self.hudId = self.hudId + 1
|
||||
local value = ConfigTable.GetUIText(stringKey)
|
||||
AdventureModuleHelper.SetHudStringValue(hud.gameObject, id, self.hudId, value, nWordType, false)
|
||||
self.numberHuds[self.hudId] = hud
|
||||
hud.gameObject.transform:SetAsLastSibling()
|
||||
end
|
||||
function HudMainCtrl:OnEvent_LevelEnd()
|
||||
self:Clear()
|
||||
end
|
||||
function HudMainCtrl:OnEvent_NPCShow(bShow, id, uid, nCostCount, nHasCount)
|
||||
if id == 0 then
|
||||
return
|
||||
end
|
||||
local npcHud = self.npcHuds[uid]
|
||||
if bShow then
|
||||
if npcHud == nil then
|
||||
npcHud = self:SpawnPrefabInstance(self.npcHudPrefab, "Game.UI.Hud.NpcHudCtrl", "HUD", self._mapNode.Root)
|
||||
self.npcHuds[uid] = npcHud
|
||||
end
|
||||
if npcHud ~= nil then
|
||||
npcHud:ShowNpc(id, uid, nCostCount, nHasCount)
|
||||
end
|
||||
elseif npcHud ~= nil then
|
||||
npcHud:HideNpc()
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_HuoChuiBossShow(bShow, id, nInitValue, nInitState)
|
||||
local huoChuiHudPrefab = self:LoadAsset("UI/HUD/HudHuoChuiBoss.prefab")
|
||||
if id == 0 then
|
||||
return
|
||||
end
|
||||
local specialHud = self.specialHuds[id]
|
||||
if bShow then
|
||||
if specialHud == nil then
|
||||
specialHud = self:SpawnPrefabInstance(huoChuiHudPrefab, "Game.UI.Hud.HuoChuiHudCtrl", "HUD", self._mapNode.Root)
|
||||
self.specialHuds[id] = specialHud
|
||||
end
|
||||
if specialHud ~= nil then
|
||||
specialHud:SetMonsterId(id, nInitValue, nInitState)
|
||||
AdventureModuleHelper.SetHudFollowTarget(id, specialHud.gameObject, Vector3.zero, true)
|
||||
end
|
||||
elseif specialHud ~= nil then
|
||||
specialHud:Hide()
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_SwitchHudDamage()
|
||||
local x = self._mapNode.DamageNumberRoot.transform.localScale.x
|
||||
if 0 < x then
|
||||
self.TEST_VISIBLE_HUD_DAMAGE = false
|
||||
self._mapNode.DamageNumberRoot.transform.localScale = Vector3.zero
|
||||
self._mapNode.DamageWordRoot.transform.localScale = Vector3.zero
|
||||
else
|
||||
self.TEST_VISIBLE_HUD_DAMAGE = true
|
||||
self._mapNode.DamageNumberRoot.transform.localScale = Vector3.one
|
||||
self._mapNode.DamageWordRoot.transform.localScale = Vector3.one
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_SwitchHudHpBar()
|
||||
local x = self._mapNode.Root.transform.localScale.x
|
||||
if 0 < x then
|
||||
self._mapNode.Root.transform.localScale = Vector3.zero
|
||||
self._mapNode.BattleTarget.transform.localScale = Vector3.zero
|
||||
else
|
||||
self._mapNode.Root.transform.localScale = Vector3.one
|
||||
self._mapNode.BattleTarget.transform.localScale = Vector3.one
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_AdventureModuleEnter()
|
||||
self._mapNode.BattleTarget.gameObject:SetActive(true)
|
||||
end
|
||||
function HudMainCtrl:OnEvent_CacheInstanceHud(count)
|
||||
local wait = function()
|
||||
local tmpIndex = 0
|
||||
for i = 1, count do
|
||||
tmpIndex = tmpIndex - 1
|
||||
local hud = self:SpawnPrefabInstance(self.critDamageHudPrefab_Vampire, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
self.numberHuds[tmpIndex] = hud
|
||||
end
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
for i = 1, count do
|
||||
tmpIndex = tmpIndex - 1
|
||||
local hud = self:SpawnPrefabInstance(self.minDamageHUDNumber_Vampire, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
self.numberHuds[tmpIndex] = hud
|
||||
end
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
for i = 1, count do
|
||||
tmpIndex = tmpIndex - 1
|
||||
local hud = self:SpawnPrefabInstance(self.damageHudPrefab_Vampire, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
self.numberHuds[tmpIndex] = hud
|
||||
end
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self:Clear()
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function HudMainCtrl:OnEvent_ToughnessStateChangedForGlobal(id, toughnessBroken)
|
||||
if toughnessBroken then
|
||||
self.tabToughnessEntity[id] = true
|
||||
else
|
||||
self:DestroyToughnessHud(id)
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:OnEvent_MonsterDeclareDied(id)
|
||||
self:DestroyToughnessHud(id)
|
||||
end
|
||||
function HudMainCtrl:DestroyToughnessHud(id)
|
||||
if self.tabToughnessEntity[id] ~= nil then
|
||||
self.tabToughnessEntity[id] = nil
|
||||
self.tabToughnessEntityVal[id] = nil
|
||||
local hud = self.numberHuds[self.tabToughnessHudId[id]]
|
||||
local tmpHudId = self.tabToughnessHudId[id]
|
||||
self.tabToughnessHudId[id] = nil
|
||||
if hud ~= nil then
|
||||
do
|
||||
local hudAni = hud.gameObject:GetComponent("Animator")
|
||||
hudAni:Play("ToughnessDamageHUD_out")
|
||||
CS.WwiseAudioManager.Instance:PlaySound("ui_battle_boss_poRen_hitValue")
|
||||
self:AddTimer(1, 1.45, function()
|
||||
self:OnEvent_HudDestroyed(tmpHudId)
|
||||
end, true, true, true, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function HudMainCtrl:SetToughnessValue(id, val)
|
||||
if self.tabToughnessHudId[id] == nil then
|
||||
local hud = self:SpawnPrefabInstance(self.toughnessDamageHUD, "Game.UI.Hud.HudNumberCtrl", "HUD", self._mapNode.DamageNumberRoot)
|
||||
self.hudId = self.hudId + 1
|
||||
self.tabToughnessEntityVal[id] = val
|
||||
local texTotal = hud.gameObject.transform:Find("text1/Title/texTotal"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(texTotal, ConfigTable.GetUIText("Hud_Total_Damage"))
|
||||
AdventureModuleHelper.SetHudToughnessDamageValue(hud.gameObject, id, self.hudId, val, false, false)
|
||||
self.numberHuds[self.hudId] = hud
|
||||
self.tabToughnessHudId[id] = self.hudId
|
||||
hud.gameObject.transform:SetAsLastSibling()
|
||||
local hudAni = hud.gameObject:GetComponent("Animator")
|
||||
hudAni:Play("ToughnessDamageHUD_in")
|
||||
else
|
||||
local hud = self.numberHuds[self.tabToughnessHudId[id]]
|
||||
if hud ~= nil then
|
||||
self.tabToughnessEntityVal[id] = self.tabToughnessEntityVal[id] + val
|
||||
AdventureModuleHelper.SetHudToughnessDamageValue(hud.gameObject, id, self.hudId, self.tabToughnessEntityVal[id], false, true)
|
||||
local texAin = hud.gameObject.transform:Find("text1"):GetComponent("Animator")
|
||||
texAin:Play("ToughnessDamageHUD_up")
|
||||
end
|
||||
end
|
||||
end
|
||||
return HudMainCtrl
|
||||
@@ -0,0 +1,12 @@
|
||||
local HudNumberCtrl = class("HudNumberCtrl", BaseCtrl)
|
||||
HudNumberCtrl._mapNodeConfig = {}
|
||||
HudNumberCtrl._mapEventConfig = {}
|
||||
function HudNumberCtrl:Awake()
|
||||
end
|
||||
function HudNumberCtrl:OnEnable()
|
||||
end
|
||||
function HudNumberCtrl:OnDisable()
|
||||
end
|
||||
function HudNumberCtrl:OnDestroy()
|
||||
end
|
||||
return HudNumberCtrl
|
||||
@@ -0,0 +1,11 @@
|
||||
local HudPanel = class("HudPanel", BasePanel)
|
||||
HudPanel._bAddToBackHistory = false
|
||||
HudPanel._bIsMainPanel = false
|
||||
HudPanel._sSortingLayerName = AllEnum.SortingLayerName.HUD
|
||||
HudPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "HUD/HUDROOT.prefab",
|
||||
sCtrlName = "Game.UI.Hud.HudMainCtrl"
|
||||
}
|
||||
}
|
||||
return HudPanel
|
||||
@@ -0,0 +1,178 @@
|
||||
local HuoChuiHudCtrl = class("HuoChuiHudCtrl", BaseCtrl)
|
||||
local nRotateMax = 0
|
||||
local nRotateMin = 45
|
||||
local nAnimTime = 0.2
|
||||
HuoChuiHudCtrl._mapNodeConfig = {
|
||||
imgFill1 = {},
|
||||
imgFill2 = {},
|
||||
imgBarLight = {},
|
||||
TMPValue = {sComponentName = "TMP_Text"},
|
||||
goRotationRoot = {
|
||||
sComponentName = "HpBarRotation"
|
||||
},
|
||||
goState33 = {},
|
||||
goState66 = {},
|
||||
goHotState = {},
|
||||
rtRoot = {sComponentName = "Animator"},
|
||||
AniTMPValue = {sNodeName = "TMPValue", sComponentName = "Animator"},
|
||||
imgFill3 = {
|
||||
sComponentName = "HpBarCanvasGroup"
|
||||
},
|
||||
imgFill3CG = {
|
||||
sNodeName = "imgFill3",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
imgBarLight1 = {
|
||||
sComponentName = "HpBarCanvasGroup"
|
||||
},
|
||||
imgBarLight1CG = {
|
||||
sNodeName = "imgBarLight1",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
imgHighlight = {}
|
||||
}
|
||||
HuoChuiHudCtrl._mapEventConfig = {}
|
||||
HuoChuiHudCtrl._mapRedDotConfig = {}
|
||||
function HuoChuiHudCtrl:Awake()
|
||||
self.nHotValue = 0
|
||||
self.nState = 1
|
||||
self.showState = 1
|
||||
end
|
||||
function HuoChuiHudCtrl:SetMonsterId(nId, nInitValue, nInitState)
|
||||
if self.nMonsterId ~= nil then
|
||||
printError("重复绑定:" .. nId)
|
||||
return
|
||||
end
|
||||
self.monsterId = nId
|
||||
self.nHotValue = nInitValue
|
||||
self.nState = nInitState
|
||||
self.gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPValue, self.nHotValue)
|
||||
self._mapNode.goRotationRoot.transform.localEulerAngles = Vector3.zero
|
||||
local target = -45 * self.nHotValue / 100 + 45
|
||||
if target < 0 then
|
||||
target = 0
|
||||
end
|
||||
if 45 < target then
|
||||
target = 45
|
||||
end
|
||||
self._mapNode.goRotationRoot:SetTarget(target, 0, 0)
|
||||
self._mapNode.imgHighlight:SetActive(self.nHotValue ~= 0 and self.nHotValue ~= 100)
|
||||
self:OnEvent_StageChange(nInitValue)
|
||||
EventManager.AddEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("HotValueChange", self.monsterId, self, self.OnEvent_ValueChange)
|
||||
EventManager.AddEntityEvent("HotStateChange", self.monsterId, self, self.OnEvent_StageChange)
|
||||
end
|
||||
function HuoChuiHudCtrl:Hide()
|
||||
self.monsterId = nil
|
||||
self.gameObject:SetActive(false)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ValueChange", self.monsterId, self, self.OnEvent_ValueChange)
|
||||
EventManager.RemoveEntityEvent("StateChange", self.monsterId, self, self.OnEvent_StageChange)
|
||||
end
|
||||
function HuoChuiHudCtrl:FadeIn()
|
||||
end
|
||||
function HuoChuiHudCtrl:FadeOut()
|
||||
end
|
||||
function HuoChuiHudCtrl:OnEnable()
|
||||
end
|
||||
function HuoChuiHudCtrl:OnDisable()
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ValueChange", self.monsterId, self, self.OnEvent_ValueChange)
|
||||
EventManager.RemoveEntityEvent("StateChange", self.monsterId, self, self.OnEvent_StageChange)
|
||||
end
|
||||
function HuoChuiHudCtrl:ChangeState1()
|
||||
self._mapNode.goState33:SetActive(false)
|
||||
self._mapNode.goState66:SetActive(false)
|
||||
self._mapNode.goHotState:SetActive(false)
|
||||
end
|
||||
function HuoChuiHudCtrl:ChangeState2()
|
||||
self._mapNode.goState33:SetActive(true)
|
||||
self._mapNode.goState66:SetActive(false)
|
||||
self._mapNode.goHotState:SetActive(false)
|
||||
end
|
||||
function HuoChuiHudCtrl:ChangeState3()
|
||||
self._mapNode.goState33:SetActive(false)
|
||||
self._mapNode.goState66:SetActive(true)
|
||||
self._mapNode.goHotState:SetActive(false)
|
||||
end
|
||||
function HuoChuiHudCtrl:ChangeStateHot()
|
||||
self._mapNode.goState33:SetActive(false)
|
||||
self._mapNode.goState66:SetActive(false)
|
||||
self._mapNode.goHotState:SetActive(true)
|
||||
end
|
||||
function HuoChuiHudCtrl:OnDestroy()
|
||||
end
|
||||
function HuoChuiHudCtrl:OnRelease()
|
||||
end
|
||||
function HuoChuiHudCtrl:SetState(nBeforeValue, nCurValue)
|
||||
if nBeforeValue < 33 and 33 <= nCurValue or nBeforeValue < 66 and 66 <= nCurValue then
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.imgFill3CG, 1)
|
||||
self._mapNode.imgFill3:SetTarget(0, 0.8, 0)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.imgBarLight1CG, 1)
|
||||
self._mapNode.imgBarLight1:SetTarget(0, 0.8, 0)
|
||||
end
|
||||
if self.nState ~= 3 then
|
||||
if nCurValue < 33 and self.showState ~= 1 then
|
||||
self.showState = 1
|
||||
self:ChangeState1()
|
||||
elseif nCurValue < 66 and self.showState ~= 2 then
|
||||
self.showState = 2
|
||||
self:ChangeState2()
|
||||
elseif 66 <= nCurValue and self.showState ~= 3 then
|
||||
self.showState = 3
|
||||
self:ChangeState3()
|
||||
end
|
||||
end
|
||||
end
|
||||
function HuoChuiHudCtrl:OnEvent_Deaded()
|
||||
self.monsterId = nil
|
||||
self.gameObject:SetActive(false)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ValueChange", self.monsterId, self, self.OnEvent_ValueChange)
|
||||
EventManager.RemoveEntityEvent("StateChange", self.monsterId, self, self.OnEvent_StageChange)
|
||||
end
|
||||
function HuoChuiHudCtrl:OnEvent_ValueChange(nValue)
|
||||
local nBeforValue = self.nHotValue
|
||||
local nCurAngle = -45 * self.nHotValue / 100 + 45
|
||||
local nCurValue = nValue
|
||||
self._mapNode.goRotationRoot.transform.localEulerAngles = Vector3(0, 0, nCurAngle)
|
||||
self.nHotValue = nValue
|
||||
local nTarget = -45 * self.nHotValue / 100 + 45
|
||||
if nTarget < 0 then
|
||||
nTarget = 0
|
||||
end
|
||||
if 45 < nTarget then
|
||||
nTarget = 45
|
||||
end
|
||||
self._mapNode.goRotationRoot:SetTarget(nTarget, nCurAngle, nAnimTime, 0)
|
||||
NovaAPI.SetTMPText(self._mapNode.TMPValue, self.nHotValue)
|
||||
if nBeforValue ~= 100 and self.nHotValue == 100 then
|
||||
self._mapNode.AniTMPValue:Play("HudHuoChuiBoss_TMPValue")
|
||||
end
|
||||
self:SetState(nBeforValue, nCurValue)
|
||||
self._mapNode.imgHighlight:SetActive(self.nHotValue ~= 0 and self.nHotValue ~= 100)
|
||||
end
|
||||
function HuoChuiHudCtrl:OnEvent_StageChange(nState)
|
||||
self.nState = nState
|
||||
if self.nState == 3 then
|
||||
self._mapNode.imgFill1:SetActive(false)
|
||||
self._mapNode.imgFill2:SetActive(true)
|
||||
self._mapNode.imgBarLight:SetActive(true)
|
||||
self:ChangeStateHot()
|
||||
else
|
||||
if self.nState == 2 then
|
||||
self._mapNode.rtRoot:Play("HudHuoChuiBoss_die")
|
||||
end
|
||||
self._mapNode.imgFill1:SetActive(true)
|
||||
self._mapNode.imgFill2:SetActive(false)
|
||||
self._mapNode.imgBarLight:SetActive(false)
|
||||
self.showState = 0
|
||||
self:SetState(0, self.nHotValue)
|
||||
end
|
||||
end
|
||||
return HuoChuiHudCtrl
|
||||
@@ -0,0 +1,409 @@
|
||||
local MonsterHudCtrl = class("MonsterHudCtrl", BaseCtrl)
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local BarHeight = 21
|
||||
local BarWidth = 139
|
||||
local ShieldWidth = 103
|
||||
local AniTimeHighlight = 0.5
|
||||
local AniTime = 0.16
|
||||
local ToughnessRecoverTime = 0.3
|
||||
local ToughnessWidth = 208
|
||||
local ToughnessHeight = 21
|
||||
local colorHide = Color(1, 1, 1, 0)
|
||||
local colorWhite = Color(1, 1, 1, 1)
|
||||
local colorShieldDelay = Color(1, 1, 1, 0.5)
|
||||
local colorRed = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 1)
|
||||
local colorRedHide = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 0)
|
||||
local colorRecover = Color(0.9921568627450981, 0.5098039215686274, 0, 1)
|
||||
MonsterHudCtrl._mapNodeConfig = {
|
||||
rtHpFillDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
aniRtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelayHighlight = {
|
||||
sNodeName = "imgHpDelayHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillHighLight = {
|
||||
sNodeName = "imgHpHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillRecoverLight = {
|
||||
sNodeName = "imgHpFillRecoverLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtShield = {},
|
||||
rtShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldDelay = {sComponentName = "Image"},
|
||||
ainColorShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtShieldFill = {
|
||||
sNodeName = "imgShieldFill",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtShieldFill = {
|
||||
sNodeName = "imgShieldFill",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldFillHighLight = {sComponentName = "Image"},
|
||||
ainColorShieldFillHighLight = {
|
||||
sNodeName = "imgShieldFillHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtToughness = {},
|
||||
rtNormal = {},
|
||||
imgBroken = {},
|
||||
imgToughnessMaskDelay = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
imgToughnessMask = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtHighlight = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
Highlight = {
|
||||
sNodeName = "rtHighlight",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
imgBrokenChip = {sComponentName = "Image"},
|
||||
aniRtToughnessDelay = {
|
||||
sNodeName = "imgToughnessMaskDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
aniRtToughnessFill = {
|
||||
sNodeName = "imgToughnessMask",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorToughnessHighlight = {
|
||||
sNodeName = "rtHighlight",
|
||||
sComponentName = "HpBarCanvasGroup"
|
||||
},
|
||||
ainColorToughnessBrokenChip = {
|
||||
sNodeName = "imgBrokenChip",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
rtShakeRoot = {sComponentName = "Animator"},
|
||||
aniFadeHpBar = {
|
||||
sNodeName = "rtShakeRoot",
|
||||
sComponentName = "HpBarCanvasGroup"
|
||||
},
|
||||
rtBuff = {
|
||||
sCtrlName = "Game.UI.Hud.Buff.BuffCtrl"
|
||||
}
|
||||
}
|
||||
MonsterHudCtrl._mapEventConfig = {}
|
||||
function MonsterHudCtrl:PlayTweenHp(hp, hpMax)
|
||||
local nWidth = 1 <= hp / hpMax and BarWidth or hp / hpMax * BarWidth
|
||||
if nWidth > BarWidth then
|
||||
nWidth = BarWidth
|
||||
end
|
||||
if hp < self.nBeforeHp then
|
||||
if self._mapNode.rtHpFill.sizeDelta.x > self._mapNode.rtHpFillDelay.sizeDelta.x then
|
||||
self._mapNode.aniRtHpDelay:SetTarget(self._mapNode.rtHpFill.sizeDelta, 0)
|
||||
end
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeHp - hp) / hpMax > self.bigDamageThreshold then
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0.1, AniTime)
|
||||
delayTime = 0.5
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime, delayTime)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + delayTime)
|
||||
else
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = self._mapNode.rtHpFill.sizeDelta
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, AniTime)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, AniTimeHighlight)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRecover)
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), AniTime, AniTime)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorRed, 0)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorRedHide, AniTimeHighlight, AniTime)
|
||||
end
|
||||
end
|
||||
function MonsterHudCtrl:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
local nWidth = 1 <= shieldValue / shieldValueMax and ShieldWidth or shieldValue / shieldValueMax * ShieldWidth
|
||||
if shieldValue < self.nBeforeShield then
|
||||
if self._mapNode.rtShieldDelay.sizeDelta.x < self._mapNode.rtShieldFill.sizeDelta.x then
|
||||
self._mapNode.rtShieldDelay.sizeDelta = self._mapNode.rtShieldFill.sizeDelta
|
||||
end
|
||||
self._mapNode.rtShieldFill.sizeDelta = Vector2(nWidth, BarHeight)
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldFillHighLight, colorWhite)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeShield - shieldValue) / shieldValueMax > self.bigDamageThreshold then
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldDelay, colorWhite)
|
||||
self._mapNode.ainColorShieldDelay:SetTarget(colorShieldDelay, 0.1, AniTime)
|
||||
delayTime = 0.5
|
||||
end
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime, delayTime)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + delayTime)
|
||||
else
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldFillHighLight, colorWhite)
|
||||
self._mapNode.ainColorShieldDelay:SetTarget(colorShieldDelay, 0)
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + AniTime)
|
||||
end
|
||||
end
|
||||
function MonsterHudCtrl:KillTweenToughness()
|
||||
self._mapNode.aniRtToughnessDelay:Stop()
|
||||
self._mapNode.aniRtToughnessFill:Stop()
|
||||
self._mapNode.ainColorToughnessHighlight:Stop()
|
||||
end
|
||||
function MonsterHudCtrl:PlayTweenToughness(toughness, toughnessMax)
|
||||
self:KillTweenToughness()
|
||||
local nWidth = 1 <= toughness / toughnessMax and ToughnessWidth or toughness / toughnessMax * ToughnessWidth
|
||||
if nWidth > ToughnessWidth then
|
||||
nWidth = ToughnessWidth
|
||||
end
|
||||
if self._mapNode.imgToughnessMaskDelay.sizeDelta.x < self._mapNode.imgToughnessMask.sizeDelta.x then
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = self._mapNode.imgToughnessMask.sizeDelta
|
||||
end
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0 < nWidth and nWidth or 0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(0 < nWidth and nWidth - 12 or 0, 0)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeToughness - toughness) / toughnessMax > self.bigDamageThreshold then
|
||||
delayTime = 0.5
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 1)
|
||||
self._mapNode.ainColorToughnessHighlight:SetTarget(0, AniTime, delayTime + AniTime)
|
||||
self._mapNode.aniRtToughnessDelay:SetTarget(Vector2(nWidth, ToughnessHeight), AniTime, delayTime)
|
||||
end
|
||||
function MonsterHudCtrl:PlayTweenToughnessBroken()
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(0, 0)
|
||||
self._mapNode.rtNormal:SetActive(false)
|
||||
self._mapNode.imgBroken:SetActive(true)
|
||||
self._mapNode.ainColorToughnessBrokenChip:Play("imgBrokenChip_in")
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
function MonsterHudCtrl:PlayTweenToughnessRecover()
|
||||
self:KillTweenToughness()
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(ToughnessWidth - 12, 0)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 0)
|
||||
self._mapNode.rtNormal:SetActive(true)
|
||||
self._mapNode.imgBroken:SetActive(false)
|
||||
self.tweenerToughness3 = self._mapNode.aniRtToughnessFill:SetTarget(Vector2(ToughnessWidth, ToughnessHeight), ToughnessRecoverTime)
|
||||
end
|
||||
function MonsterHudCtrl:ResetHit()
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, 0)
|
||||
self.nBeforeHp = 0
|
||||
self.nBeforeHpMax = 0
|
||||
self.nBeforeShield1 = 0
|
||||
self.nBeforeShield2 = 0
|
||||
self.nBeforeShield3 = 0
|
||||
self.nBeforeShield4 = 0
|
||||
self.nBeforeToughness = 0
|
||||
self._mapNode.rtNormal:SetActive(true)
|
||||
self._mapNode.imgBroken:SetActive(false)
|
||||
end
|
||||
function MonsterHudCtrl:KillTween()
|
||||
self._mapNode.aniRtHpDelay:Stop()
|
||||
self._mapNode.ainColorHpDelay:Stop()
|
||||
self._mapNode.aniRtHpFill:Stop()
|
||||
self._mapNode.ainColorHpDelayHighlight:Stop()
|
||||
self._mapNode.ainColorHpFillHighLight:Stop()
|
||||
self._mapNode.ainColorHpFillRecoverLight:Stop()
|
||||
self._mapNode.aniRtShieldDelay:Stop()
|
||||
self._mapNode.ainColorShieldDelay:Stop()
|
||||
self._mapNode.aniRtShieldFill:Stop()
|
||||
self._mapNode.ainColorShieldFillHighLight:Stop()
|
||||
self._mapNode.aniRtToughnessDelay:Stop()
|
||||
self._mapNode.aniRtToughnessFill:Stop()
|
||||
self._mapNode.ainColorToughnessHighlight:Stop()
|
||||
end
|
||||
function MonsterHudCtrl:Awake()
|
||||
self.monsterId = 0
|
||||
self.bigDamageThreshold = ConfigTable.GetConfigNumber("BloodSpecialEffectThresholdValue") / 100
|
||||
self._Timer = nil
|
||||
end
|
||||
function MonsterHudCtrl:OnEnable()
|
||||
self.monsterId = 0
|
||||
self:ResetHit()
|
||||
end
|
||||
function MonsterHudCtrl:OnDisable()
|
||||
self._mapNode.rtBuff:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
self.monsterId = 0
|
||||
self:KillTween()
|
||||
self:ResetHit()
|
||||
end
|
||||
function MonsterHudCtrl:OnDestroy()
|
||||
end
|
||||
function MonsterHudCtrl:HideHpBar()
|
||||
self._mapNode.aniFadeHpBar:SetTarget(0, 0.5)
|
||||
end
|
||||
function MonsterHudCtrl:SetMonsterId(monsterId, nType)
|
||||
if self.monsterId == monsterId then
|
||||
return
|
||||
end
|
||||
if nType == GameEnum.monsterBloodType.SIMPLE then
|
||||
self._Timer = self:AddTimer(1, 5, "HideHpBar", false, false, true, nil)
|
||||
self._mapNode.aniFadeHpBar:SetTarget(0)
|
||||
else
|
||||
self._mapNode.aniFadeHpBar:SetTarget(1)
|
||||
self._Timer = nil
|
||||
end
|
||||
self.monsterId = monsterId
|
||||
self.nType = nType
|
||||
self:ResetHit()
|
||||
self:KillTween()
|
||||
local hp = AdventureModuleHelper.GetEntityHp(self.monsterId)
|
||||
local hpMax = AdventureModuleHelper.GetEntityMaxHp(self.monsterId)
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.one
|
||||
local toughness = AdventureModuleHelper.GetMonsterToughness(self.monsterId)
|
||||
local toughnessMax = AdventureModuleHelper.GetMonsterToughnessMax(self.monsterId)
|
||||
self:SetHp(hp, hpMax, true)
|
||||
self:SetToughness(toughness, toughnessMax, false, true)
|
||||
local shieldValue, shieldValueMax = AdventureModuleHelper.GetEntityShieldValue(self.monsterId)
|
||||
self:SetShield(shieldValue, shieldValueMax, true)
|
||||
self._mapNode.rtBuff:BindEntity(self.monsterId)
|
||||
EventManager.AddEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.AddEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
end
|
||||
function MonsterHudCtrl:SetHp(hp, hpMax, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if hpMax <= 0 then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(0, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(0, BarHeight)
|
||||
elseif bChange then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
else
|
||||
self:PlayTweenHp(hp, hpMax)
|
||||
end
|
||||
self.nBeforeHp = hp
|
||||
self.nBeforeHpMax = hpMax
|
||||
end
|
||||
function MonsterHudCtrl:SetToughness(toughness, toughnessMax, bState, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if toughnessMax <= 0 then
|
||||
self._mapNode.rtToughness:SetActive(false)
|
||||
elseif bChange then
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(toughness / toughnessMax * ToughnessWidth, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(toughness / toughnessMax * ToughnessWidth, ToughnessHeight)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 0)
|
||||
elseif bState then
|
||||
if toughness == 0 then
|
||||
self:PlayTweenToughnessBroken()
|
||||
else
|
||||
self:PlayTweenToughnessRecover()
|
||||
end
|
||||
else
|
||||
self:PlayTweenToughness(toughness, toughnessMax)
|
||||
end
|
||||
self.nBeforeToughness = toughness
|
||||
end
|
||||
function MonsterHudCtrl:OnEvent_HpChanged(hp, hpMax)
|
||||
if hp == self.nBeforeHp then
|
||||
self:SetHp(hp, hpMax, true)
|
||||
else
|
||||
self:SetHp(hp, hpMax)
|
||||
self._mapNode.aniFadeHpBar:SetTarget(1)
|
||||
if self._Timer ~= nil then
|
||||
self._Timer:Reset()
|
||||
end
|
||||
end
|
||||
end
|
||||
function MonsterHudCtrl:OnEvent_ShieldChanged(value1, value2)
|
||||
if value1 == self.nBeforeShield then
|
||||
self:SetShield(value1, value2, true)
|
||||
else
|
||||
self:SetShield(value1, value2)
|
||||
self._mapNode.aniFadeHpBar:SetTarget(1)
|
||||
if self._Timer ~= nil then
|
||||
self._Timer:Reset()
|
||||
end
|
||||
end
|
||||
end
|
||||
function MonsterHudCtrl:OnEvent_ToughnessStateChanged(bBroken, nValue, nToughnessMax)
|
||||
if bBroken then
|
||||
self:SetToughness(0, nToughnessMax, true)
|
||||
elseif nValue ~= 0 then
|
||||
self:SetToughness(nToughnessMax, nToughnessMax, true)
|
||||
end
|
||||
end
|
||||
function MonsterHudCtrl:OnEvent_ToughnessValueChanged(toughness, toughnessMax)
|
||||
self:SetToughness(toughness, toughnessMax, false)
|
||||
end
|
||||
function MonsterHudCtrl:OnEvent_ToughnessShowStateChanged(bShow)
|
||||
if bShow then
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.one
|
||||
else
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.zero
|
||||
end
|
||||
end
|
||||
function MonsterHudCtrl:SetShield(shieldValue, shieldValueMax, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if shieldValue <= 0 then
|
||||
self._mapNode.rtShield:SetActive(false)
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(0, BarHeight), 0)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(0, BarHeight), 0)
|
||||
elseif bChange then
|
||||
self._mapNode.rtShield:SetActive(true)
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(shieldValue / shieldValueMax * ShieldWidth, BarHeight), 0)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(shieldValue / shieldValueMax * ShieldWidth, BarHeight), 0)
|
||||
else
|
||||
self._mapNode.rtShield:SetActive(true)
|
||||
self:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
end
|
||||
self.nBeforeShield = shieldValue
|
||||
self.nBeforeShieldMax = shieldValueMax
|
||||
end
|
||||
function MonsterHudCtrl:OnEvent_Deaded()
|
||||
self._mapNode.rtBuff:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.Hit("MonsterHUDChange", self.monsterId, self.nType, false)
|
||||
end
|
||||
return MonsterHudCtrl
|
||||
@@ -0,0 +1,170 @@
|
||||
local NpcHudCtrl = class("NpcHudCtrl", BaseCtrl)
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
NpcHudCtrl._mapNodeConfig = {
|
||||
rtRoot = {},
|
||||
rtTop = {},
|
||||
rtNpc = {},
|
||||
rtChat = {},
|
||||
txtChat = {sComponentName = "TMP_Text"},
|
||||
txtNPCType = {sComponentName = "TMP_Text"},
|
||||
rtStrength = {},
|
||||
txtStrength = {sComponentName = "TMP_Text"},
|
||||
rtCost = {},
|
||||
txtCost = {sComponentName = "TMP_Text"},
|
||||
imgCost = {sComponentName = "Image"},
|
||||
rtFree = {},
|
||||
txtFree = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "ST_StrengthenMachine_Free"
|
||||
},
|
||||
rtBottom = {},
|
||||
txtNPCName = {sComponentName = "TMP_Text"},
|
||||
txtNPCTag = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
NpcHudCtrl._mapEventConfig = {
|
||||
RefreshStarTowerCoin = "OnEvent_RefreshStarTowerCoin",
|
||||
InteractiveNpc = "OnEvent_InteractiveNpc",
|
||||
InteractiveNpcFinish = "OnEvent_InteractiveNpcFinish"
|
||||
}
|
||||
local colorGreen = Color(0.9803921568627451, 0.9803921568627451, 0.9803921568627451, 1)
|
||||
local colorRed = Color(1.0, 0.44313725490196076, 0.5411764705882353, 1)
|
||||
local nInterval = 0.2
|
||||
local chatMinTime = 1
|
||||
local chatMaxTime = 4
|
||||
function NpcHudCtrl:CalChatContentShowTime(sContent)
|
||||
local sPureContent = string.gsub(sContent, "<.->", "")
|
||||
sPureContent = string.gsub(sPureContent, "\n", "")
|
||||
local nDuration = string.utf8len(sPureContent) * nInterval
|
||||
nDuration = math.min(chatMaxTime, nDuration)
|
||||
nDuration = math.max(chatMinTime, nDuration)
|
||||
return nDuration
|
||||
end
|
||||
function NpcHudCtrl:ShowStrengthNpc(sName, nCostCount, nHasCount)
|
||||
self._mapNode.rtStrength.gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtStrength, sName)
|
||||
self.nCostCount = nCostCount
|
||||
self:RefreshStrengthCost(nHasCount)
|
||||
end
|
||||
function NpcHudCtrl:RefreshStrengthCost(nHasCount)
|
||||
self._mapNode.rtCost.gameObject:SetActive(self.nCostCount > 0)
|
||||
self._mapNode.rtFree.gameObject:SetActive(self.nCostCount <= 0)
|
||||
if self.nCostCount > 0 then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCost, self.nCostCount)
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtCost, nHasCount >= self.nCostCount and colorGreen or colorRed)
|
||||
self:SetSprite_Coin(self._mapNode.imgCost, AllEnum.CoinItemId.FixedRogCurrency)
|
||||
end
|
||||
end
|
||||
function NpcHudCtrl:ShowNpc(nId, nUId, nCostCount, nHasCount)
|
||||
self.nNpcId = nId
|
||||
self.nNpcUId = nUId
|
||||
self.nCostCount = nCostCount
|
||||
self:Clear()
|
||||
local mapNpcCfg = ConfigTable.GetData("NPCConfig", nId)
|
||||
if mapNpcCfg ~= nil then
|
||||
self._mapNode.rtRoot.gameObject:SetActive(true)
|
||||
self.tbChatPool = mapNpcCfg.Chat
|
||||
self.nChatProp = mapNpcCfg.ChatProp
|
||||
if mapNpcCfg.type == GameEnum.npcNewType.Upgrade and nCostCount ~= nil then
|
||||
self:ShowStrengthNpc(mapNpcCfg.Literary, nCostCount, nHasCount)
|
||||
else
|
||||
self._mapNode.rtBottom.gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtNPCName, mapNpcCfg.Name)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtNPCTag, mapNpcCfg.Desc)
|
||||
if mapNpcCfg.type ~= GameEnum.npcNewType.Narrate then
|
||||
self._mapNode.rtNpc.gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtNPCType, mapNpcCfg.Literary)
|
||||
self:ShowChat()
|
||||
if self.chatTimer == nil then
|
||||
self.chatTimer = TimerManager.Add(0, mapNpcCfg.ChatTime, self, function()
|
||||
self:ShowChat()
|
||||
end, true, true, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
AdventureModuleHelper.SetHudFollowTarget(nUId, self._mapNode.rtTop.gameObject, Vector3(0, 1.2, 0), true)
|
||||
AdventureModuleHelper.SetHudFollowTarget(nUId, self._mapNode.rtBottom.gameObject, Vector3(0, -0.7, 0), false)
|
||||
end
|
||||
end
|
||||
function NpcHudCtrl:ShowChat()
|
||||
if self.tbChatPool == nil then
|
||||
return
|
||||
end
|
||||
local bTrigger = math.random(1, 100) <= self.nChatProp and true or false
|
||||
self._mapNode.rtChat.gameObject:SetActive(bTrigger)
|
||||
if bTrigger then
|
||||
local nAllCount = #self.tbChatPool
|
||||
local nIndex = math.random(1, nAllCount)
|
||||
local nChatId = self.tbChatPool[nIndex]
|
||||
local mapChatCfg = ConfigTable.GetData("StarTowerTalk", nChatId)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtChat, mapChatCfg.Content)
|
||||
local nDuration = self:CalChatContentShowTime(mapChatCfg.Content)
|
||||
self:AddTimer(1, nDuration, function()
|
||||
self._mapNode.rtChat.gameObject:SetActive(false)
|
||||
end, true, true, true, nil)
|
||||
end
|
||||
end
|
||||
function NpcHudCtrl:Clear()
|
||||
self._mapNode.rtNpc.gameObject:SetActive(false)
|
||||
self._mapNode.rtChat.gameObject:SetActive(false)
|
||||
self._mapNode.rtStrength.gameObject:SetActive(false)
|
||||
self._mapNode.rtBottom.gameObject:SetActive(false)
|
||||
self.tbChatPool = nil
|
||||
self.nChatProp = nil
|
||||
end
|
||||
function NpcHudCtrl:HideNpc()
|
||||
if self.chatTimer ~= nil then
|
||||
TimerManager.Remove(self.chatTimer, false)
|
||||
end
|
||||
self.chatTimer = nil
|
||||
self:Clear()
|
||||
self._mapNode.rtRoot.gameObject:SetActive(false)
|
||||
end
|
||||
function NpcHudCtrl:Awake()
|
||||
self._mapNode.rtRoot.gameObject:SetActive(false)
|
||||
end
|
||||
function NpcHudCtrl:OnDisable()
|
||||
self:HideNpc()
|
||||
self.nNpcId = nil
|
||||
self.nNpcUId = nil
|
||||
self.nCostCount = nil
|
||||
end
|
||||
function NpcHudCtrl:OnEvent_InteractiveNpc(nId)
|
||||
if nId ~= self.nNpcId then
|
||||
return
|
||||
end
|
||||
if self.chatTimer ~= nil then
|
||||
TimerManager.Remove(self.chatTimer, false)
|
||||
end
|
||||
self.chatTimer = nil
|
||||
self._mapNode.rtChat.gameObject:SetActive(false)
|
||||
end
|
||||
function NpcHudCtrl:OnEvent_InteractiveNpcFinish(nId, nCostCount, nHasCount)
|
||||
if nId ~= self.nNpcId then
|
||||
return
|
||||
end
|
||||
local mapNpcCfg = ConfigTable.GetData("NPCConfig", nId)
|
||||
if mapNpcCfg == nil then
|
||||
printError("读取NPCConfig配置失败!!!id = " .. tostring(nId))
|
||||
return
|
||||
end
|
||||
self:ShowChat()
|
||||
if self.chatTimer == nil then
|
||||
self.chatTimer = TimerManager.Add(0, mapNpcCfg.ChatTime, self, function()
|
||||
self:ShowChat()
|
||||
end, true, true, false)
|
||||
end
|
||||
if mapNpcCfg.type == GameEnum.npcNewType.Upgrade and nCostCount ~= nil then
|
||||
self.nCostCount = nCostCount
|
||||
self:RefreshStrengthCost(nHasCount)
|
||||
end
|
||||
end
|
||||
function NpcHudCtrl:OnEvent_RefreshStarTowerCoin(nCoin)
|
||||
if self.nNpcId ~= nil and self.nCostCount ~= nil then
|
||||
local mapNpcCfg = ConfigTable.GetData("NPCConfig", self.nNpcId)
|
||||
if mapNpcCfg ~= nil and mapNpcCfg.type == GameEnum.npcNewType.Upgrade then
|
||||
self:RefreshStrengthCost(nCoin)
|
||||
end
|
||||
end
|
||||
end
|
||||
return NpcHudCtrl
|
||||
@@ -0,0 +1,362 @@
|
||||
local PlayerHudCtrl = class("PlayerHudCtrl", BaseCtrl)
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local nShieldParam = 0.3
|
||||
local nShieldParamPower = 0.5
|
||||
local BarHeight = 21
|
||||
local BarWidth = 166
|
||||
local ShieldBarHeight = 32
|
||||
local ShieldBarWidth = 190
|
||||
local ShieldDelayHeight = 21
|
||||
local AniTimeHighlight = 0.5
|
||||
local AniTime = 0.16
|
||||
local AniTimeShield = 0.5
|
||||
local ToughnessRecoverTime = 0.3
|
||||
local ToughnessWidth = 208
|
||||
local ToughnessHeight = 21
|
||||
local colorHide = Color(1, 1, 1, 0)
|
||||
local colorWhite = Color(1, 1, 1, 1)
|
||||
local colorShieldDelay = Color(1, 1, 1, 0.5)
|
||||
local colorRed = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 1)
|
||||
local colorRedHide = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 0)
|
||||
local colorRecover = Color(0.043137254901960784, 0.9921568627450981, 0.7568627450980392, 1)
|
||||
local colorGreen = Color(0.5568627450980392, 0.8274509803921568, 0.28627450980392155, 1)
|
||||
local colorGreenHide = Color(0.5568627450980392, 0.8274509803921568, 0.28627450980392155, 0)
|
||||
local bulletType = {
|
||||
[1] = "icon_bullet_1",
|
||||
[2] = "icon_bullet_2",
|
||||
[3] = "icon_bullet_3",
|
||||
[4] = "icon_bullet_4",
|
||||
[5] = "icon_bullet_5"
|
||||
}
|
||||
PlayerHudCtrl._mapNodeConfig = {
|
||||
canvasGroup = {
|
||||
sNodeName = "rtRoot",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
rtHpFillDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
aniRtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelayHighlight = {
|
||||
sNodeName = "imgHpDelayHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillHighLight = {
|
||||
sNodeName = "imgHpHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillRecoverLight = {
|
||||
sNodeName = "imgHpFillRecoverLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorimgBigHit = {sNodeName = "imgBigHit", sComponentName = "HpBarColor"},
|
||||
imgBg2 = {},
|
||||
aniShield = {
|
||||
sComponentName = "Animator",
|
||||
sNodeName = "rtShieldMask"
|
||||
},
|
||||
rtShieldMask = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtShieldMaskAin = {
|
||||
sNodeName = "rtShieldMask",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldDelay = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
imgShieldDelayAin = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldFillHighLight = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
imgShieldFillHighLightAni = {
|
||||
sNodeName = "imgShieldFillHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
imgShieldFillLIght = {sComponentName = "HpBarColor"},
|
||||
AmmoBar = {sNodeName = "AmmoBar"},
|
||||
AmmoBarAnim = {sNodeName = "AmmoBar", sComponentName = "Animator"},
|
||||
txtAmmoCount = {sComponentName = "TMP_Text"},
|
||||
AmmoIcon = {sComponentName = "Image"},
|
||||
JsAniObj = {sNodeName = "JsAniObj"},
|
||||
rtShakeRoot = {sComponentName = "Animator"},
|
||||
rtBuff = {
|
||||
sCtrlName = "Game.UI.Hud.Buff.BuffCtrl"
|
||||
}
|
||||
}
|
||||
PlayerHudCtrl._mapEventConfig = {
|
||||
ShowPlayerHudRootCanvas = "OnEvent_ShowPlayerHudRootCanvas",
|
||||
PlayerSwitchGun = "OnEvent_PlayerSwitchGun"
|
||||
}
|
||||
function PlayerHudCtrl:PlayTweenHp(hp, hpMax)
|
||||
local nWidth = 1 <= hp / hpMax and BarWidth or hp / hpMax * BarWidth
|
||||
if nWidth > BarWidth then
|
||||
nWidth = BarWidth
|
||||
end
|
||||
if hp < self.nBeforeHp then
|
||||
if self._mapNode.rtHpFill.sizeDelta.x > self._mapNode.rtHpFillDelay.sizeDelta.x then
|
||||
self._mapNode.aniRtHpDelay:SetTarget(self._mapNode.rtHpFill.sizeDelta, 0)
|
||||
end
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeHp - hp) / hpMax > self.bigDamageThreshold then
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0.1, AniTime)
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
delayTime = 0.5
|
||||
end
|
||||
if hp / hpMax < 0.25 then
|
||||
self._mapNode.ainColorimgBigHit:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorimgBigHit:SetTarget(colorHide, AniTime, 0.5)
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime, delayTime)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + delayTime)
|
||||
else
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = self._mapNode.rtHpFill.sizeDelta
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, AniTime)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, AniTimeHighlight)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRecover)
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), AniTime, AniTime)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorGreen, 0)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorGreenHide, AniTimeHighlight, AniTime)
|
||||
end
|
||||
end
|
||||
function PlayerHudCtrl:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
local nShieldPersent = shieldValue / self.nBeforeHpMax
|
||||
if nShieldPersent < 0.3 then
|
||||
nShieldPersent = (nShieldParam * nShieldPersent) ^ nShieldParamPower
|
||||
end
|
||||
local nWidth = math.min(nShieldPersent, 1) * ShieldBarWidth
|
||||
local nHighlightPos = math.min(nShieldPersent, 1) * 180 + 8
|
||||
local nBeforePersent = self.nBeforeShield / self.nBeforeHpMax
|
||||
if nBeforePersent < 0.3 then
|
||||
nBeforePersent = (nShieldParam * nBeforePersent) ^ nShieldParamPower
|
||||
end
|
||||
local nSumWidth = math.min(nBeforePersent - nShieldPersent, 1) * ShieldBarWidth
|
||||
if nSumWidth + nWidth > ShieldBarWidth then
|
||||
nSumWidth = ShieldBarWidth - nWidth
|
||||
end
|
||||
if shieldValue < self.nBeforeShield then
|
||||
self._mapNode.imgShieldFillHighLight.anchoredPosition = Vector2(nHighlightPos, 0)
|
||||
self._mapNode.imgShieldDelay.anchoredPosition = Vector2(nHighlightPos, 0)
|
||||
self._mapNode.imgShieldFillHighLightAni:SetTarget(colorWhite, 0)
|
||||
self._mapNode.imgShieldFillHighLightAni:SetTarget(colorHide, AniTimeShield * 1.5)
|
||||
self._mapNode.imgShieldFillLIght:SetTarget(colorWhite, 0)
|
||||
self._mapNode.imgShieldFillLIght:SetTarget(colorHide, AniTimeShield)
|
||||
self._mapNode.rtShieldMaskAin:SetTarget(Vector2(nWidth, ShieldBarHeight), AniTimeShield)
|
||||
self._mapNode.imgShieldDelay.anchoredPosition = Vector2(nWidth, 0)
|
||||
self._mapNode.imgShieldDelayAin:SetTarget(Vector2(nSumWidth, ShieldBarHeight), 0)
|
||||
self._mapNode.imgShieldDelayAin:SetTarget(Vector2(0, ShieldBarHeight), AniTimeShield, AniTimeShield * 0.5)
|
||||
elseif self.nBeforeShield <= 0 and 0 < shieldValue then
|
||||
self._mapNode.rtShieldMaskAin:SetTarget(Vector2(nWidth, ShieldBarHeight), 0)
|
||||
self._mapNode.imgShieldFillLIght:SetTarget(colorHide, 0)
|
||||
self._mapNode.aniShield:Play("PlayShield_in")
|
||||
else
|
||||
self._mapNode.imgShieldDelayAin:SetTarget(Vector2(0, BarHeight), 0)
|
||||
self._mapNode.imgShieldFillHighLightAni:SetTarget(colorHide, 0)
|
||||
self._mapNode.rtShieldMaskAin:SetTarget(Vector2(nWidth, ShieldBarHeight), AniTimeShield)
|
||||
self._mapNode.imgShieldFillLIght:SetTarget(colorWhite, 0)
|
||||
self._mapNode.imgShieldFillLIght:SetTarget(colorHide, AniTimeShield)
|
||||
end
|
||||
end
|
||||
function PlayerHudCtrl:ResetHit()
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, 0)
|
||||
self._mapNode.imgShieldFillHighLightAni:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorimgBigHit:SetTarget(colorHide, 0)
|
||||
self.nBeforeHp = 0
|
||||
self.nBeforeHpMax = 0
|
||||
self.nBeforeShield1 = 0
|
||||
self.nBeforeShield2 = 0
|
||||
self.nBeforeShield3 = 0
|
||||
self.nBeforeShield4 = 0
|
||||
end
|
||||
function PlayerHudCtrl:KillTween()
|
||||
self._mapNode.aniRtHpDelay:Stop()
|
||||
self._mapNode.ainColorHpDelay:Stop()
|
||||
self._mapNode.aniRtHpFill:Stop()
|
||||
self._mapNode.ainColorHpDelayHighlight:Stop()
|
||||
self._mapNode.ainColorHpFillHighLight:Stop()
|
||||
self._mapNode.ainColorHpFillRecoverLight:Stop()
|
||||
self._mapNode.rtShieldMaskAin:Stop()
|
||||
self._mapNode.imgShieldDelayAin:Stop()
|
||||
self._mapNode.imgShieldFillHighLightAni:Stop()
|
||||
end
|
||||
function PlayerHudCtrl:Awake()
|
||||
self.playerId = 0
|
||||
self.bigDamageThreshold = ConfigTable.GetConfigNumber("BloodSpecialEffectThresholdValue") / 100
|
||||
end
|
||||
function PlayerHudCtrl:OnEnable()
|
||||
self.playerId = 0
|
||||
self._mapNode.AmmoBar:SetActive(false)
|
||||
self:ResetHit()
|
||||
end
|
||||
function PlayerHudCtrl:OnDisable()
|
||||
self._mapNode.rtBuff:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.playerId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("AmmoChanged", self.playerId, self, self.OnEvent_AmmoChanged)
|
||||
EventManager.RemoveEntityEvent("BuffReduceTime", self.playerId, self, self.OnEvent_JsAniObjActive)
|
||||
EventManager.RemoveEntityEvent("ShieldChanged", self.playerId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.RemoveEntityEvent("PlayerDeathStateEnter", self.playerId, self, self.OnEvent_Deaded)
|
||||
self.playerId = 0
|
||||
self:KillTween()
|
||||
self:ResetHit()
|
||||
end
|
||||
function PlayerHudCtrl:OnDestroy()
|
||||
end
|
||||
function PlayerHudCtrl:SetPlayerId(playerId)
|
||||
if self.playerId == playerId then
|
||||
return
|
||||
end
|
||||
if NovaAPI.GetEntryLevelFade() then
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup, 0)
|
||||
else
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup, 1)
|
||||
end
|
||||
self.playerId = playerId
|
||||
self:ResetHit()
|
||||
self:KillTween()
|
||||
local ammoMax = AdventureModuleHelper.GetEntityAmmoMax(self.playerId)
|
||||
local ammoCount = AdventureModuleHelper.GetEntityAmmoCount(self.playerId)
|
||||
local bulletType = AdventureModuleHelper.GetEntityBulletType(self.playerId)
|
||||
self:SetAmmo(ammoCount, ammoMax)
|
||||
self:SetAmmoIcon(bulletType)
|
||||
local hp = AdventureModuleHelper.GetEntityHp(self.playerId)
|
||||
local hpMax = AdventureModuleHelper.GetEntityMaxHp(self.playerId)
|
||||
self:SetHp(hp, hpMax, true)
|
||||
local activeJs = AdventureModuleHelper.GetEntityHaveBuffTimeReduce(self.playerId)
|
||||
self:OnEvent_JsAniObjActive(activeJs)
|
||||
local shieldValue, shieldValueMax = AdventureModuleHelper.GetEntityShieldValue(self.playerId)
|
||||
self:SetShield(shieldValue, shieldValueMax, true)
|
||||
self._mapNode.rtBuff:BindEntity(self.playerId)
|
||||
EventManager.AddEntityEvent("HpChanged", self.playerId, self, self.OnEvent_HpChanged)
|
||||
EventManager.AddEntityEvent("AmmoChanged", self.playerId, self, self.OnEvent_AmmoChanged)
|
||||
EventManager.AddEntityEvent("BuffReduceTime", self.playerId, self, self.OnEvent_JsAniObjActive)
|
||||
EventManager.AddEntityEvent("ShieldChanged", self.playerId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.AddEntityEvent("PlayerDeathStateEnter", self.playerId, self, self.OnEvent_Deaded)
|
||||
end
|
||||
function PlayerHudCtrl:SetHp(hp, hpMax, bChange)
|
||||
if self.playerId == 0 then
|
||||
return
|
||||
end
|
||||
if hpMax <= 0 then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(0, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(0, BarHeight)
|
||||
elseif bChange then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorGreenHide, 0)
|
||||
else
|
||||
self:PlayTweenHp(hp, hpMax)
|
||||
end
|
||||
self.nBeforeHp = hp
|
||||
self.nBeforeHpMax = hpMax
|
||||
self._mapNode.imgBg2:SetActive(hp / hpMax < 0.25)
|
||||
end
|
||||
function PlayerHudCtrl:OnEvent_HpChanged(hp, hpMax)
|
||||
if hp == self.nBeforeHp then
|
||||
self:SetHp(hp, hpMax, true)
|
||||
else
|
||||
self:SetHp(hp, hpMax)
|
||||
end
|
||||
if hpMax ~= self.nBeforeHpMax then
|
||||
self:SetShield(self.nBeforeShield, self.nBeforeShieldMax, true)
|
||||
end
|
||||
end
|
||||
function PlayerHudCtrl:OnEvent_ShieldChanged(value1, value2)
|
||||
self:SetShield(value1, value2)
|
||||
end
|
||||
function PlayerHudCtrl:OnEvent_AmmoChanged(ammo, ammoMax)
|
||||
self:SetAmmo(ammo, ammoMax)
|
||||
end
|
||||
function PlayerHudCtrl:OnEvent_JsAniObjActive(active)
|
||||
self._mapNode.JsAniObj:SetActive(active)
|
||||
end
|
||||
function PlayerHudCtrl:SetShield(shieldValue, shieldValueMax, bChange)
|
||||
if self.playerId == 0 then
|
||||
return
|
||||
end
|
||||
if shieldValue <= 0 then
|
||||
self._mapNode.rtShieldMaskAin:SetTarget(Vector2(0, BarHeight), 0)
|
||||
self._mapNode.imgShieldDelayAin:SetTarget(Vector2(0, BarHeight), 0)
|
||||
self._mapNode.imgShieldFillHighLightAni:SetTarget(colorHide, 0)
|
||||
elseif bChange then
|
||||
self._mapNode.imgShieldDelayAin:SetTarget(Vector2(0, BarHeight), 0)
|
||||
self._mapNode.imgShieldFillHighLightAni:SetTarget(colorHide, 0)
|
||||
local nShieldPersent = shieldValue / self.nBeforeHpMax
|
||||
if nShieldPersent < 0.3 then
|
||||
nShieldPersent = (nShieldParam * nShieldPersent) ^ nShieldParamPower
|
||||
end
|
||||
local nWidth = math.min(nShieldPersent, 1) * BarWidth
|
||||
self._mapNode.rtShieldMaskAin:SetTarget(Vector2(nWidth, BarHeight), 0)
|
||||
self._mapNode.imgShieldFillLIght:SetTarget(colorHide, 0)
|
||||
else
|
||||
self:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
end
|
||||
self.nBeforeShield = shieldValue
|
||||
self.nBeforeShieldMax = shieldValueMax
|
||||
if 0 < shieldValue then
|
||||
self._mapNode.rtBuff:AddShield()
|
||||
else
|
||||
self._mapNode.rtBuff:RemoveShield()
|
||||
end
|
||||
end
|
||||
function PlayerHudCtrl:SetAmmo(ammo, ammoMax)
|
||||
if 0 < ammoMax then
|
||||
self._mapNode.AmmoBar:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAmmoCount, ammo)
|
||||
else
|
||||
self._mapNode.AmmoBar:SetActive(false)
|
||||
end
|
||||
end
|
||||
function PlayerHudCtrl:SetAmmoIcon(type)
|
||||
if type ~= 0 then
|
||||
local spriteBullet = bulletType[type]
|
||||
self:SetAtlasSprite(self._mapNode.AmmoIcon, "15_battle", spriteBullet)
|
||||
end
|
||||
end
|
||||
function PlayerHudCtrl:OnEvent_Deaded()
|
||||
EventManager.Hit("PlayerShow", self.playerId, false)
|
||||
end
|
||||
function PlayerHudCtrl:OnEvent_ShowPlayerHudRootCanvas()
|
||||
local sequence = DOTween.Sequence()
|
||||
sequence:Append(self._mapNode.canvasGroup:DOFade(1, 0.7):SetUpdate(true))
|
||||
sequence:AppendCallback(function()
|
||||
NovaAPI.SetEntryLevelFade(false)
|
||||
end)
|
||||
sequence:SetUpdate(true)
|
||||
end
|
||||
function PlayerHudCtrl:OnEvent_PlayerSwitchGun(type)
|
||||
local waitCallback = function()
|
||||
self:SetAmmoIcon(type)
|
||||
self._mapNode.AmmoBarAnim:Play("AmmoBar_in")
|
||||
end
|
||||
self._mapNode.AmmoBarAnim:Play("AmmorBar_out")
|
||||
self:AddTimer(1, 0.2, waitCallback, true, true, true, nil)
|
||||
end
|
||||
return PlayerHudCtrl
|
||||
@@ -0,0 +1,394 @@
|
||||
local PlayerSummonerHudCtrl = class("PlayerSummonerHudCtrl", BaseCtrl)
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local BarHeight = 21
|
||||
local BarWidth = 175
|
||||
local AniTimeHighlight = 0.5
|
||||
local AniTime = 0.16
|
||||
local ToughnessRecoverTime = 0.3
|
||||
local ToughnessWidth = 208
|
||||
local ToughnessHeight = 21
|
||||
local colorHide = Color(1, 1, 1, 0)
|
||||
local colorWhite = Color(1, 1, 1, 1)
|
||||
local colorShieldDelay = Color(1, 1, 1, 0.5)
|
||||
local colorRed = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 1)
|
||||
local colorRedHide = Color(0.9176470588235294, 0.043137254901960784, 0.08627450980392157, 0)
|
||||
local colorRecover = Color(0.9921568627450981, 0.5098039215686274, 0, 1)
|
||||
PlayerSummonerHudCtrl._mapNodeConfig = {
|
||||
rtHpFillDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelay = {
|
||||
sNodeName = "imgHpFillDelay",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
aniRtHpFill = {
|
||||
sNodeName = "imgHpFill",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorHpDelayHighlight = {
|
||||
sNodeName = "imgHpDelayHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillHighLight = {
|
||||
sNodeName = "imgHpHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
ainColorHpFillRecoverLight = {
|
||||
sNodeName = "imgHpFillRecoverLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldDelay = {sComponentName = "Image"},
|
||||
ainColorShieldDelay = {
|
||||
sNodeName = "imgShieldDelay",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtShieldFill = {
|
||||
sNodeName = "imgShieldFill",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
aniRtShieldFill = {
|
||||
sNodeName = "imgShieldFill",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
imgShieldFillHighLight = {sComponentName = "Image"},
|
||||
ainColorShieldFillHighLight = {
|
||||
sNodeName = "imgShieldFillHighLight",
|
||||
sComponentName = "HpBarColor"
|
||||
},
|
||||
rtToughness = {},
|
||||
rtNormal = {},
|
||||
imgBroken = {},
|
||||
imgToughnessMaskDelay = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
imgToughnessMask = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtHighlight = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
Highlight = {
|
||||
sNodeName = "rtHighlight",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
imgBrokenChip = {sComponentName = "Image"},
|
||||
aniRtToughnessDelay = {
|
||||
sNodeName = "imgToughnessMaskDelay",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
aniRtToughnessFill = {
|
||||
sNodeName = "imgToughnessMask",
|
||||
sComponentName = "HpBarRectTransform"
|
||||
},
|
||||
ainColorToughnessHighlight = {
|
||||
sNodeName = "rtHighlight",
|
||||
sComponentName = "HpBarCanvasGroup"
|
||||
},
|
||||
ainColorToughnessBrokenChip = {
|
||||
sNodeName = "imgBrokenChip",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
rtShakeRoot = {sComponentName = "Animator"},
|
||||
rtBuff = {
|
||||
sCtrlName = "Game.UI.Hud.Buff.BuffCtrl"
|
||||
}
|
||||
}
|
||||
PlayerSummonerHudCtrl._mapEventConfig = {}
|
||||
function PlayerSummonerHudCtrl:PlayTweenHp(hp, hpMax)
|
||||
local nWidth = 1 <= hp / hpMax and BarWidth or hp / hpMax * BarWidth
|
||||
if nWidth > BarWidth then
|
||||
nWidth = BarWidth
|
||||
end
|
||||
if hp < self.nBeforeHp then
|
||||
if self._mapNode.rtHpFill.sizeDelta.x > self._mapNode.rtHpFillDelay.sizeDelta.x then
|
||||
self._mapNode.aniRtHpDelay:SetTarget(self._mapNode.rtHpFill.sizeDelta, 0)
|
||||
end
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeHp - hp) / hpMax > self.bigDamageThreshold then
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0.1, AniTime)
|
||||
delayTime = 0.5
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime, delayTime)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + delayTime)
|
||||
else
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = self._mapNode.rtHpFill.sizeDelta
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, AniTimeHighlight, AniTime)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorWhite, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, AniTimeHighlight)
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRecover)
|
||||
self._mapNode.aniRtHpDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.aniRtHpFill:SetTarget(Vector2(nWidth, BarHeight), AniTime, AniTime)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorRed, 0)
|
||||
self._mapNode.ainColorHpFillRecoverLight:SetTarget(colorRedHide, AniTimeHighlight, AniTime)
|
||||
printLog("over herer 2")
|
||||
end
|
||||
end
|
||||
function PlayerSummonerHudCtrl:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
local nWidth = 1 <= shieldValue / shieldValueMax and BarWidth or shieldValue / shieldValueMax * BarWidth
|
||||
if shieldValue < self.nBeforeShield then
|
||||
if self._mapNode.rtShieldDelay.sizeDelta.x < self._mapNode.rtShieldFill.sizeDelta.x then
|
||||
self._mapNode.rtShieldDelay.sizeDelta = self._mapNode.rtShieldFill.sizeDelta
|
||||
end
|
||||
self._mapNode.rtShieldFill.sizeDelta = Vector2(nWidth, BarHeight)
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldFillHighLight, colorWhite)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeShield - shieldValue) / shieldValueMax > self.bigDamageThreshold then
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldDelay, colorWhite)
|
||||
self._mapNode.ainColorShieldDelay:SetTarget(colorShieldDelay, 0.1, AniTime)
|
||||
delayTime = 0.5
|
||||
end
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime, delayTime)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + delayTime)
|
||||
else
|
||||
NovaAPI.SetImageColor(self._mapNode.imgShieldFillHighLight, colorWhite)
|
||||
self._mapNode.ainColorShieldDelay:SetTarget(colorShieldDelay, 0)
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(nWidth, BarHeight), AniTime)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, AniTimeHighlight, 0.2 + AniTime)
|
||||
end
|
||||
end
|
||||
function PlayerSummonerHudCtrl:KillTweenToughness()
|
||||
self._mapNode.aniRtToughnessDelay:Stop()
|
||||
self._mapNode.aniRtToughnessFill:Stop()
|
||||
self._mapNode.ainColorToughnessHighlight:Stop()
|
||||
end
|
||||
function PlayerSummonerHudCtrl:PlayTweenToughness(toughness, toughnessMax)
|
||||
self:KillTweenToughness()
|
||||
local nWidth = 1 <= toughness / toughnessMax and ToughnessWidth or toughness / toughnessMax * ToughnessWidth
|
||||
if nWidth > ToughnessWidth then
|
||||
nWidth = ToughnessWidth
|
||||
end
|
||||
if self._mapNode.imgToughnessMaskDelay.sizeDelta.x < self._mapNode.imgToughnessMask.sizeDelta.x then
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = self._mapNode.imgToughnessMask.sizeDelta
|
||||
end
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0 < nWidth and nWidth or 0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(0 < nWidth and nWidth - 12 or 0, 0)
|
||||
local delayTime = 0
|
||||
if (self.nBeforeToughness - toughness) / toughnessMax > self.bigDamageThreshold then
|
||||
delayTime = 0.5
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 1)
|
||||
self._mapNode.ainColorToughnessHighlight:SetTarget(0, AniTime, delayTime + AniTime)
|
||||
self._mapNode.aniRtToughnessDelay:SetTarget(Vector2(nWidth, ToughnessHeight), AniTime, delayTime)
|
||||
end
|
||||
function PlayerSummonerHudCtrl:PlayTweenToughnessBroken()
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(0, 0)
|
||||
self._mapNode.rtNormal:SetActive(false)
|
||||
self._mapNode.imgBroken:SetActive(true)
|
||||
self._mapNode.ainColorToughnessBrokenChip:Play("imgBrokenChip_in")
|
||||
self._mapNode.rtShakeRoot:Play("HPShake_in")
|
||||
end
|
||||
function PlayerSummonerHudCtrl:PlayTweenToughnessRecover()
|
||||
self:KillTweenToughness()
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(0, ToughnessHeight)
|
||||
self._mapNode.rtHighlight.anchoredPosition = Vector2(ToughnessWidth - 12, 0)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 0)
|
||||
self._mapNode.rtNormal:SetActive(true)
|
||||
self._mapNode.imgBroken:SetActive(false)
|
||||
self.tweenerToughness3 = self._mapNode.aniRtToughnessFill:SetTarget(Vector2(ToughnessWidth, ToughnessHeight), ToughnessRecoverTime)
|
||||
end
|
||||
function PlayerSummonerHudCtrl:ResetHit()
|
||||
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0)
|
||||
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, 0)
|
||||
self._mapNode.ainColorShieldFillHighLight:SetTarget(colorHide, 0)
|
||||
self.nBeforeHp = 0
|
||||
self.nBeforeHpMax = 0
|
||||
self.nBeforeShield1 = 0
|
||||
self.nBeforeShield2 = 0
|
||||
self.nBeforeShield3 = 0
|
||||
self.nBeforeShield4 = 0
|
||||
self.nBeforeToughness = 0
|
||||
self._mapNode.rtNormal:SetActive(true)
|
||||
self._mapNode.imgBroken:SetActive(false)
|
||||
end
|
||||
function PlayerSummonerHudCtrl:KillTween()
|
||||
self._mapNode.aniRtHpDelay:Stop()
|
||||
self._mapNode.ainColorHpDelay:Stop()
|
||||
self._mapNode.aniRtHpFill:Stop()
|
||||
self._mapNode.ainColorHpDelayHighlight:Stop()
|
||||
self._mapNode.ainColorHpFillHighLight:Stop()
|
||||
self._mapNode.ainColorHpFillRecoverLight:Stop()
|
||||
self._mapNode.aniRtShieldDelay:Stop()
|
||||
self._mapNode.ainColorShieldDelay:Stop()
|
||||
self._mapNode.aniRtShieldFill:Stop()
|
||||
self._mapNode.ainColorShieldFillHighLight:Stop()
|
||||
self._mapNode.aniRtToughnessDelay:Stop()
|
||||
self._mapNode.aniRtToughnessFill:Stop()
|
||||
self._mapNode.ainColorToughnessHighlight:Stop()
|
||||
end
|
||||
function PlayerSummonerHudCtrl:Awake()
|
||||
self.monsterId = 0
|
||||
self.bigDamageThreshold = ConfigTable.GetConfigNumber("BloodSpecialEffectThresholdValue") / 100
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnEnable()
|
||||
self.monsterId = 0
|
||||
self:ResetHit()
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnDisable()
|
||||
self._mapNode.rtBuff:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessStateChanged", self.monsterId, self, self.OnEvent_ToughnessStateChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessValueChanged", self.monsterId, self, self.OnEvent_ToughnessValueChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessShowStateChanged", self.monsterId, self, self.OnEvent_ToughnessShowStateChanged)
|
||||
self.monsterId = 0
|
||||
self:KillTween()
|
||||
self:ResetHit()
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnDestroy()
|
||||
end
|
||||
function PlayerSummonerHudCtrl:SetMonsterId(monsterId)
|
||||
if self.monsterId == monsterId then
|
||||
return
|
||||
end
|
||||
self.monsterId = monsterId
|
||||
self:ResetHit()
|
||||
self:KillTween()
|
||||
local hp = AdventureModuleHelper.GetEntityHp(self.monsterId)
|
||||
local hpMax = AdventureModuleHelper.GetEntityMaxHp(self.monsterId)
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.one
|
||||
local toughness = AdventureModuleHelper.GetMonsterToughness(self.monsterId)
|
||||
local toughnessMax = AdventureModuleHelper.GetMonsterToughnessMax(self.monsterId)
|
||||
self:SetHp(hp, hpMax, true)
|
||||
self:SetToughness(toughness, toughnessMax, false, true)
|
||||
local shieldValue, shieldValueMax = AdventureModuleHelper.GetEntityShieldValue(self.monsterId)
|
||||
self:SetShield(shieldValue, shieldValueMax, true)
|
||||
self._mapNode.rtBuff:BindEntity(self.monsterId)
|
||||
EventManager.AddEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.AddEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.AddEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.AddEntityEvent("ToughnessStateChanged", self.monsterId, self, self.OnEvent_ToughnessStateChanged)
|
||||
EventManager.AddEntityEvent("ToughnessValueChanged", self.monsterId, self, self.OnEvent_ToughnessValueChanged)
|
||||
EventManager.AddEntityEvent("ToughnessShowStateChanged", self.monsterId, self, self.OnEvent_ToughnessShowStateChanged)
|
||||
printLog("herherhehrhehrherheh")
|
||||
end
|
||||
function PlayerSummonerHudCtrl:SetHp(hp, hpMax, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if hpMax <= 0 then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(0, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(0, BarHeight)
|
||||
elseif bChange then
|
||||
self._mapNode.rtHpFillDelay.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
self._mapNode.rtHpFill.sizeDelta = Vector2(hp / hpMax * BarWidth, BarHeight)
|
||||
else
|
||||
self:PlayTweenHp(hp, hpMax)
|
||||
end
|
||||
self.nBeforeHp = hp
|
||||
self.nBeforeHpMax = hpMax
|
||||
end
|
||||
function PlayerSummonerHudCtrl:SetToughness(toughness, toughnessMax, bState, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if toughnessMax <= 0 then
|
||||
self._mapNode.rtToughness:SetActive(false)
|
||||
elseif bChange then
|
||||
self._mapNode.imgToughnessMask.sizeDelta = Vector2(toughness / toughnessMax * ToughnessWidth, ToughnessHeight)
|
||||
self._mapNode.imgToughnessMaskDelay.sizeDelta = Vector2(toughness / toughnessMax * ToughnessWidth, ToughnessHeight)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Highlight, 0)
|
||||
elseif bState then
|
||||
if toughness == 0 then
|
||||
self:PlayTweenToughnessBroken()
|
||||
else
|
||||
self:PlayTweenToughnessRecover()
|
||||
end
|
||||
else
|
||||
self:PlayTweenToughness(toughness, toughnessMax)
|
||||
end
|
||||
self.nBeforeToughness = toughness
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnEvent_HpChanged(hp, hpMax)
|
||||
if hp == self.nBeforeHp then
|
||||
self:SetHp(hp, hpMax, true)
|
||||
else
|
||||
self:SetHp(hp, hpMax)
|
||||
end
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnEvent_ShieldChanged(value1, value2)
|
||||
if value1 == self.nBeforeShield then
|
||||
self:SetShield(value1, value2, true)
|
||||
else
|
||||
self:SetShield(value1, value2)
|
||||
end
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnEvent_ToughnessStateChanged(bBroken, nValue, nToughnessMax)
|
||||
if bBroken then
|
||||
self:SetToughness(0, nToughnessMax, true)
|
||||
elseif nValue ~= 0 then
|
||||
self:SetToughness(nToughnessMax, nToughnessMax, true)
|
||||
end
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnEvent_ToughnessValueChanged(toughness, toughnessMax)
|
||||
self:SetToughness(toughness, toughnessMax, false)
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnEvent_ToughnessShowStateChanged(bShow)
|
||||
if bShow then
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.one
|
||||
else
|
||||
self._mapNode.rtToughness.transform.localScale = Vector3.zero
|
||||
end
|
||||
end
|
||||
function PlayerSummonerHudCtrl:SetShield(shieldValue, shieldValueMax, bChange)
|
||||
if self.monsterId == 0 then
|
||||
return
|
||||
end
|
||||
if shieldValue <= 0 then
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(0, BarHeight), 0)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(0, BarHeight), 0)
|
||||
elseif bChange then
|
||||
self._mapNode.aniRtShieldDelay:SetTarget(Vector2(shieldValue / shieldValueMax * BarWidth, BarHeight), 0)
|
||||
self._mapNode.aniRtShieldFill:SetTarget(Vector2(shieldValue / shieldValueMax * BarWidth, BarHeight), 0)
|
||||
else
|
||||
self:PlayTweenShield(shieldValue, shieldValueMax)
|
||||
end
|
||||
self.nBeforeShield = shieldValue
|
||||
self.nBeforeShieldMax = shieldValueMax
|
||||
end
|
||||
function PlayerSummonerHudCtrl:OnEvent_Deaded()
|
||||
self._mapNode.rtBuff:UnbindEntity()
|
||||
EventManager.RemoveEntityEvent("HpChanged", self.monsterId, self, self.OnEvent_HpChanged)
|
||||
EventManager.RemoveEntityEvent("Dead", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ClearSlef", self.monsterId, self, self.OnEvent_Deaded)
|
||||
EventManager.RemoveEntityEvent("ShieldChanged", self.monsterId, self, self.OnEvent_ShieldChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessStateChanged", self.monsterId, self, self.OnEvent_ToughnessStateChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessValueChanged", self.monsterId, self, self.OnEvent_ToughnessValueChanged)
|
||||
EventManager.RemoveEntityEvent("ToughnessShowStateChanged", self.monsterId, self, self.OnEvent_ToughnessShowStateChanged)
|
||||
self.monsterId = 0
|
||||
self:KillTween()
|
||||
self:ResetHit()
|
||||
EventManager.Hit("MonsterHUDChange", self.monsterId, GameEnum.monsterBloodType.PLAYERSUMMON, false)
|
||||
end
|
||||
return PlayerSummonerHudCtrl
|
||||
Reference in New Issue
Block a user