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:
SL1900
2025-12-03 01:00:00 +09:00
commit 5e0d58cfad
3595 changed files with 9373562 additions and 0 deletions
@@ -0,0 +1,160 @@
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"
},
rtShakeRoot = {sComponentName = "Animator"},
aniFadeHpBar = {
sNodeName = "rtShakeRoot",
sComponentName = "HpBarCanvasGroup"
}
}
MonsterHudCtrl._mapEventConfig = {}
MonsterHudCtrl._mapRedDotConfig = {}
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()
EventManager.RemoveEntityEvent("HpChanged", self.nEntityId, self, self.OnEvent_HpChanged)
self.monsterId = 0
self:KillTween()
self:ResetHit()
end
function MonsterHudCtrl:ResetHit()
self._mapNode.ainColorHpDelay:SetTarget(colorRed, 0)
self._mapNode.ainColorHpFillHighLight:SetTarget(colorHide, 0)
self._mapNode.ainColorHpDelayHighlight:SetTarget(colorHide, 0)
self.nBeforeHp = 0
self.nBeforeHpMax = 0
end
function MonsterHudCtrl:SetMonsterId(nEntityId)
if self.nEntityId ~= nil or self.nEntityId ~= 0 then
EventManager.RemoveEntityEvent("HpChanged", self.nEntityId, self, self.OnEvent_HpChanged)
end
self.nEntityId = nEntityId
self:KillTween()
local hp = AdventureModuleHelper.GetEntityHp(self.nEntityId)
local hpMax = AdventureModuleHelper.GetEntityMaxHp(self.nEntityId)
self:SetHp(hp, hpMax, true)
EventManager.AddEntityEvent("HpChanged", self.nEntityId, self, self.OnEvent_HpChanged)
end
function MonsterHudCtrl:SetHp(hp, hpMax, bChange)
if self.nEntityId == 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: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: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()
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
return MonsterHudCtrl
@@ -0,0 +1,142 @@
local PlayerHudCtrl = class("PlayerHudCtrl", BaseCtrl)
local barWidth = 122
PlayerHudCtrl._mapNodeConfig = {
go_Level = {nCount = 6},
go_LevelUpTips = {},
skillBar = {},
bar = {
sComponentName = "RectTransform"
},
go_levelUpDes = {},
txt_upDes = {sComponentName = "TMP_Text"}
}
PlayerHudCtrl._mapEventConfig = {
TowerDefense_character_levelUp = "OnEvent_LevelUp",
TowerDefensePointChange = "OnEvent_PointChange",
ResetEnergy = "OnEvent_UpdateEnergy",
TowerDefenseShowFullScreenPanel = "OnEvent_PauseEnergy",
TowerDefenseShowHideScreenPanel = "OnEvent_ResumeEnergy",
TowerDefenseFuncShow = "OnEvent_FuncShow"
}
PlayerHudCtrl._mapRedDotConfig = {}
function PlayerHudCtrl:Awake()
self:Init()
end
function PlayerHudCtrl:OnDestroy()
if self.tweener ~= nil then
self.tweener:Kill()
end
end
function PlayerHudCtrl:Init()
for _, go in pairs(self._mapNode.go_Level) do
go:SetActive(false)
end
self.nPoint = 0
self.bFuncIsShow = false
end
function PlayerHudCtrl:SetPlayerId(characterId)
self:Init()
self.nCharacterId = characterId
self._mapNode.go_Level[1]:SetActive(true)
self.nlevel = 1
self._mapNode.go_levelUpDes:SetActive(false)
self._mapNode.go_LevelUpTips:SetActive(false)
self._mapNode.skillBar:SetActive(false)
end
function PlayerHudCtrl:CheckTips()
if self.bFuncIsShow then
self._mapNode.go_LevelUpTips:SetActive(false)
return
end
local config = ConfigTable.GetData("TowerDefenseCharacter", self.nCharacterId)
if config == nil then
return
end
local needPoint = config.PointNeeded[self.nlevel]
if needPoint ~= nil then
self._mapNode.go_LevelUpTips:SetActive(needPoint <= self.nPoint)
else
self._mapNode.go_LevelUpTips:SetActive(false)
end
end
function PlayerHudCtrl:OnEvent_LevelUp(nCharacterId, nlevel)
if self.nCharacterId ~= nCharacterId then
return
end
self._mapNode.go_Level[self.nlevel]:SetActive(false)
self.nlevel = nlevel
self._mapNode.go_Level[self.nlevel]:SetActive(true)
local config = ConfigTable.GetData("TowerDefenseCharacter", self.nCharacterId)
if config == nil then
return
end
self._mapNode.go_levelUpDes:SetActive(false)
if self.timer ~= nil then
self.timer:_Stop()
end
if #config["NewPotential" .. nlevel] == 1 then
local id = config["NewPotential" .. nlevel][1]
local potentialConfig = ConfigTable.GetData("TowerDefensePotential", id)
if potentialConfig == nil then
return
end
NovaAPI.SetTMPText(self._mapNode.txt_upDes, potentialConfig.Name)
self._mapNode.go_levelUpDes:SetActive(true)
local cb = function()
self._mapNode.go_levelUpDes:SetActive(false)
end
self.timer = self:AddTimer(1, 1.5, cb, true, true, true)
end
end
function PlayerHudCtrl:OnEvent_PointChange(nPoint)
if self.nCharacterId == nil then
return
end
self.nPoint = nPoint
self:CheckTips()
end
function PlayerHudCtrl:OnEvent_UpdateEnergy(entityId, characterId, skillId, curCd, maxCd, isAuto)
if characterId ~= self.nCharacterId then
return
end
local cdValue = curCd:AsFloat() or 0
local cdMaxValue = maxCd:AsFloat() or 0
cdValue = math.max(0, cdMaxValue - cdValue)
if self.tweener ~= nil then
self.tweener:Kill()
end
self._mapNode.skillBar:SetActive(true)
if isAuto then
self.tweener = DOTween.To(function()
return cdMaxValue - cdValue
end, function(v)
self._mapNode.bar.sizeDelta = Vector2(barWidth * (v / cdMaxValue), self._mapNode.bar.sizeDelta.y)
end, cdMaxValue, cdValue):OnComplete(function()
self._mapNode.bar.sizeDelta = Vector2(barWidth, self._mapNode.bar.sizeDelta.y)
end)
else
self._mapNode.bar.sizeDelta = Vector2(barWidth * ((cdMaxValue - cdValue) / cdMaxValue), self._mapNode.bar.sizeDelta.y)
end
end
function PlayerHudCtrl:OnEvent_PauseEnergy()
if self.tweener == nil then
return
end
end
function PlayerHudCtrl:OnEvent_ResumeEnergy()
if self.tweener == nil then
return
end
end
function PlayerHudCtrl:OnEvent_FuncShow(bIsShow, characterId)
if characterId ~= self.nCharacterId then
return
end
self.bFuncIsShow = bIsShow
if self.bFuncIsShow then
self._mapNode.go_LevelUpTips:SetActive(false)
else
self:CheckTips()
end
end
return PlayerHudCtrl
@@ -0,0 +1,214 @@
local TowerDefenseHUDCtrl = class("TowerDefenseHUDCtrl", BaseCtrl)
local AdventureModuleHelper = CS.AdventureModuleHelper
TowerDefenseHUDCtrl._mapNodeConfig = {
Root = {},
DamageNumberRoot = {},
DamageWordRoot = {}
}
TowerDefenseHUDCtrl._mapEventConfig = {
TOWERDEFENSE_SET_ROLE_ON_STAGE_RESULT = "OnEvent_PlayerShowChanged",
TOWERDEFENSE_MONSTER_STATE = "OnEvent_MonsterActive",
TowerDefense_Restart = "OnEvent_Restart",
HudDestroy = "OnEvent_HudDestroyed",
HudDamage = "OnEvent_HudDamaged",
HudHeal = "OnEvent_HudHealed",
HudDefence = "OnEvent_HudDefenced",
HudDotDamage = "OnEvent_HudDotDamage",
TriggerElementMark = "OnEvent_HudMark"
}
TowerDefenseHUDCtrl._mapRedDotConfig = {}
function TowerDefenseHUDCtrl:Awake()
self.PlayerHUDPrefab = self:LoadAsset("UI/Play_TowerDefence/HUD/PlayerHUD.prefab")
self.MonsterHUDPrefab = self:LoadAsset("UI/Play_TowerDefence/HUD/MonsterHUD.prefab")
self.critDamageHudPrefab = self:LoadAsset("UI/HUD/CritDamageHUDNumber_UI.prefab")
self.dotDamageHudPrefab = self:LoadAsset("UI/HUD/DotDamageHUDNumber_UI.prefab")
self.damageHudPrefab = self:LoadAsset("UI/Play_TowerDefence/HUD/DamageHUDNumber_UI.prefab")
self.minDamageHUDNumber = self:LoadAsset("UI/HUD/MinDamageHUDNumber_UI.prefab")
self.monsterHuds = {}
self.playerHuds = {}
self.numberHuds = {}
self.tabToughnessEntity = {}
self.hudId = 0
end
function TowerDefenseHUDCtrl:OnDestroy()
self.PlayerHUDPrefab = nil
self.MonsterHUDPrefab = nil
self.critDamageHudPrefab = nil
self.dotDamageHudPrefab = nil
self.damageHudPrefab = nil
self.minDamageHUDNumber = nil
for key, value in pairs(self.monsterHuds) do
self:DespawnPrefabInstance(value, "HUD")
end
for key, value in pairs(self.playerHuds) do
self:DespawnPrefabInstance(value, "HUD")
end
for _, v in pairs(self.numberHuds) do
self:DespawnPrefabInstance(v, "HUD")
end
self.monsterHuds = {}
self.playerHuds = {}
self.numberHuds = {}
self.tabToughnessEntity = {}
self.hudId = 0
end
function TowerDefenseHUDCtrl:OnEvent_PlayerShowChanged(bResult, nEntityId, nCharacterId)
if nEntityId == 0 then
return
end
local playerHud = self.playerHuds[nCharacterId]
if bResult then
if playerHud == nil then
playerHud = self:SpawnPrefabInstance(self.PlayerHUDPrefab, "Game.UI.TowerDefense.HUD.PlayerHudCtrl", "HUD", self._mapNode.Root)
self.playerHuds[nCharacterId] = playerHud
playerHud.gameObject.transform.localScale = Vector3.one
end
if playerHud ~= nil then
playerHud:SetPlayerId(nCharacterId)
local height = CS.AdventureModuleHelper.GetHudOffsetHeight(nEntityId)
local offset = Vector3(0, height, 0)
CS.AdventureModuleHelper.SetHudFollowTarget(nEntityId, playerHud.gameObject, offset, false)
end
elseif playerHud ~= nil then
self:DespawnPrefabInstance(playerHud, "HUD")
self.playerHuds[nCharacterId] = nil
end
end
function TowerDefenseHUDCtrl:OnEvent_MonsterActive(nEntityId, bShow)
if nEntityId == 0 then
return
end
local monsterHud = self.monsterHuds[nEntityId]
if bShow then
if monsterHud == nil then
monsterHud = self:SpawnPrefabInstance(self.MonsterHUDPrefab, "Game.UI.TowerDefense.HUD.MonsterHudCtrl", "HUD", self._mapNode.Root)
self.monsterHuds[nEntityId] = monsterHud
monsterHud.gameObject.transform.localScale = Vector3.one
end
if monsterHud ~= nil then
monsterHud:SetMonsterId(nEntityId)
local height = CS.AdventureModuleHelper.GetEntityMonsterBarHeight(nEntityId)
local offset = Vector3(0, height, 0)
CS.AdventureModuleHelper.SetHudFollowTarget(nEntityId, monsterHud.gameObject, offset, true)
end
elseif monsterHud ~= nil then
self:DespawnPrefabInstance(monsterHud, "HUD")
self.monsterHuds[nEntityId] = nil
end
end
function TowerDefenseHUDCtrl:OnEvent_Restart()
for _, value in pairs(self.monsterHuds) do
self:DespawnPrefabInstance(value, "HUD")
end
for _, value in pairs(self.playerHuds) do
self:DespawnPrefabInstance(value, "HUD")
end
for _, v in pairs(self.numberHuds) do
self:DespawnPrefabInstance(v, "HUD")
end
self.monsterHuds = {}
self.playerHuds = {}
self.numberHuds = {}
self.tabToughnessEntity = {}
self.hudId = 0
end
function TowerDefenseHUDCtrl:OnEvent_HudDestroyed(id)
local hud = self.numberHuds[id]
if hud ~= nil then
self:DespawnPrefabInstance(hud, "HUD")
self.numberHuds[id] = nil
end
end
function TowerDefenseHUDCtrl: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 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 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 TowerDefenseHUDCtrl:OnEvent_HudDotDamage(id, value, isCrit, hitDamageConfig, formId, isMark, 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, 4)
self.numberHuds[self.hudId] = hud
hud.gameObject.transform:SetAsLastSibling()
end
function TowerDefenseHUDCtrl: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 TowerDefenseHUDCtrl: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 TowerDefenseHUDCtrl: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
return TowerDefenseHUDCtrl
@@ -0,0 +1,11 @@
local TowerDefenseHudPanel = class("TowerDefenseHudPanel", BasePanel)
TowerDefenseHudPanel._bAddToBackHistory = false
TowerDefenseHudPanel._bIsMainPanel = false
TowerDefenseHudPanel._sSortingLayerName = AllEnum.SortingLayerName.HUD
TowerDefenseHudPanel._tbDefine = {
{
sPrefabPath = "Play_TowerDefence/HUD/HUDROOT.prefab",
sCtrlName = "Game.UI.TowerDefense.HUD.TowerDefenseHUDCtrl"
}
}
return TowerDefenseHudPanel