182 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			182 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Lua
		
	
require("Base/BasePanel")
 | 
						|
local BattleBossInfoPanel = Inherit(BasePanel)
 | 
						|
local func
 | 
						|
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
 | 
						|
local BossConfig = ConfigManager.GetConfig(ConfigName.MainLevelBossConfig)
 | 
						|
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
 | 
						|
local bgName
 | 
						|
local Live
 | 
						|
local orginLayer = 0
 | 
						|
 | 
						|
--初始化组件(用于子类重写)
 | 
						|
function BattleBossInfoPanel:InitComponent()
 | 
						|
    self.spLoader = SpriteLoader.New()
 | 
						|
    self.btnBack = Util.GetGameObject(self.gameObject,"mask")
 | 
						|
    self.mask2 = Util.GetGameObject(self.gameObject,"mask2")
 | 
						|
    self.root = Util.GetGameObject(self.gameObject,"animation/bossRoot")
 | 
						|
    self.liveroot = Util.GetGameObject(self.gameObject,"animation/bossRoot/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")
 | 
						|
 | 
						|
    self.Text = Util.GetGameObject(self.gameObject,"content/Text"):GetComponent("Text")
 | 
						|
    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")
 | 
						|
    
 | 
						|
    self.effect = Util.GetGameObject(self.gameObject,"UI_effect_RecruitPanel_particle")
 | 
						|
 | 
						|
    self.Img1 = Util.GetGameObject(self.gameObject,"bg2/Image1"):GetComponent("Image")
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
--绑定事件(用于子类重写)
 | 
						|
function BattleBossInfoPanel:BindEvent()
 | 
						|
    Util.AddClick(self.btnBack,function ()
 | 
						|
        if self.timer1 then
 | 
						|
            self.timer1:Stop()
 | 
						|
            self.timer1 = nil
 | 
						|
        end
 | 
						|
        self.Img1:DOFade(0,0.7)
 | 
						|
        if self.timer2 then
 | 
						|
            self.timer2:Stop()
 | 
						|
            self.timer2 = nil
 | 
						|
        end
 | 
						|
        self.effect:SetActive(false)
 | 
						|
        PlayUIAnim(self.ani1)
 | 
						|
        PlayUIAnim(self.ani2)
 | 
						|
        Timer.New(function ()
 | 
						|
            self:ClosePanel()
 | 
						|
        end,0.7):Start()
 | 
						|
    end)
 | 
						|
end
 | 
						|
 | 
						|
--添加事件监听(用于子类重写)
 | 
						|
function BattleBossInfoPanel:AddListener()
 | 
						|
end
 | 
						|
 | 
						|
--移除事件监听(用于子类重写)
 | 
						|
function BattleBossInfoPanel:RemoveListener()
 | 
						|
end
 | 
						|
 | 
						|
function BattleBossInfoPanel:OnSortingOrderChange()
 | 
						|
    Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
 | 
						|
    orginLayer = self.sortingOrder
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
--界面打开时调用(用于子类重写)
 | 
						|
function BattleBossInfoPanel:OnOpen(...)
 | 
						|
    func = ...
 | 
						|
    orginLayer = 0
 | 
						|
end
 | 
						|
 | 
						|
-- 打开,重新打开时回调
 | 
						|
