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)
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.topBarBg = Util.GetGameObject(self.transform, "Content/topBar/bg2")
self.topBarBgColor = Util.GetGameObject(self.transform, "Content/topBar/bg1"):GetComponent("Image")
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")
self.superTitle = Util.GetGameObject(self.midBar, "superPro/Image/name"):GetComponent("Text")
self.superTitle.text = Language[12116]
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")
self.costTitle = Util.GetGameObject(self.transform, "costPro/Image/name"):GetComponent("Text")
self.costTitle.text = Language[12124]
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(Language[12125])
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
local openPanel = nil
--界面打开时调用(用于子类重写)
function FaLingStrongPopup:OnOpen(_equipData, _openPanel, _herodata)
if not _equipData then
return
end --父界面
openPanel = _openPanel
self.curHeroData = _herodata
self.equipData = _equipData --当前装备数据
--0不显示按钮、1背包、2已穿戴(显示卸下)、3未穿戴(显示穿戴)、4未穿戴(显示替换)、5自己或其他人穿戴(非装备界面但需要显示套装属性)
--self.func = _func
end
function FaLingStrongPopup:ChangeSelectMat(_list)
selectMat = _list
end
function FaLingStrongPopup:OnShow()
--上部装备基础信息
self.equipData = FaLingManager.GetEquipDataByDid(self.equipData.did)
lv = self.equipData.lv
if lv > 0 then
self.hLv.gameObject:SetActive(true)
else
self.hLv.gameObject:SetActive(false)
end
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.topBarBg:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_" .. aaa)
if aaa == 1 then
self.topBarBgColor.color = Color.New(0.81, 0.81, 0.81, 1)
elseif aaa == 2 then
self.topBarBgColor.color = Color.New(0.24, 0.34, 0.21, 1)
elseif aaa == 3 then
self.topBarBgColor.color = Color.New(0.22, 0.42, 0.63, 1)
elseif aaa == 4 then
self.topBarBgColor.color = Color.New(0.29, 0.14, 0.26, 1)
elseif aaa == 5 then
self.topBarBgColor.color = Color.New(0.26, 0.14, 0.06, 1)
elseif aaa == 6 then
self.topBarBgColor.color = Color.New(0.25, 0.02, 0.02, 1)
elseif aaa == 7 then
self.topBarBgColor.color = Color.New(0.32, 0.32, 0.32, 1)
elseif aaa == 8 then
self.topBarBgColor.color = Color.New(0.32, 0.32, 0.32, 1)
end
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 = GetLanguageStrById(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)
local star = talismana.Star
if star > 0 then
self.star:SetActive(true)
local starType = 1
local starSize = nil
starType = 3
star = star + 10
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
local nextLvData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId",
self.equipData.staticId, "Level", lv + 1)
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 = GetLanguageStrById(passiveSkillConfig[skillData.id].Desc)
skillData.openLv = lvList[i].Level
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
skillData.des = skillData.des .. "(" .. ProfessionType[lvList[i].ShowSkill[2]] .. Language[12121] .. ")"
elseif type == 2 then
--LogError("sssss:"..tostring(skillData.id).."/"..tostring(skillData.state).."/"..tostring(self.equipData.staticId).."/"..tostring(self.curHeroData.staticId))
--if lv >= lvList[i].Level and self.curHeroData and self.curHeroData.staticId == lvList[i].ShowSkill[2] then
if lv >= lvList[i].Level and self.curHeroData and self.curHeroData.heroConfig.Id == lvList[i].ShowSkill[2] then
skillData.state = 1
end
skillData.des = skillData.des ..
"(" .. GetLanguageStrById(heroConfig[lvList[i].ShowSkill[2]].ReadingName) .. Language[12122] .. ")"
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]
if skillData.state == 1 then
info.text = string.format("%s",
"[" .. skillData.openLv .. Language[12123] .. GetLanguageStrById(skillData.des))
else
info.text = string.format("%s",
"[" .. skillData.openLv .. Language[12123] .. GetLanguageStrById(skillData.des))
end
end
-- end
else
self.superPro:SetActive(false)
end
--消耗信息
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("%s", cost[i][2] .. "/" .. bagNum)
else
numTxt.text = string.format("%s", cost[i][2] .. "/" .. bagNum)
end
self.itemViewList[grid]:OnOpen(false, { id, 0 }, 0.8, false, false, false, self.sortingOrder)
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("%s", coinNum .. "/" .. haveNum)
else
self.coinTxt.text = string.format("%s", 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()
if openPanel then
openPanel:OnShow()
end
end
--界面销毁时调用(用于子类重写)
function FaLingStrongPopup:OnDestroy()
self.spLoader:Destroy()
self.itemViewList = {}
_BaseProList = {}
_superProList = {}
_costProList = {}
selectMat = {}
end
return FaLingStrongPopup