miduo_client/Assets/ManagedResources/~Lua/Modules/Pokemon/PokemonUpStarSuccessPanel.lua

190 lines
8.3 KiB
Lua

require("Base/BasePanel")
PokemonUpStarSuccessPanel = Inherit(BasePanel)
local this=PokemonUpStarSuccessPanel
this.skillConfig=ConfigManager.GetConfig(ConfigName.SpiritAnimalSkill)
local passiveSkillConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local orginLayer = 20
local callBack = nil
local spiritAnimal = ConfigManager.GetConfig(ConfigName.SpiritAnimal)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local curPro = {}
local curProImage = {}
local nextPro = {}
--初始化组件(用于子类重写)
function PokemonUpStarSuccessPanel:InitComponent()
this.spLoader = SpriteLoader.New()
orginLayer = 20
this.BtnBack = Util.GetGameObject(self.transform, "backBtn")
this.mask = Util.GetGameObject(self.transform, "mask")
this.live2dRoot=Util.GetGameObject(self.transform,"live2dRoot")
this.starGrid = Util.GetGameObject(self.transform, "heroInfo/sartAndLvLayout")
this.heroName=Util.GetGameObject(self.transform,"Pos/PosText"):GetComponent("Text")
for i = 1, 4 do
curPro[i] = Util.GetGameObject(self.transform,"proInfo/GameObject/proInfo/curPros/otherPro ("..i..")")
curProImage[i] = Util.GetGameObject(curPro[i],"Image"):GetComponent("Image")
nextPro[i] = Util.GetGameObject(self.transform,"proInfo/GameObject/proInfo/nextPros/otherPro ("..i..")")
end
this.upLvShowGoText=Util.GetGameObject(self.transform,"proInfo/GameObject/proInfo/Text"):GetComponent("Text")
this.upLvShowGoText.text = Language[11430]
this.starEndText=Util.GetGameObject(self.transform, "proInfo/starEndText")
this.starEndText:GetComponent("Text").text = Language[11431]
this.skillImg=Util.GetGameObject(self.transform, "heroInfo/nameAndPossLayout/skill1"):GetComponent("Image")
this.skillImg1=Util.GetGameObject(self.transform, "heroInfo/nameAndPossLayout/skill2"):GetComponent("Image")
this.skillLvTxt1=Util.GetGameObject(self.transform, "heroInfo/nameAndPossLayout/lv1"):GetComponent("Text")
this.skillLvTxt2=Util.GetGameObject(self.transform, "heroInfo/nameAndPossLayout/lv2"):GetComponent("Text")
this.UI_Effect_choukaSSR = Util.GetGameObject(self.transform, "UI_Effect_chouka_SSR")
this.UI_Effect_choukaSR = Util.GetGameObject(self.transform, "UI_Effect_chouka_SR")
this.UI_Effect_choukaR = Util.GetGameObject(self.transform, "UI_Effect_chouka_R")
end
--绑定事件(用于子类重写)
function PokemonUpStarSuccessPanel:BindEvent()
Util.AddClick(this.BtnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function PokemonUpStarSuccessPanel:AddListener()
end
--移除事件监听(用于子类重写)
function PokemonUpStarSuccessPanel:RemoveListener()
end
function PokemonUpStarSuccessPanel:OnSortingOrderChange()
Util.AddParticleSortLayer(this.UI_Effect_choukaSSR, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.UI_Effect_choukaSR, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.UI_Effect_choukaR, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.starGrid, self.sortingOrder - orginLayer)
this.mask:GetComponent("Canvas").overrideSorting = true
this.mask:GetComponent("Canvas").sortingOrder = self.sortingOrder - 30
orginLayer = self.sortingOrder
end
--界面打开时调用(用于子类重写)
function PokemonUpStarSuccessPanel:OnOpen(_curPokemonData)
local curPokemonData = _curPokemonData
local curPokeponConfig = spiritAnimal[curPokemonData.id]
this.UI_Effect_choukaSSR:SetActive(curPokeponConfig.Quality == 5)
this.UI_Effect_choukaSR:SetActive(curPokeponConfig.Quality == 4)
this.UI_Effect_choukaR:SetActive(curPokeponConfig.Quality == 3)
this.LiveName = curPokemonData.live
this.LiveGO = poolManager:LoadLive(this.LiveName, this.live2dRoot.transform,
Vector3.one * curPokemonData.scale, Vector3.New(curPokemonData.position[1],curPokemonData.position[2],0))
local starSize = Vector2.New(60,60)
local starScale = -10
local starType=1
local star = curPokemonData.star
if star>5 then
starType=3
star=curPokemonData.star+5
starSize = Vector2.New(1,2) --控制大小
starScale = -5 --控制距离
else
--starSize=Vector2.New(60,60)
--starScale = 7
end
SetHeroStars(this.spLoader, this.starGrid, star,starType,starSize,starScale,Vector2.New(0.5,0.5))
Util.AddParticleSortLayer(this.starGrid, self.sortingOrder+1)
this.heroName.text = GetLanguageStrById(curPokeponConfig.Name)
SetTextVerTial(this.heroName,Vector3.New(101.68,10,0))
--如果是最大等级
local nextUpStarConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.SpiritAnimalStar,"Quality", spiritAnimal[curPokemonData.id].Quality, "Star", curPokemonData.star + 1)
if curPokemonData.star == curPokeponConfig.MaxStar then
this.starEndText:SetActive(true)
else
this.starEndText:SetActive(false)
end
--计算面板属性old
local oldLvAllAddProVal = PokemonManager.GetSinglePokemonAddProData(curPokemonData.dynamicId,curPokemonData.star - 1)
--计算面板属性cur
local curLvAllAddProVal = PokemonManager.GetSinglePokemonAddProData(curPokemonData.dynamicId,curPokemonData.star)
local index = 0
for key, value in pairs(oldLvAllAddProVal) do
index = index + 1
if curPro[index] then
Util.GetGameObject(curPro[index],"curProName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[key].Info)
Util.GetGameObject(curPro[index],"curProVale"):GetComponent("Text").text = value
Util.GetGameObject(curPro[index],"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(PropertyTypeIconDef[index])
end
end
local index2 = 0
for key, value in pairs(curLvAllAddProVal) do
index2 = index2 + 1
if nextPro[index2] then
Util.GetGameObject(nextPro[index2],"curProName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[key].Info)
Util.GetGameObject(nextPro[index2],"curProVale"):GetComponent("Text").text = value
end
end
-- for i = 1, 4 do
-- Util.GetGameObject(curPro[i],"curProName"):GetComponent("Text").text = propertyConfig[i].Info
-- Util.GetGameObject(curPro[i],"curProVale"):GetComponent("Text").text = oldLvAllAddProVal[i]
-- Util.GetGameObject(curPro[i],"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(PropertyTypeIconDef[i])
-- Util.GetGameObject(nextPro[i],"curProName"):GetComponent("Text").text = propertyConfig[i].Info
-- Util.GetGameObject(nextPro[i],"curProVale"):GetComponent("Text").text = curLvAllAddProVal[i]
-- end
local curSkillId = 0
local nextSkillId = 0
local skillArray = ConfigManager.GetConfigData(ConfigName.SpiritAnimal,curPokemonData.id).SkillArray
for i = 1, #skillArray do
LogPink("skillArray[i][1] "..skillArray[i][1])
if skillArray[i][1] == curPokemonData.star - 1 then
curSkillId = skillArray[i][2]
end
if skillArray[i][1] == curPokemonData.star then
nextSkillId = skillArray[i][2]
end
end
LogPink("curPokemonData.star "..curPokemonData.star.." curSkillId " .. curSkillId.." nextSkillId "..nextSkillId)
local curUpStarConfig = ConfigManager.GetConfigData(ConfigName.SpiritAnimalSkill,curSkillId)
local nextSkillConFig = ConfigManager.GetConfigData(ConfigName.SpiritAnimalSkill,nextSkillId)
this.skillImg1.sprite = this.spLoader:LoadSprite(GetResourcePath(nextSkillConFig.Icon))
this.skillLvTxt2.text = nextSkillConFig.Level
this.skillImg.sprite = this.spLoader:LoadSprite(GetResourcePath(curUpStarConfig.Icon))
this.skillLvTxt1.text = curUpStarConfig.Level
end
function PokemonUpStarSuccessPanel:GetEquipSkillData(skillId)
return this.skillConfig[skillId]
end
--界面关闭时调用(用于子类重写)
function PokemonUpStarSuccessPanel:OnClose()
if this.LiveName then
poolManager:UnLoadLive(this.LiveName, this.LiveGO)
this.LiveName = nil
end
if callBack then
callBack()
callBack = nil
end
end
--界面销毁时调用(用于子类重写)
function PokemonUpStarSuccessPanel:OnDestroy()
this.spLoader:Destroy()
end
return PokemonUpStarSuccessPanel