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

400 lines
17 KiB
Lua
Raw Normal View History

2023-10-26 17:16:10 +08:00
require("Base/BasePanel")
local FaLingStrongPopup = Inherit(BasePanel)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
local EquipStrengthen = ConfigManager.GetConfig(ConfigName.EquipStrengthen)
local EquipRankUp = ConfigManager.GetConfig(ConfigName.EquipRankUp)
local suitConFig = ConfigManager.GetConfig(ConfigName.EquipSuiteConfig)
2024-01-16 11:21:17 +08:00
local maxLv=tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,156).Value)
2023-10-26 17:16:10 +08:00
local _BaseProList = {}--基础属性对象
local _superProList = {}--白金属性对象
local _costProList = {} --护佑对象
local equipConfigData
local lv=0
local talismana
local selectMat={}
local isEnough = true
local typeToUpdate = {
[2] = 2,--已穿戴->卸载单件
[3] = 1,--未穿戴->穿单件
[4] = 3,--未穿戴->替换单件
}
--初始化组件(用于子类重写)
function FaLingStrongPopup:InitComponent()
self.spLoader = SpriteLoader.New()
self.mask = Util.GetGameObject(self.transform, "mask")
self.content = Util.GetGameObject(self.transform, "Content")
self.btn_close=Util.GetGameObject(self.transform, "Content/btn_close")
--装备详情--topBar
self.topBar = Util.GetGameObject(self.transform, "Content/topBar")
self.UI_effect_WuCai_Kuang = Util.GetGameObject(self.topBar, "UI_effect_WuCai_Kuang")
self.c_ui_qinyan_duan = Util.GetGameObject(self.topBar, "c_ui_qinyan_duan")
self.icon = Util.GetGameObject(self.topBar, "icon"):GetComponent("Image")
self.frame = Util.GetGameObject(self.topBar, "frame"):GetComponent("Image")
self.equipName=Util.GetGameObject(self.topBar, "name"):GetComponent("Text")
self.star=Util.GetGameObject(self.topBar, "star")
self.effectbaijin = Util.GetGameObject(self.topBar, "fx_zhuangbeijiemian")
self.hLv = Util.GetGameObject(self.topBar, "hLv"):GetComponent("Text")--家园摘星阁强化
self.hProLv = Util.GetGameObject(self.topBar, "hProLv"):GetComponent("Text")--家园摘星阁突破
--装备属性--midBar
--basePro
self.midBar = Util.GetGameObject(self.transform, "Content/midBar")
self.baseProGrid = Util.GetGameObject(self.topBar, "grid")
self.baseProPre = Util.GetGameObject(self.topBar, "grid/curProName")
self.baseProPre:SetActive(false)
self.btnJumpHome = Util.GetGameObject(self.homePro, "btnJump")
--superPro
self.superPro = Util.GetGameObject(self.midBar, "superPro")
2023-10-26 20:44:18 +08:00
self.superTitle = Util.GetGameObject(self.midBar, "superPro/Image/name"):GetComponent("Text")
2023-12-08 21:57:53 +08:00
self.superTitle.text="生命卡天赋"
2023-10-26 17:16:10 +08:00
self.superProGrid = Util.GetGameObject(self.superPro, "proGrid")
self.superProPre = Util.GetGameObject(self.superPro, "proGrid/Desc")
self.superProPre:SetActive(false)
--costpro
self.costPro = Util.GetGameObject(self.transform, "costPro")
2023-10-26 20:44:18 +08:00
self.costTitle = Util.GetGameObject(self.transform, "costPro/Image/name"):GetComponent("Text")
2023-10-26 17:16:10 +08:00
self.costTitle.text="强化要求"
self.costProGrid = Util.GetGameObject(self.costPro, "proGrid")
self.costProPre = Util.GetGameObject(self.costPro, "proGrid/item")
self.costProPre:SetActive(false)
self.coinImg = Util.GetGameObject(self.costPro, "coinImg"):GetComponent("Image")
self.coinTxt = Util.GetGameObject(self.costPro, "needCoin"):GetComponent("Text")
--分解按钮--btmBar
self.btnStrong=Util.GetGameObject(self.costPro, "btnStrong")
self.itemViewList={}
end
--绑定事件(用于子类重写)
function FaLingStrongPopup:BindEvent()
Util.AddClick(self.mask, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(self.btn_close, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(self.btnStrong, function()
if isEnough==false then
PopupTipPanel.ShowTip("强化材料不足")
return
end
NetManager.BaublesStrengthenRequest(self.equipData.did,1,selectMat,function()
selectMat={}
self:OnShow()
end)
end)
end
--添加事件监听(用于子类重写)
function FaLingStrongPopup:AddListener()
end
--移除事件监听(用于子类重写)
function FaLingStrongPopup:RemoveListener()
end
function FaLingStrongPopup:OnSortingOrderChange()
Util.SetParticleSortLayer(self.effectbaijin,self.sortingOrder + 1)
SetParticleSortLayer(self.c_ui_qinyan_duan,self.sortingOrder + 1)
SetParticleSortLayer(self.UI_effect_WuCai_Kuang,self.sortingOrder + 1)
end
2023-10-27 16:16:37 +08:00
local openPanel=nil
2023-10-26 17:16:10 +08:00
--界面打开时调用(用于子类重写)
2023-10-27 16:16:37 +08:00
function FaLingStrongPopup:OnOpen(_equipData,_openPanel)
2023-10-26 17:16:10 +08:00
if not _equipData then
return
end --父界面
2023-10-27 16:16:37 +08:00
openPanel=_openPanel
2023-10-26 17:16:10 +08:00
self.equipData = _equipData --当前装备数据
--0不显示按钮、1背包、2已穿戴显示卸下、3未穿戴显示穿戴、4未穿戴显示替换、5自己或其他人穿戴非装备界面但需要显示套装属性
2023-10-27 16:16:37 +08:00
--self.func = _func
2023-10-26 17:16:10 +08:00
end
function FaLingStrongPopup:ChangeSelectMat(_list)
selectMat=_list
end
function FaLingStrongPopup:OnShow()
--上部装备基础信息
self.equipData=FaLingManager.GetEquipDataByDid(self.equipData.did)
lv=self.equipData.lv
2023-10-27 14:10:43 +08:00
if lv>0 then
self.hLv.gameObject:SetActive(true)
else
self.hLv.gameObject:SetActive(false)
end
2023-10-26 17:16:10 +08:00
self.hLv.text=lv
Log("装备id:"..tostring(self.equipData.staticId).." openType:"..tostring(self.openType))
equipConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig, self.equipData.staticId)
local itemConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig,self.equipData.staticId)
local aaa=equipConfigData.Quantity
if equipConfigData.Quantity==8 then
aaa=7
end
--self.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_"..aaa)
self.c_ui_qinyan_duan:SetActive(equipConfigData.Quantity==8)
self.UI_effect_WuCai_Kuang:SetActive(equipConfigData.Quantity==7)
self.frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(equipConfigData.Quantity))
self.icon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfigData.ResourceID))
self.equipName.text = itemConfigData.Name
EquipManager.SetEquipStarShow(self.spLoader, self.star,equipConfigData.staticId)
--下部按钮信息
self.effectbaijin:SetActive(false)
--Util.SetParticleSortLayer(self.effectbaijin,self.sortingOrder + 1)
--basePro基础属性
LogError("lv========================"..lv)
talismana=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",self.equipData.staticId,"Level",lv)
2023-10-26 20:44:18 +08:00
local star=talismana.Star
if star>0 then
self.star:SetActive(true)
local starType=1
local starSize=nil
starType=3
2024-01-03 15:24:49 +08:00
star=star+10
2023-10-26 20:44:18 +08:00
starSize = Vector2.New(1,-13)
--starScale = 0
SetHeroStars(self.spLoader,self.star, star,starType,starSize,starScale)
Util.SetParticleSortLayer(self.star, self.sortingOrder + 3)
else
self.star:SetActive(false)
end
2023-10-26 17:16:10 +08:00
local nextLvData=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",self.equipData.staticId,"Level",lv+1)
2024-01-16 11:21:17 +08:00
if lv>=maxLv then
nextLvData=nil
end
2023-10-26 17:16:10 +08:00
self.btnStrong:SetActive(nextLvData~=nil)
for _, pro in ipairs(_BaseProList) do
pro:SetActive(false)
end
local num = 0
for i=1,#talismana.Property do
local prop=talismana.Property[i]
if tonumber(prop[1])~=nil then
local proConfigData = ConfigManager.GetConfigData(ConfigName.PropertyConfig, prop[1])
if proConfigData then
num = num + 1
--基础属性
if not _BaseProList[num] then
_BaseProList[num] = newObjToParent(self.baseProPre, self.baseProGrid)
end
_BaseProList[num]:SetActive(true)
local vText = Util.GetGameObject(_BaseProList[num], "curProVale"):GetComponent("Text")
vText.gameObject:SetActive(false)
local nText = Util.GetGameObject(_BaseProList[num], "nextProVale"):GetComponent("Text")
local addImg = Util.GetGameObject(_BaseProList[num], "Image")
-- Util.GetGameObject(vText.gameObject, "homeValue"):GetComponent("Text").text = ""--摘星阁加持文字显示位置
local str=nil
if prop[2] > 0 then
str = "+"..GetPropertyFormatStr(proConfigData.Style, prop[2])
else
str = GetPropertyFormatStr(proConfigData.Style, prop[2])
end
_BaseProList[num]:GetComponent("Text").text = GetLanguageStrById(proConfigData.Info)..":"..str
if nextLvData~=nil then
nText.gameObject:SetActive(true)
addImg:SetActive(true)
nText.text = GetPropertyFormatStr(proConfigData.Style,nextLvData.Property[i][2])
else
nText.gameObject:SetActive(false)
addImg:SetActive(false)
end
end
end
end
local lvList=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipTalismana,"TalismanaId",self.equipData.staticId)
local skillList={}
for i=1,#lvList do
if lvList[i].ShowSkill and #lvList[i].ShowSkill>0 and tonumber(lvList[i].ShowSkill[1])~=nil then
LogError("lvList[i].id======"..lvList[i].ShowSkill[3])
local skillData={}
skillData.id=lvList[i].ShowSkill[3]
skillData.state=0
skillData.des=passiveSkillConfig[skillData.id].Desc
2023-10-27 16:16:37 +08:00
skillData.openLv =lvList[i].Level
2023-10-26 17:16:10 +08:00
local type=lvList[i].ShowSkill[1]
if type==0 then
if lv>=lvList[i].Level then
skillData.state=1
end
elseif type==1 then
if lv>=lvList[i].Level and self.curHeroData and self.curHeroData.heroConfig.Profession==lvList[i].ShowSkill[2] then
skillData.state=1
end
2024-01-03 15:24:49 +08:00
skillData.des=skillData.des.."(".. ProfessionType[lvList[i].ShowSkill[2]].."职业佩戴后生效".. ")"
2023-10-26 17:16:10 +08:00
elseif type==2 then
if lv>=lvList[i].Level and self.curHeroData and self.curHeroData.staticId==lvList[i].ShowSkill[2] then
skillData.state=1
end
2024-01-03 15:24:49 +08:00
skillData.des=skillData.des.."(".. heroConfig[lvList[i].ShowSkill[2]].ReadingName .."佩戴后生效".. ")"
2023-10-26 17:16:10 +08:00
end
table.insert(skillList,skillData)
end
end
if #skillList>0 then
self.superPro:SetActive(true)
--if curGoldSuitConFig then
local goldSuiteSkill = skillList
local num=0
--LogError("curGoldSuitConFig.id======"..curGoldSuitConFig.Id.." curGoldSuitConFig skill len=="..#curGoldSuitConFig.SuiteSkill)
for i = 1, #goldSuiteSkill do
num = num + 1
if not _superProList[num] then
_superProList[num] = newObjToParent(self.superProPre, self.superProGrid)
end
_superProList[num].gameObject:SetActive(true)
local go = _superProList[num]
go.gameObject:SetActive(true)
local info = go:GetComponent("Text")
local skillData=goldSuiteSkill[i]
2023-10-27 16:16:37 +08:00
2023-10-26 17:16:10 +08:00
if skillData.state==1 then
2024-01-16 11:21:17 +08:00
info.text = string.format("<color=#1F9E46>%s</color>","["..skillData.openLv.."级开启]"..GetLanguageStrById(skillData.des))
2023-10-26 17:16:10 +08:00
else
2023-10-27 16:16:37 +08:00
info.text = string.format("<color=#574141>%s</color>","["..skillData.openLv.."级开启]"..GetLanguageStrById(skillData.des))
2023-10-26 17:16:10 +08:00
end
end
-- end
else
self.superPro:SetActive(false)
end
2024-01-16 11:21:17 +08:00
2023-10-26 17:16:10 +08:00
--消耗信息
self:ShowCostInfo()
--(此处需要三遍才能完全打开)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
if self.func then
self.func()
end
end
function FaLingStrongPopup:ShowCostInfo()
local cost=talismana.RankupBasicMaterial
local coinNum=0
isEnough=true
LogError("#cost len======================="..#cost)
if #cost>0 then
self.costPro:SetActive(true)
local num=0
for i = 1, #cost do
num = num + 1
if not _costProList[num] then
_costProList[num] = newObjToParent(self.costProPre, self.costProGrid)
end
_costProList[num].gameObject:SetActive(true)
local go = _costProList[num]
go.gameObject:SetActive(true)
local grid = Util.GetGameObject(go,"grid")
local numTxt=Util.GetGameObject(go,"grid/Text"):GetComponent("Text")
local btn=Util.GetGameObject(go,"grid/btn")
if not self.itemViewList[grid] then
self.itemViewList[grid] = SubUIManager.Open(SubUIConfig.ItemView,grid.transform)
end
local id=cost[i][1]
--金币不在这里显示
if id==14 then
go.gameObject:SetActive(false)
coinNum=cost[i][2]
else
go.gameObject:SetActive(true)
end
local list={}
local bagNum=0
if id == 0 then
id=self.equipData.staticId
list=FaLingManager.GetAllUpListNoBless(id)
if #selectMat==0 then
for j=1,#list do
if #selectMat < cost[i][2] and list[j].lv==0 then
table.insert(selectMat,list[j].did)
end
end
end
bagNum=#selectMat
else
bagNum=BagManager.GetItemCountById(cost[i][1])
end
if cost[i][2] > bagNum then
isEnough=false
numTxt.text=string.format("<color=#FF0000>%s</color>", cost[i][2] .."/"..bagNum)
else
2023-10-27 16:16:37 +08:00
numTxt.text=string.format("<color=#59320E>%s</color>", cost[i][2].."/"..bagNum)
2023-10-26 17:16:10 +08:00
end
2023-10-27 16:16:37 +08:00
self.itemViewList[grid]:OnOpen(false,{id,0}, 0.8, false, false, false, self.sortingOrder)
2023-10-26 17:16:10 +08:00
self.itemViewList[grid].gameObject.transform:SetAsFirstSibling()
Util.AddOnceClick(btn,function ()
LogError("id========================="..id)
if id == self.equipData.staticId then
UIManager.OpenPanel(UIName.FaLingUpStarListPanel,list,self,selectMat,self.curHeroData,cost[i][2])
else
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,id)
end
end)
end
if coinNum>0 then
self.coinImg.gameObject:SetActive(true)
self.coinTxt.gameObject:SetActive(true)
local haveNum=BagManager.GetItemCountById(14)
--self.coinTxt.text = coinNum
if coinNum>haveNum then
self.coinTxt.text=string.format("<color=#FF0000>%s</color>", coinNum .."/"..haveNum)
else
self.coinTxt.text=string.format("<color=#59320E>%s</color>", coinNum .."/"..haveNum)
end
self.coinImg.sprite=self.spLoader:LoadSprite(GetResourcePath(ConfigManager.GetConfigData(ConfigName.ItemConfig,14).ResourceID))
else
self.coinImg.gameObject:SetActive(false)
self.coinTxt.gameObject:SetActive(false)
end
else
self.costPro:SetActive(false)
end
end
--界面关闭时调用(用于子类重写)
function FaLingStrongPopup:OnClose()
2023-10-27 16:16:37 +08:00
if openPanel then
openPanel:OnShow()
end
2023-10-26 17:16:10 +08:00
end
--界面销毁时调用(用于子类重写)
function FaLingStrongPopup:OnDestroy()
self.spLoader:Destroy()
self.itemViewList={}
_BaseProList = {}
_superProList = {}
_costProList = {}
selectMat={}
end
return FaLingStrongPopup