function BattleBossInfoPanel:OnShow()
 | 
						|
 | 
						|
    PlayerPrefs.SetInt(PlayerManager.uid.."BattleBossShow"..FightPointPassManager.curOpenFight,1)
 | 
						|
    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)
 | 
						|
    local bossDataInHero = ConfigManager.GetConfigDataByKey(ConfigName.HeroConfig,"Id",data.BossPreview)
 | 
						|
    local time = bossData.Time/1000
 | 
						|
    self.mask2:SetActive(true)
 | 
						|
    Timer.New(function ()
 | 
						|
        self.mask2:SetActive(false)
 | 
						|
    end,1):Start()
 | 
						|
    self.timer1 = Timer.New(function ()
 | 
						|
        PlayUIAnim(self.ani1)
 | 
						|
        PlayUIAnim(self.ani2)
 | 
						|
        self.effect:SetActive(false)
 | 
						|
        if self.timer2 then
 | 
						|
            self.timer2:Stop()
 | 
						|
            self.timer2 = nil
 | 
						|
        end
 | 
						|
        self.Img1:DOFade(0,0.7)
 | 
						|
        Timer.New(function ()
 | 
						|
            self:ClosePanel()
 | 
						|
        end,0.7):Start()
 | 
						|
    end,time)
 | 
						|
    self.timer1:Start()
 | 
						|
 | 
						|
    local thread2=coroutine.start(function()
 | 
						|
        coroutine.wait(0.5)
 | 
						|
        self.Img1:DOFade(0.4,1)
 | 
						|
        coroutine.wait(1)
 | 
						|
        self.Img1:DOFade(1,1)
 | 
						|
        coroutine.wait(1)
 | 
						|
    end)
 | 
						|
    self.timer2 = Timer.New(function ()
 | 
						|
        local thread=coroutine.start(function()
 | 
						|
            self.Img1:DOFade(0.4,1)
 | 
						|
            coroutine.wait(1)
 | 
						|
            self.Img1:DOFade(1,1)
 | 
						|
            coroutine.wait(1)
 | 
						|
        end)
 | 
						|
    end, 2, 4, true)
 | 
						|
    self.timer2:Start()
 | 
						|
 | 
						|
    --Pos
 | 
						|
    self.nameZh.text = heroData.ReadingName
 | 
						|
    self.posTextZh.text = heroData.HeroLocation
 | 
						|
    self.nameOther.text = GetLanguageStrById(heroData.ReadingName)
 | 
						|
    self.posTextOther.text = GetLanguageStrById(heroData.HeroLocation)
 | 
						|
 | 
						|
    self.nameZh.gameObject:SetActive(GetCurLanguage() == 0)
 | 
						|
    self.posTextZh.gameObject:SetActive(GetCurLanguage() == 0)
 | 
						|
    self.nameOther.gameObject:SetActive(GetCurLanguage() ~= 0)
 | 
						|
    self.posTextOther.gameObject:SetActive(GetCurLanguage() ~= 0)
 | 
						|
 | 
						|
    self.posImg.sprite = self.spLoader:LoadSprite(GetHeroPosStr(heroData.Profession))
 | 
						|
    self.posImgDi.sprite = self.spLoader:LoadSprite(GetHeroPosBgStr(heroData.Profession))
 | 
						|
 | 
						|
    --Root
 | 
						|
    bgName =  artConfig[HeroConfig[data.BossPreview].Live].Name
 | 
						|
    local pos = bossDataInHero.Position
 | 
						|
    local scale = bossDataInHero.Scale
 | 
						|
    if Live then
 | 
						|
        poolManager:UnLoadLive(bgName, Live)
 | 
						|
        Live = nil
 | 
						|
    end
 | 
						|
    Live = poolManager:LoadLive(bgName, self.liveroot.transform, Vector3.one, Vector2.New(pos[1],pos[2]))
 | 
						|
    self.root.transform.localScale = Vector3.one*scale
 | 
						|
 | 
						|
    --Bottom
 | 
						|
    self.skillText.text = GetLanguageStrById(bossData.Skilltips)
 | 
						|
    self.talismanText.text = GetLanguageStrById(bossData.Treasuretips)
 | 
						|
    self.Text.text = GetLanguageStrById(bossData.HeroLocationDesc1)
 | 
						|
 | 
						|
    
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
--界面关闭时调用(用于子类重写)
 | 
						|
function BattleBossInfoPanel:OnClose()
 | 
						|
    if self.timer1 then
 | 
						|
        self.timer1:Stop()
 | 
						|
        self.timer1 = nil
 | 
						|
    end
 | 
						|
    if self.timer2 then
 | 
						|
        self.timer2:Stop()
 | 
						|
        self.timer2 = nil
 | 
						|
    end
 | 
						|
    if func then
 | 
						|
        func()
 | 
						|
    end
 | 
						|
    if Live then
 | 
						|
        poolManager:UnLoadLive(bgName, Live)
 | 
						|
        Live = nil
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
--界面销毁时调用(用于子类重写)
 | 
						|
function BattleBossInfoPanel:OnDestroy()
 | 
						|
    self.spLoader:Destroy()
 | 
						|
end
 | 
						|
 | 
						|
return BattleBossInfoPanel |