miduo_client/Assets/ManagedResources/~Lua/Modules/Fight/FightEndLvUpPanel.lua

182 lines
7.1 KiB
Lua
Raw Normal View History

2025-03-14 11:58:20 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
FightEndLvUpPanel = Inherit(BasePanel)
2024-09-06 10:38:56 +08:00
local this = FightEndLvUpPanel
2020-05-09 13:31:21 +08:00
local oldLevel
local curLevel
local callBack
local orginLayer
local SkeletonGraphic
local idleFunc = function()
SkeletonGraphic.AnimationState:SetAnimation(0, "idle2", true)
end
--初始化组件(用于子类重写)
function FightEndLvUpPanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
orginLayer = 0
this.maskBtn = Util.GetGameObject(self.transform, "maskBtn")
this.nameText = Util.GetGameObject(self.transform, "bg/nameImage/nameText"):GetComponent("Text")
this.lvNum = Util.GetGameObject(self.transform, "bg/lvNum/Text"):GetComponent("Text")
this.curLvOpenFun = Util.GetGameObject(self.transform, "bg/openFun/curLvOpenFun")
this.curLvOpenFun:SetActive(false)
this.curopenListPre = Util.GetGameObject(self.transform, "bg/openFun/curLvOpenFun/openList/viewPort/content")
this.itemPro = Util.GetGameObject(self.transform, "bg/openFun/curLvOpenFun/openList/viewPort/itemPro")
this.itemPro.gameObject:SetActive(false)
this.nextLvOpenFun = Util.GetGameObject(self.transform, "bg/openFun/nextLvOpenFun")
this.nextLvOpenFun:SetActive(false)
this.nextopenListPre = Util.GetGameObject(self.transform, "bg/openFun/nextLvOpenFun/openList/viewPort/content")
2021-01-26 17:08:39 +08:00
if GetCurLanguage() == 0 then
2025-01-17 16:26:21 +08:00
this.roleEffect = Util.GetGameObject(self.transform, "bg/npc_en")
2024-09-06 10:38:56 +08:00
elseif GetCurLanguage() == 2 then
this.roleEffect = Util.GetGameObject(self.transform, "bg/npc_en")
2021-02-18 17:21:14 +08:00
else
2024-09-06 10:38:56 +08:00
this.roleEffect = Util.GetGameObject(self.transform, "bg/npc_en")
2021-01-26 17:08:39 +08:00
end
2024-09-06 10:38:56 +08:00
this.roleEffect.gameObject:SetActive(true)
2020-05-09 13:31:21 +08:00
SkeletonGraphic = this.roleEffect:GetComponent("SkeletonGraphic")
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idleFunc
end
local NpcAnimDef = {
2024-09-06 10:38:56 +08:00
idle1 = { name = "idle1", y = 0 },
idle2 = { name = "idle2", y = 0 },
2020-05-09 13:31:21 +08:00
}
--绑定事件(用于子类重写)
function FightEndLvUpPanel:BindEvent()
Util.AddClick(this.maskBtn, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function FightEndLvUpPanel:AddListener()
end
--移除事件监听(用于子类重写)
function FightEndLvUpPanel:RemoveListener()
end
2024-09-06 10:38:56 +08:00
2024-04-26 18:20:14 +08:00
local soliderAutoTimer
2020-05-09 13:31:21 +08:00
--界面打开时调用(用于子类重写)
function FightEndLvUpPanel:OnOpen(...)
SoundManager.PlaySound(SoundConfig.Sound_UpLevel)
2024-09-06 10:38:56 +08:00
local data = { ... }
2020-05-09 13:31:21 +08:00
if #data < 1 then
return
end
2024-09-06 10:38:56 +08:00
oldLevel = data[1]
curLevel = data[2]
2020-05-09 13:31:21 +08:00
callBack = data[3]
2024-04-24 18:11:52 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnLevelChange)
2024-09-06 10:38:56 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend, FacePanelType.UpgradePac)
2020-05-09 13:31:21 +08:00
this.ShowPanelData()
2024-09-06 10:38:56 +08:00
SubmitExtraData({ type = SDKSubMitType.TYPE_LEVEL_UP })
2020-05-09 13:31:21 +08:00
--TalentManager.SetLevelEffect()
end
function FightEndLvUpPanel:OnShow()
local SkeletonGraphic = this.roleEffect:GetComponent("SkeletonGraphic")
SkeletonGraphic.AnimationState:SetAnimation(0, "idle1", false)
2024-04-26 18:20:14 +08:00
if SmallSoldierManager.isAuto then
2024-09-06 10:38:56 +08:00
soliderAutoTimer = Timer.New(function()
2024-04-26 18:20:14 +08:00
self:ClosePanel()
end, 3):Start()
end
2020-05-09 13:31:21 +08:00
end
function FightEndLvUpPanel:OnSortingOrderChange()
Util.AddParticleSortLayer(self.gameObject, self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
end
2024-09-06 10:38:56 +08:00
function this.ShowPanelData()
this.nameText.text = PlayerManager.nickName
2024-11-19 15:31:33 +08:00
this.lvNum.text = GetLanguageStrById("等级提升至%s级!"):format(curLevel)
2020-05-09 13:31:21 +08:00
this.ShowPlayerAndLevelPassOpenFun()
end
2024-09-06 10:38:56 +08:00
2020-05-09 13:31:21 +08:00
function this.ShowPlayerAndLevelPassOpenFun()
local openFunDataList = FightManager.GetPlayerAndLevelPassOpenFun(curLevel)
if openFunDataList and #openFunDataList > 0 then
this.curLvOpenFun:SetActive(true)
Util.ClearChild(this.curopenListPre.transform)
for i = 1, #openFunDataList do
local go = newObjToParent(this.itemPro.gameObject, this.curopenListPre.gameObject)
2024-09-20 11:45:46 +08:00
Util.GetGameObject(go, "name"):GetComponent("Text").text = GetLanguageStrById(openFunDataList[i].Name)
2024-04-23 18:56:18 +08:00
Util.GetGameObject(go, "name"):SetActive(true)
2024-09-06 10:38:56 +08:00
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(
GetQuantityImageByquality(1))
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite =
2024-09-06 10:38:56 +08:00
this.spLoader:LoadSprite(GetResourcePath(openFunDataList[i].OpenShow))
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go, "icon"):GetComponent("Image"):SetNativeSize()
2024-09-06 10:38:56 +08:00
local iconTextImage = Util.GetGameObject(go, "icon/iconTextImage")
2020-05-09 13:31:21 +08:00
if openFunDataList[i].scriptshow and openFunDataList[i].scriptshow > 0 then
iconTextImage:SetActive(true)
iconTextImage:GetComponent("Image").sprite =
2024-09-06 10:38:56 +08:00
this.spLoader:LoadSprite(GetResourcePath(openFunDataList[i].scriptshow))
2020-05-09 13:31:21 +08:00
else
iconTextImage:SetActive(false)
end
end
else
this.curLvOpenFun:SetActive(false)
end
2024-09-06 10:38:56 +08:00
local needLv, nextFunDataList = FightManager.GetNextPlayerAndLevelPassOpenFun(curLevel)
2020-05-09 13:31:21 +08:00
if nextFunDataList and #nextFunDataList > 0 then
this.nextLvOpenFun:SetActive(true)
2024-09-06 10:38:56 +08:00
Util.GetGameObject(this.nextLvOpenFun, "openLock/Text"):GetComponent("Text").text = Language[10539] ..
needLv ..
Language
2024-09-20 11:45:46 +08:00
[10738] -- needLv..级
2020-05-09 13:31:21 +08:00
Util.ClearChild(this.nextopenListPre.transform)
for i = 1, #nextFunDataList do
local go = newObjToParent(this.itemPro.gameObject, this.nextopenListPre.gameObject)
2024-04-23 18:56:18 +08:00
Util.GetGameObject(go, "name"):SetActive(true)
2024-09-20 11:45:46 +08:00
Util.GetGameObject(go, "name"):GetComponent("Text").text = GetLanguageStrById(nextFunDataList[i].Name)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite =
2024-09-06 10:38:56 +08:00
this.spLoader:LoadSprite(GetQuantityImageByquality(1))
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite =
2024-09-06 10:38:56 +08:00
this.spLoader:LoadSprite(GetResourcePath(nextFunDataList[i].OpenShow))
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go, "icon"):GetComponent("Image"):SetNativeSize()
2024-09-06 10:38:56 +08:00
local iconTextImage = Util.GetGameObject(go, "icon/iconTextImage")
2020-05-09 13:31:21 +08:00
if nextFunDataList[i].scriptshow and nextFunDataList[i].scriptshow > 0 then
iconTextImage:SetActive(true)
iconTextImage:GetComponent("Image").sprite =
2024-09-06 10:38:56 +08:00
this.spLoader:LoadSprite(GetResourcePath(nextFunDataList[i].scriptshow))
2020-05-09 13:31:21 +08:00
else
iconTextImage:SetActive(false)
end
end
else
this.nextLvOpenFun:SetActive(false)
end
end
2024-09-06 10:38:56 +08:00
2020-05-09 13:31:21 +08:00
--界面关闭时调用(用于子类重写)
function FightEndLvUpPanel:OnClose()
if callBack then
callBack()
end
2024-04-26 18:20:14 +08:00
if soliderAutoTimer then
soliderAutoTimer:Stop()
2024-09-06 10:38:56 +08:00
soliderAutoTimer = nil
2024-04-26 18:20:14 +08:00
end
2020-12-24 16:06:10 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend, FacePanelType.UpgradePac)
2020-05-09 13:31:21 +08:00
end
--界面销毁时调用(用于子类重写)
function FightEndLvUpPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idleFunc
end
2024-09-06 10:38:56 +08:00
return FightEndLvUpPanel