miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/TalismanInfoPopup.lua

187 lines
7.4 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
----- 通用弹窗 -----
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
TalismanInfoPopup = Inherit(BasePanel)
local this=TalismanInfoPopup
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local passiveSkillConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local propertyConfig=ConfigManager.GetConfig(ConfigName.PropertyConfig)
local artResourcesConfig=ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local curHeroData--当前英雄数据
local curHeroConfig
local proList = {}--属性容器
local Type=0
local TypeLv=0
function TalismanInfoPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.backBtn=Util.GetGameObject(this.gameObject,"Panel/BackBtn")
this.backBtn2=Util.GetGameObject(this.gameObject,"Mask")
2020-05-09 13:31:21 +08:00
this.title=Util.GetGameObject(this.gameObject,"Panel/Title"):GetComponent("Text")
--滚动条
this.content=Util.GetGameObject(this.gameObject,"Panel/ScrollView/Viewport/Content"):GetComponent("RectTransform")
this.core=Util.GetGameObject(this.gameObject,"Panel/ScrollView/Viewport/Content/Core")
this.coreText=Util.GetGameObject(this.core,"Info"):GetComponent("Text")
this.talismanIcon = Util.GetGameObject(this.core, "TalismanRoot/Icon"):GetComponent("Image")
this.power=Util.GetGameObject(this.core,"TalismanRoot/Power/Value"):GetComponent("Text")
this.basics=Util.GetGameObject(this.gameObject,"Panel/ScrollView/Viewport/Content/Basics")
--属性预设
this.proPre=Util.GetGameObject(this.basics,"Root/ProPre")
--属性列表父物体
this.proRoot=Util.GetGameObject(this.basics,"Root")
this.dower=Util.GetGameObject(this.gameObject,"Panel/ScrollView/Viewport/Content/Dower")
this.dowerText=Util.GetGameObject(this.dower,"Mask/Text"):GetComponent("Text")
end
function TalismanInfoPopup:BindEvent()
--返回按钮
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
Util.AddClick(this.backBtn2,function()
self:ClosePanel()
end)
2020-05-09 13:31:21 +08:00
end
function TalismanInfoPopup:AddListener()
end
function TalismanInfoPopup:RemoveListener()
end
function TalismanInfoPopup:OnSortingOrderChange()
this.sortingOrder = self.sortingOrder
end
function TalismanInfoPopup:OnOpen(...)
local args={...}
curHeroData=args[1]
if args[2] then
Type=1
curHeroConfig=args[1]
TypeLv = args[3]
end
2020-05-09 13:31:21 +08:00
end
function TalismanInfoPopup:OnShow()
this.Show()
end
function TalismanInfoPopup:OnClose()
end
function TalismanInfoPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
proList={}
end
--显示
function this.Show()
this.content:DOAnchorPosY(0, 0)
local data={}
local curLv--获取当前法宝等级
if Type==1 then
data = ConfigManager.GetConfigData(ConfigName.HeroConfig,curHeroConfig.Id).EquipTalismana--当前法宝数据 data[1]星级 data[2]法宝ID
curLv=TypeLv
else
data = ConfigManager.GetConfigData(ConfigName.HeroConfig,curHeroData.id).EquipTalismana--当前法宝数据 data[1]星级 data[2]法宝ID
curLv=HeroManager.GetTalismanLv(curHeroData.dynamicId)
2020-05-09 13:31:21 +08:00
end
--当前法宝数据
local curTalismanConFig= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",curLv)
--标题
2023-08-11 19:03:48 +08:00
this.title.text= string.format( "",GetLanguageStrById(itemConfig[data[2]].Name),curLv)
2021-04-21 13:12:04 +08:00
this.talismanIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[data[2]].ResourceID))
2020-05-09 13:31:21 +08:00
this.power.text = TalismanManager.CalculateWarForceBase(curTalismanConFig,0)--法宝战力
--显示核心特性(30级解锁)
2023-08-11 19:03:48 +08:00
local skillLv= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",30).OpenSkillRules[1]
2020-05-09 13:31:21 +08:00
if skillLv then
2023-08-11 19:03:48 +08:00
if curLv<30 then
this.coreText.text=string.format( Language[11532],GetLanguageStrById(passiveSkillConfig[skillLv].Desc),30)
2020-05-09 13:31:21 +08:00
else
2021-03-02 16:53:12 +08:00
this.coreText.text=string.format( "%s【%s】",GetLanguageStrById(passiveSkillConfig[skillLv].Desc),Language[11533])
2020-05-09 13:31:21 +08:00
end
end
2022-08-30 15:55:37 +08:00
--显示核心特性(50级解锁)
local skillLv_50= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",50).OpenSkillRules[1]
if skillLv_50 then
if curLv<50 then
this.coreText.text=this.coreText.text.."\n"..string.format( Language[11532],GetLanguageStrById(passiveSkillConfig[skillLv_50].Desc),50)
else
this.coreText.text=this.coreText.text.."\n"..string.format( "%s【%s】",GetLanguageStrById(passiveSkillConfig[skillLv_50].Desc),Language[11533])
end
end
2020-05-09 13:31:21 +08:00
--显示基础属性
for i=1,#curTalismanConFig.Property do
if not proList[i] then
proList[i]= newObjToParent(this.proPre,this.proRoot)
proList[i].name="ProPre"..i
end
local proName=proList[i]:GetComponent("Text")
local proImage=Util.GetGameObject(proList[i],"Image"):GetComponent("Image")
2023-11-06 14:55:59 +08:00
proImage.gameObject:SetActive(false)
2020-05-09 13:31:21 +08:00
local skillId=curTalismanConFig.Property[i][1]
local curValue=curTalismanConFig.Property[i][2]
2023-11-06 14:55:59 +08:00
--LogError("skillid===================="..skillId)
2021-11-12 09:55:00 +08:00
proName.text= " <size=40>"..GetLanguageStrById(propertyConfig[skillId].Info).."+"..curValue.."</size>"
2023-11-06 14:55:59 +08:00
--proImage.sprite=this.spLoader:LoadSprite(artResourcesConfig[propertyConfig[skillId].PropertyIcon].Name)
--Util.GetGameObject(proImage.gameObject,"Image"):GetComponent("Image"):SetNativeSize()
2020-05-09 13:31:21 +08:00
end
--显示法宝天赋
--筛选出符合要求的数据
local dowerAllData={}--当前法宝全部天赋数据(天赋可能为空)
dowerAllData= ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipTalismana,"TalismanaId",data[2])
local dowerData={}--当前法宝全部技能数据(天赋不为空)
2023-11-06 14:55:59 +08:00
--LogError("#dowerAllData==================================="..#dowerAllData)
2020-05-09 13:31:21 +08:00
for i=1,#dowerAllData do
if dowerAllData[i].OpenSkillRules then
table.insert( dowerData, dowerAllData[i])
end
end
2022-08-30 18:12:25 +08:00
table.sort(dowerData, function(a,b) return a.Level<b.Level end)
2020-05-09 13:31:21 +08:00
--赋值到表现
local strTable={}
2023-11-06 14:55:59 +08:00
local str=""
2020-05-09 13:31:21 +08:00
for n=1,#dowerData do
2022-08-30 18:12:25 +08:00
if dowerData[n].Level<=50 then
2023-11-06 14:55:59 +08:00
--LogError("dowerData[n].OpenSkillRules[1]======"..dowerData[n].OpenSkillRules[1])
2022-08-30 18:12:25 +08:00
if curLv>=dowerData[n].Level then
2023-11-06 14:55:59 +08:00
--LogError("dowerData[n].OpenSkillRules[1]]=="..dowerData[n].OpenSkillRules[1])
if passiveSkillConfig[dowerData[n].OpenSkillRules[1]] then
strTable[n]= string.format( Language[11534], dowerData[n].Level,GetLanguageStrById(passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc),"\n")
end
2022-08-30 18:12:25 +08:00
else
2023-11-06 14:55:59 +08:00
if passiveSkillConfig[dowerData[n].OpenSkillRules[1]] then
strTable[n]=string.format( Language[11535],dowerData[n].Level,GetLanguageStrById(passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc),"\n")
end
2022-08-30 18:12:25 +08:00
end
if dowerData[n].Level==30 or dowerData[n].Level==50 then
2023-11-06 14:55:59 +08:00
2022-08-30 18:12:25 +08:00
strTable[n]=string.gsub(strTable[n],"·","")
strTable[n]=Language[11536]..strTable[n]
2023-11-06 14:55:59 +08:00
str=str..strTable[n]
2022-08-30 18:12:25 +08:00
end
2020-05-09 13:31:21 +08:00
end
end
2023-11-06 14:55:59 +08:00
--str=table.concat(strTable)--将表里字符串拼接
2020-05-09 13:31:21 +08:00
--看这下面 是全角空格哦~
this.dowerText.text=string.sub(string.gsub(str," "," "),1,-2)--去除最后\n
end
2020-06-23 18:36:24 +08:00
return TalismanInfoPopup