miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/View/BattleBossInfoPanel.lua

137 lines
5.1 KiB
Lua
Raw Normal View History

2021-02-22 20:19:16 +08:00
require("Base/BasePanel")
local BattleBossInfoPanel = Inherit(BasePanel)
local func
2021-02-25 21:08:11 +08:00
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local BossConfig = ConfigManager.GetConfig(ConfigName.MainLevelBossConfig)
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local bgName
local Live
2021-02-26 11:03:14 +08:00
local orginLayer = 0
2021-02-22 20:19:16 +08:00
--初始化组件(用于子类重写)
function BattleBossInfoPanel:InitComponent()
2021-02-25 21:08:11 +08:00
self.btnBack = Util.GetGameObject(self.gameObject,"mask")
2021-02-26 14:07:22 +08:00
self.root = Util.GetGameObject(self.gameObject,"animation/root")
self.nameImg = Util.GetGameObject(self.gameObject,"bg2/content/Pos/NameImg"):GetComponent("Image")
self.nameZh = Util.GetGameObject(self.gameObject,"bg2/content/Pos/NameZh"):GetComponent("Text")
self.nameOther = Util.GetGameObject(self.gameObject,"bg2/content/Pos/NameOther"):GetComponent("Text")
self.posImg = Util.GetGameObject(self.gameObject,"bg2/content/Pos/PosImage"):GetComponent("Image")
self.posImgDi = Util.GetGameObject(self.gameObject,"bg2/content/Pos/PosImgDi"):GetComponent("Image")
self.posTextZh = Util.GetGameObject(self.gameObject,"bg2/content/Pos/PosTextZh"):GetComponent("Text")
self.posTextOther = Util.GetGameObject(self.gameObject,"bg2/content/Pos/PosTexOther"):GetComponent("Text")
2021-02-25 21:08:11 +08:00
self.skillText = Util.GetGameObject(self.gameObject,"content/Detail/skill/Text"):GetComponent("Text")
self.talismanText = Util.GetGameObject(self.gameObject,"content/Detail/talisman/Text"):GetComponent("Text")
self.ani1 = Util.GetGameObject(self.gameObject,"ani")
self.ani2 = Util.GetGameObject(self.gameObject,"ani2")
2021-02-26 11:03:14 +08:00
self.effect = Util.GetGameObject(self.gameObject,"UI_effect_RecruitPanel_particle")
2021-02-26 14:07:22 +08:00
self.Img1 = Util.GetGameObject(self.gameObject,"bg2/Image1"):GetComponent("RectTransform")
self.Img2 = Util.GetGameObject(self.gameObject,"bg2/Image2"):GetComponent("RectTransform")
self.Img3 = Util.GetGameObject(self.gameObject,"bg2/Image3"):GetComponent("RectTransform")
2021-02-22 20:19:16 +08:00
end
--绑定事件(用于子类重写)
function BattleBossInfoPanel:BindEvent()
Util.AddClick(self.btnBack,function ()
2021-02-26 14:07:22 +08:00
if self.timer1 then
self.timer1:Stop()
self.timer1 = nil
end
2021-02-25 21:08:11 +08:00
PlayUIAnim(self.ani1)
PlayUIAnim(self.ani2)
Timer.New(function ()
self:ClosePanel()
end,0.7):Start()
2021-02-22 20:19:16 +08:00
end)
end
--添加事件监听(用于子类重写)
function BattleBossInfoPanel:AddListener()
end
--移除事件监听(用于子类重写)
function BattleBossInfoPanel:RemoveListener()
end
function BattleBossInfoPanel:OnSortingOrderChange()
2021-02-26 11:03:14 +08:00
Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
2021-02-22 20:19:16 +08:00
end
--界面打开时调用(用于子类重写)
function BattleBossInfoPanel:OnOpen(...)
func = ...
2021-02-26 11:03:14 +08:00
orginLayer = 0
2021-02-22 20:19:16 +08:00
end
-- 打开,重新打开时回调
function BattleBossInfoPanel:OnShow()
2021-02-26 11:03:14 +08:00
self.timer1 = Timer.New(function ()
2021-02-25 21:08:11 +08:00
PlayUIAnim(self.ani1)
PlayUIAnim(self.ani2)
Timer.New(function ()
self:ClosePanel()
end,0.7):Start()
2021-02-26 11:03:14 +08:00
end,10)
self.timer1:Start()
2021-02-25 21:08:11 +08:00
local data = ConfigManager.GetConfigData(ConfigName.MainLevelConfig,FightPointPassManager.curOpenFight)
local heroData = ConfigManager.GetConfigData(ConfigName.HeroConfig,data.BossPreview)
local bossData = ConfigManager.GetConfigDataByKey(ConfigName.MainLevelBossConfig,"HeroId",data.BossPreview)
--Pos
local GetcurLanguage = 0
self.nameZh.text = heroData.ReadingName
self.posTextZh.text = heroData.HeroLocation
self.nameOther.text = heroData.ReadingName
self.posTextOther.text = heroData.ShowHeroLocation
self.nameZh.gameObject:SetActive(GetcurLanguage == 0)
self.posTextZh.gameObject:SetActive(GetcurLanguage == 0)
self.nameOther.gameObject:SetActive(GetcurLanguage ~= 0)
self.posTextOther.gameObject:SetActive(GetcurLanguage ~= 0)
2021-02-26 11:03:14 +08:00
self.posImg.sprite = Util.LoadSprite(GetHeroPosStr(heroData.Profession))
self.posImgDi.sprite = Util.LoadSprite(GetHeroPosBgStr(heroData.Profession))
2021-02-25 21:08:11 +08:00
2021-02-26 11:03:14 +08:00
--Root
2021-02-25 21:08:11 +08:00
bgName = artConfig[HeroConfig[data.BossPreview].Live].Name
2021-02-26 11:03:14 +08:00
local pos = bossData.Position
local scale = bossData.Scale
2021-02-25 21:08:11 +08:00
if Live then
poolManager:UnLoadLive(bgName, Live)
end
Live = poolManager:LoadLive(bgName, self.root.transform, Vector3.one*scale, Vector2.New(pos[1],pos[2]))
--Bottom
self.skillText.text = bossData.Skilltips
self.talismanText.text = bossData.Treasuretips
2021-02-26 14:07:22 +08:00
--bg
self.Img1:DOShakeAnchorPos(10, Vector2.New(10, 10), 1, 50, false, false)
self.Img2:DOShakeAnchorPos(10, Vector2.New(10, 10), 1, 50, false, false)
self.Img3:DOShakeAnchorPos(10, Vector2.New(10, 10), 1, 50, false, false)
2021-02-22 20:19:16 +08:00
end
--界面关闭时调用(用于子类重写)
function BattleBossInfoPanel:OnClose()
2021-02-26 11:03:14 +08:00
if self.timer1 then
self.timer1:Stop()
self.timer1 = nil
end
2021-02-22 20:19:16 +08:00
if func then
func()
end
2021-02-25 21:08:11 +08:00
if Live then
poolManager:UnLoadLive(bgName, Live)
end
2021-02-22 20:19:16 +08:00
end
--界面销毁时调用(用于子类重写)
function BattleBossInfoPanel:OnDestroy()
end
return BattleBossInfoPanel