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,120 @@
|
||||
local BossSkillHintIndicator = class("BossSkillHintIndicator", BaseCtrl)
|
||||
BossSkillHintIndicator._mapNodeConfig = {
|
||||
ImageIcon = {sComponentName = "Image"},
|
||||
ImageBossIconBtn = {
|
||||
sNodeName = "ImageBossIcon",
|
||||
sComponentName = "Button"
|
||||
},
|
||||
ImageBossWarn = {},
|
||||
ImageArrow = {sComponentName = "Button"}
|
||||
}
|
||||
BossSkillHintIndicator._mapEventConfig = {}
|
||||
function BossSkillHintIndicator:Awake()
|
||||
self.animtor = self.gameObject:GetComponent("Animator")
|
||||
self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
|
||||
self.nEntityId = nil
|
||||
end
|
||||
function BossSkillHintIndicator:FadeIn()
|
||||
end
|
||||
function BossSkillHintIndicator:FadeOut()
|
||||
end
|
||||
function BossSkillHintIndicator:OnEnable()
|
||||
end
|
||||
function BossSkillHintIndicator:OnDisable()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
function BossSkillHintIndicator:OnDestroy()
|
||||
end
|
||||
function BossSkillHintIndicator:OnRelease()
|
||||
end
|
||||
function BossSkillHintIndicator:SetTarget(nEntityId, nBossSkinId, bHold, fRecycleCallback)
|
||||
if self.nEntityId ~= nil then
|
||||
printError("重复绑定")
|
||||
return
|
||||
end
|
||||
self.fRecycleCallback = fRecycleCallback
|
||||
self.nEntityId = nEntityId
|
||||
self.bHold = bHold
|
||||
local mapMonsterSkin = ConfigTable.GetData("MonsterSkin", nBossSkinId)
|
||||
local previewMonster
|
||||
if mapMonsterSkin.MonsterManual ~= "" then
|
||||
previewMonster = ConfigTable.GetData("MonsterManual", mapMonsterSkin.MonsterManual)
|
||||
end
|
||||
if self.bHold and previewMonster ~= nil and (previewMonster.Icon ~= nil or previewMonster.Icon ~= "") then
|
||||
self:SetPngSprite(self._mapNode.ImageIcon, previewMonster.Icon)
|
||||
else
|
||||
end
|
||||
EventManager.AddEntityEvent("AttackHintCancel", self.nEntityId, self, self.OnEvent_SkillCancel)
|
||||
EventManager.AddEntityEvent("AttackHint", self.nEntityId, self, self.OnEvent_SkillHint)
|
||||
EventManager.AddEntityEvent("AttackHintEnd", self.nEntityId, self, self.OnEvent_SkillEnd)
|
||||
EventManager.AddEntityEvent("AttackHintShow", self.nEntityId, self, self.OnEvent_HintShow)
|
||||
EventManager.AddEntityEvent("AttackHintHide", self.nEntityId, self, self.OnEvent_HintHide)
|
||||
self._mapNode.ImageBossWarn:SetActive(false)
|
||||
self.gameObject:SetActive(self.bHold)
|
||||
self.animtor:Play("TemplateBoss_in")
|
||||
NovaAPI.SetSkillIndicatorTarget(nEntityId, self.gameObject, Vector3.zero)
|
||||
end
|
||||
function BossSkillHintIndicator:UnBindEvent()
|
||||
if self.nEntityId == nil then
|
||||
return
|
||||
end
|
||||
if self.endTimer ~= nil then
|
||||
self.endTimer:Cancel()
|
||||
end
|
||||
EventManager.RemoveEntityEvent("AttackHintCancel", self.nEntityId, self, self.OnEvent_SkillCancel)
|
||||
EventManager.RemoveEntityEvent("AttackHint", self.nEntityId, self, self.OnEvent_SkillHint)
|
||||
EventManager.RemoveEntityEvent("AttackHintEnd", self.nEntityId, self, self.OnEvent_SkillEnd)
|
||||
EventManager.RemoveEntityEvent("AttackHintShow", self.nEntityId, self, self.OnEvent_HintShow)
|
||||
EventManager.RemoveEntityEvent("AttackHintHide", self.nEntityId, self, self.OnEvent_HintHide)
|
||||
if self.fRecycleCallback ~= nil then
|
||||
self.fRecycleCallback(self.nEntityId, self, self.bHold)
|
||||
self.fRecycleCallback = nil
|
||||
end
|
||||
self.nEntityId = nil
|
||||
end
|
||||
function BossSkillHintIndicator:OnEvent_SkillHint()
|
||||
if self.endTimer ~= nil then
|
||||
printError("已在技能结束处理中")
|
||||
return
|
||||
end
|
||||
self.gameObject:SetActive(true)
|
||||
self._mapNode.ImageBossWarn:SetActive(true)
|
||||
self.animtor:Play("TemplateBoss_Hint")
|
||||
end
|
||||
function BossSkillHintIndicator:OnEvent_SkillEnd()
|
||||
if self.endTimer ~= nil then
|
||||
printError("已在技能结束处理中")
|
||||
return
|
||||
end
|
||||
self.animtor:Play("TemplateBoss_out_2")
|
||||
local EndCallBack = function()
|
||||
self.animtor:Play("TemplateBoss_in_loop")
|
||||
self._mapNode.ImageBossWarn:SetActive(false)
|
||||
self.endTimer = nil
|
||||
end
|
||||
self.endTimer = self:AddTimer(1, 0.5, EndCallBack, true, true, nil, true)
|
||||
end
|
||||
function BossSkillHintIndicator:OnEvent_SkillCancel()
|
||||
if self.endTimer ~= nil then
|
||||
self.endTimer:Cancel()
|
||||
end
|
||||
if self.bHold then
|
||||
self.animtor:Play("TemplateBoss_in_loop")
|
||||
else
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
self._mapNode.ImageBossWarn:SetActive(false)
|
||||
self.endTimer = nil
|
||||
end
|
||||
function BossSkillHintIndicator:OnEvent_HintShow()
|
||||
local indicatorBase = self.gameObject:GetComponent("IndicatorBase")
|
||||
indicatorBase:SetLogicHide(false)
|
||||
end
|
||||
function BossSkillHintIndicator:OnEvent_HintHide()
|
||||
local indicatorBase = self.gameObject:GetComponent("IndicatorBase")
|
||||
indicatorBase:SetLogicHide(true)
|
||||
end
|
||||
function BossSkillHintIndicator:MonsterDied()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
return BossSkillHintIndicator
|
||||
@@ -0,0 +1,121 @@
|
||||
local HintIndicators = class("HintIndicators", BaseCtrl)
|
||||
HintIndicators._mapNodeConfig = {
|
||||
canvas_group = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "CanvasGroup"
|
||||
},
|
||||
IndictorArea = {sComponentName = "Transform"},
|
||||
TemplateBossIndicator = {},
|
||||
TemplateMonsterIndictor = {}
|
||||
}
|
||||
HintIndicators._mapEventConfig = {
|
||||
MonsterActive = "OnEvent_MonsterActive",
|
||||
InputEnable = "OnEvent_InputEnable"
|
||||
}
|
||||
function HintIndicators:Awake()
|
||||
self.tbAllIndicators = {}
|
||||
self.mapActiveIndicator = {}
|
||||
self.tbPoolBossIndicator = {}
|
||||
self.tbPoolMonsterIndicator = {}
|
||||
end
|
||||
function HintIndicators:FadeIn()
|
||||
end
|
||||
function HintIndicators:FadeOut()
|
||||
end
|
||||
function HintIndicators:OnEnable()
|
||||
end
|
||||
function HintIndicators:OnDisable()
|
||||
self:ClearAllCtrl()
|
||||
end
|
||||
function HintIndicators:OnDestroy()
|
||||
end
|
||||
function HintIndicators:OnRelease()
|
||||
end
|
||||
function HintIndicators:GetIndicator(bHold)
|
||||
if not bHold then
|
||||
if #self.tbPoolMonsterIndicator > 0 then
|
||||
local mapCtrl = table.remove(self.tbPoolMonsterIndicator)
|
||||
return mapCtrl
|
||||
else
|
||||
local goIndicator = instantiate(self._mapNode.TemplateMonsterIndictor, self._mapNode.IndictorArea)
|
||||
local rtIndicator = goIndicator:GetComponent("RectTransform")
|
||||
rtIndicator.localScale = Vector3.one
|
||||
rtIndicator.localPosition = Vector3.zero
|
||||
local mapCtrl = self:BindCtrlByNode(goIndicator, "Game.UI.Battle.SkillHintIndicator.MonsterSkillHintIndicator")
|
||||
table.insert(self.tbAllIndicators, mapCtrl)
|
||||
return mapCtrl
|
||||
end
|
||||
elseif 0 < #self.tbPoolBossIndicator then
|
||||
local mapCtrl = table.remove(self.tbPoolBossIndicator)
|
||||
return mapCtrl
|
||||
else
|
||||
local goIndicator = instantiate(self._mapNode.TemplateBossIndicator, self._mapNode.IndictorArea)
|
||||
local rtIndicator = goIndicator:GetComponent("RectTransform")
|
||||
rtIndicator.localScale = Vector3.one
|
||||
rtIndicator.localPosition = Vector3.zero
|
||||
local mapCtrl = self:BindCtrlByNode(goIndicator, "Game.UI.Battle.SkillHintIndicator.BossSkillHintIndicator")
|
||||
table.insert(self.tbAllIndicators, mapCtrl)
|
||||
return mapCtrl
|
||||
end
|
||||
end
|
||||
function HintIndicators:OnEvent_MonsterSpawn(nEntityId, nDataId)
|
||||
local mapMonster = ConfigTable.GetData("Monster", nDataId)
|
||||
if mapMonster == nil then
|
||||
printError("Monster Data Missing:" .. nDataId)
|
||||
return
|
||||
end
|
||||
local mapMonsterSkin = ConfigTable.GetData("MonsterSkin", mapMonster.FAId)
|
||||
if mapMonsterSkin == nil then
|
||||
printError("MonsterSkin Data Missing:" .. mapMonster.FAId)
|
||||
return
|
||||
end
|
||||
if mapMonster.AttackHintType ~= nil and mapMonster.AttackHintType ~= GameEnum.AttackHintType.Null then
|
||||
if self.mapActiveIndicator[nEntityId] ~= nil then
|
||||
printError("重复EntityId绑定指示器:" .. nEntityId)
|
||||
return
|
||||
end
|
||||
local mapCtrl = self:GetIndicator(mapMonster.AttackHintType == GameEnum.AttackHintType.Always)
|
||||
local RecycleCallback = function(nCtrlEntityId, goCtrl, bHold)
|
||||
if not bHold then
|
||||
table.insert(self.tbPoolMonsterIndicator, goCtrl)
|
||||
else
|
||||
table.insert(self.tbPoolBossIndicator, goCtrl)
|
||||
end
|
||||
goCtrl.gameObject:SetActive(false)
|
||||
if self.mapActiveIndicator[nCtrlEntityId] ~= nil then
|
||||
self.mapActiveIndicator[nCtrlEntityId] = nil
|
||||
end
|
||||
end
|
||||
mapCtrl:SetTarget(nEntityId, mapMonster.FAId, mapMonster.AttackHintType == GameEnum.AttackHintType.Always, RecycleCallback)
|
||||
self.mapActiveIndicator[nEntityId] = mapCtrl
|
||||
end
|
||||
end
|
||||
function HintIndicators:OnEvent_MonsterDied(nEntityId)
|
||||
if self.mapActiveIndicator[nEntityId] ~= nil then
|
||||
self.mapActiveIndicator[nEntityId]:UnBindEvent()
|
||||
end
|
||||
end
|
||||
function HintIndicators:OnEvent_MonsterActive(nEntityId, dataID, bShow)
|
||||
if bShow then
|
||||
self:OnEvent_MonsterSpawn(nEntityId, dataID)
|
||||
else
|
||||
self:OnEvent_MonsterDied(nEntityId)
|
||||
end
|
||||
end
|
||||
function HintIndicators:OnEvent_InputEnable(bEnable)
|
||||
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvas_group, bEnable == true and 1 or 0)
|
||||
end
|
||||
function HintIndicators:ClearAllCtrl()
|
||||
for _, mapCtrl in ipairs(self.mapActiveIndicator) do
|
||||
mapCtrl:UnBindEvent()
|
||||
end
|
||||
for _, mapCtrl in pairs(self.tbAllIndicators) do
|
||||
local go = mapCtrl.gameObject
|
||||
self:UnbindCtrlByNode(mapCtrl)
|
||||
destroy(go)
|
||||
end
|
||||
self.tbAllIndicators = {}
|
||||
self.mapActiveIndicator = {}
|
||||
self.tbPoolBossIndicator = {}
|
||||
end
|
||||
return HintIndicators
|
||||
@@ -0,0 +1,115 @@
|
||||
local MonsterSkillHintIndicator = class("MonsterSkillHintIndicator", BaseCtrl)
|
||||
MonsterSkillHintIndicator._mapNodeConfig = {
|
||||
imgIcon = {sComponentName = "Image"}
|
||||
}
|
||||
MonsterSkillHintIndicator._mapEventConfig = {}
|
||||
function MonsterSkillHintIndicator:Awake()
|
||||
self.animtor = self.gameObject:GetComponent("Animator")
|
||||
self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
|
||||
self.nEntityId = nil
|
||||
end
|
||||
function MonsterSkillHintIndicator:FadeIn()
|
||||
end
|
||||
function MonsterSkillHintIndicator:FadeOut()
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnEnable()
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnDisable()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnDestroy()
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnRelease()
|
||||
end
|
||||
function MonsterSkillHintIndicator:SetTarget(nEntityId, _, bHold, fRecycleCallback)
|
||||
if self.nEntityId ~= nil then
|
||||
printError("重复绑定")
|
||||
return
|
||||
end
|
||||
self.fRecycleCallback = fRecycleCallback
|
||||
self.nEntityId = nEntityId
|
||||
self.bHold = bHold
|
||||
EventManager.AddEntityEvent("AttackHintCancel", self.nEntityId, self, self.OnEvent_SkillCancel)
|
||||
EventManager.AddEntityEvent("AttackHint", self.nEntityId, self, self.OnEvent_SkillHint)
|
||||
EventManager.AddEntityEvent("AttackHintEnd", self.nEntityId, self, self.OnEvent_SkillEnd)
|
||||
EventManager.AddEntityEvent("AttackHintShow", self.nEntityId, self, self.OnEvent_HintShow)
|
||||
EventManager.AddEntityEvent("AttackHintHide", self.nEntityId, self, self.OnEvent_HintHide)
|
||||
NovaAPI.SetSkillIndicatorTarget(nEntityId, self.gameObject, Vector3.zero)
|
||||
self.gameObject:SetActive(self.bHold)
|
||||
if self.bHold then
|
||||
self.animtor:Play("TemplateMonster_in")
|
||||
end
|
||||
NovaAPI.SetComponentEnable(self._mapNode.imgIcon, false)
|
||||
end
|
||||
function MonsterSkillHintIndicator:UnBindEvent()
|
||||
if self.nEntityId == nil then
|
||||
return
|
||||
end
|
||||
if self.endTimer ~= nil then
|
||||
self.endTimer:Cancel()
|
||||
end
|
||||
EventManager.RemoveEntityEvent("AttackHintCancel", self.nEntityId, self, self.OnEvent_SkillCancel)
|
||||
EventManager.RemoveEntityEvent("AttackHint", self.nEntityId, self, self.OnEvent_SkillHint)
|
||||
EventManager.RemoveEntityEvent("AttackHintEnd", self.nEntityId, self, self.OnEvent_SkillEnd)
|
||||
EventManager.RemoveEntityEvent("AttackHintShow", self.nEntityId, self, self.OnEvent_HintShow)
|
||||
EventManager.RemoveEntityEvent("AttackHintHide", self.nEntityId, self, self.OnEvent_HintHide)
|
||||
if self.fRecycleCallback ~= nil then
|
||||
self.fRecycleCallback(self.nEntityId, self, self.bHold)
|
||||
self.fRecycleCallback = nil
|
||||
end
|
||||
self.nEntityId = nil
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnEvent_SkillHint()
|
||||
if self.endTimer ~= nil then
|
||||
printError("已在技能结束处理中")
|
||||
return
|
||||
end
|
||||
self.gameObject:SetActive(true)
|
||||
NovaAPI.SetComponentEnable(self._mapNode.imgIcon, true)
|
||||
if self.bHold then
|
||||
self.animtor:Play("TemplateMonster_loop")
|
||||
else
|
||||
self.animtor:Play("TemplateMonster_Hint")
|
||||
end
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnEvent_SkillEnd()
|
||||
if self.endTimer ~= nil then
|
||||
printError("已在技能结束处理中")
|
||||
return
|
||||
end
|
||||
self.animtor:Play("TemplateMonster_out")
|
||||
local EndCallBack = function()
|
||||
if self.bHold then
|
||||
self.animtor:Play("TemplateMonster_in")
|
||||
NovaAPI.SetComponentEnable(self._mapNode.imgIcon, false)
|
||||
else
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
self.endTimer = nil
|
||||
end
|
||||
self.endTimer = self:AddTimer(1, 0.2, EndCallBack, true, true, nil, true)
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnEvent_SkillCancel()
|
||||
if self.endTimer ~= nil then
|
||||
self.endTimer:Cancel()
|
||||
end
|
||||
if self.bHold then
|
||||
self.animtor:Play("TemplateMonster_in")
|
||||
NovaAPI.SetComponentEnable(self._mapNode.imgIcon, false)
|
||||
else
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
self.endTimer = nil
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnEvent_HintShow()
|
||||
local indicatorBase = self.gameObject:GetComponent("IndicatorBase")
|
||||
indicatorBase:SetLogicHide(false)
|
||||
end
|
||||
function MonsterSkillHintIndicator:OnEvent_HintHide()
|
||||
local indicatorBase = self.gameObject:GetComponent("IndicatorBase")
|
||||
indicatorBase:SetLogicHide(true)
|
||||
end
|
||||
function MonsterSkillHintIndicator:MonsterDied()
|
||||
self:UnBindEvent()
|
||||
end
|
||||
return MonsterSkillHintIndicator
|
||||
Reference in New Issue
Block a user