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

482 lines
21 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
local FaLingSingleShowPopup = 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 typeToUpdate = {
[2] = 2,--已穿戴->卸载单件
[3] = 1,--未穿戴->穿单件
[4] = 3,--未穿戴->替换单件
}
--初始化组件(用于子类重写)
function FaLingSingleShowPopup:InitComponent()
self.spLoader = SpriteLoader.New()
self.mask = Util.GetGameObject(self.transform, "mask")
self.content = Util.GetGameObject(self.transform, "Content")
--装备详情--topBar
self.topBar = Util.GetGameObject(self.transform, "Content/topBar")
self.eqiopName = Util.GetGameObject(self.topBar, "name"):GetComponent("Text")
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.equipType=Util.GetGameObject(self.topBar, "equipType"):GetComponent("Text")
self.equipQuaText=Util.GetGameObject(self.topBar, "equipQuaText"):GetComponent("Text")
self.equipInfoText=Util.GetGameObject(self.topBar, "equipInfoText"):GetComponent("Text")
self.powerNum=Util.GetGameObject(self.topBar, "powerNum"):GetComponent("Text")
self.star=Util.GetGameObject(self.topBar, "star")
self.powerNumUpDown = Util.GetGameObject(self.topBar, "powerUPorDown"):GetComponent("Image")
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.basePro = Util.GetGameObject(self.midBar, "basePro")
self.baseProName = Util.GetGameObject(self.basePro, "PropertyName"):GetComponent("Text")
self.baseProGrid = Util.GetGameObject(self.basePro, "grid")
self.baseProPre = Util.GetGameObject(self.basePro, "grid/curProName")
self.baseProPre:SetActive(false)
--superPro
self.superPro = Util.GetGameObject(self.midBar, "superPro")
self.superTitle = Util.GetGameObject(self.midBar, "superPro/Image/PropertyName"):GetComponent("Text")
self.superTitle.text="法宝天赋"
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.midBar, "costPro")
self.costTitle = Util.GetGameObject(self.midBar, "costPro/Image/PropertyName"):GetComponent("Text")
self.costTitle.text="护佑"
self.addTxt = Util.GetGameObject(self.costPro, "addTxt"):GetComponent("Text")
self.costProGrid = Util.GetGameObject(self.costPro, "proGrid")
self.costProPre = Util.GetGameObject(self.costPro, "proGrid/item")
self.costProPre:SetActive(false)
--分解按钮--btmBar
self.btmBar = Util.GetGameObject(self.transform, "Content/btmBar")
self.howGet = Util.GetGameObject(self.btmBar, "howGet")
self.btnGrid = Util.GetGameObject(self.btmBar, "btnGrid")
self.btnStrong=Util.GetGameObject(self.btnGrid, "btnStrong")
self.btnDown = Util.GetGameObject(self.btnGrid, "btnDown")
self.btnAdd = Util.GetGameObject(self.btnGrid, "btnAdd")
self.btnStrongRed=Util.GetGameObject(self.btnGrid, "btnStrong/redPoint")
--装备获取途径--btmBar
self.canGetPre = Util.GetGameObject(self.btmBar, "scroll/canGetPre")
self.canGetGrid = Util.GetGameObject(self.btmBar, "scroll")
self.canGetScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.canGetGrid.transform,self.canGetPre, nil,
Vector2.New(self.canGetGrid.transform.rect.width, self.canGetGrid.transform.rect.height), 1, 1, Vector2.New(0, 0))
self.canGetScrollView.moveTween.MomentumAmount = 1
self.canGetScrollView.moveTween.Strength = 2
self.canGetScrollView.elastic = false
self.jumpViewList = {}
end
--绑定事件(用于子类重写)
function FaLingSingleShowPopup:BindEvent()
Util.AddClick(self.mask, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(self.btnStrong, function()
UIManager.OpenPanel(UIName.FaLingStrongPopup,self.equipData,self)
end)
Util.AddClick(self.btnAdd, function()
NetManager.BaublesWearRequest(self.curHeroData.dynamicId,self.equipData.did,nil,function()
self:ClosePanel()
self.parent:ClosePanel()
end)
end)
--卸下
Util.AddClick(self.btnDown, function()
NetManager.BaublesWearRequest(self.curHeroData.dynamicId,"",self.curHeroData.baublesId, function()
HeroManager.SetHeroBaublesId(self.curHeroData.dynamicId,nil)
self:ClosePanel()
end)
end)
--替换
Util.AddClick(self.btnSwitch, function()
local equipIdList={}
local equipDataList={}
table.insert(equipIdList,tostring(self.equipData.id))
table.insert(equipDataList,self.equipData)
NetManager.EquipWearRequest(self.curHeroData.dynamicId,equipIdList ,1, function ()
self:ClosePanel()
self.parent.UpdateEquipPosHeroData(1,typeToUpdate[self.openType],equipDataList,self.nextEquip,self.position)
end)
end)
end
--道具 和 装备分解 发送请求后 回调
function FaLingSingleShowPopup:SendBackResolveReCallBack(drop)
local isShowReward=false
if drop.itemlist~=nil and #drop.itemlist>0 then
for i = 1, #drop.itemlist do
if drop.itemlist[i].itemNum>0 then
isShowReward=true
break
end
end
end
if isShowReward then
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function ()
BagManager.OnShowTipDropNumZero(drop)
end)
else
BagManager.OnShowTipDropNumZero(drop)
end
if self.func then
self.func()
end
self:ClosePanel()
end
--添加事件监听(用于子类重写)
function FaLingSingleShowPopup:AddListener()
end
--移除事件监听(用于子类重写)
function FaLingSingleShowPopup:RemoveListener()
end
function FaLingSingleShowPopup: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
--界面打开时调用(用于子类重写)
function FaLingSingleShowPopup:OnOpen(_parent,_equipData,_openType,_isShowGet,_isShowGo,_curHeroData,_position,_targetEquipData,_func)
if not _equipData then
return
end
self.parent = _parent --父界面
self.equipData = _equipData --当前装备数据
self.openType = _openType --0不显示按钮、1背包、2已穿戴显示卸下、3未穿戴显示穿戴、4未穿戴显示替换、5自己或其他人穿戴非装备界面但需要显示套装属性
self.howGet:SetActive(_isShowGet and true or false)--是否显示获取途径
self.btnGrid:SetActive(self.openType ~= 0)
self.curHeroData = _curHeroData --装备了该装备的英雄数据
self.position = _position --装备的位置
self.nextEquip = _targetEquipData--要替换的目标装备
if _targetEquipData then
LogGreen("Id:"..tostring(_equipData.id).." Id2:"..tostring(_targetEquipData.id))
end
self.isShowGo = _isShowGo and _isShowGo or false--是否显示跳转按钮
self.func = _func
end
function FaLingSingleShowPopup:SetBtns()
self.btnDown:SetActive(self.openType == 2)
self.btnStrong:SetActive(self.openType==2)
self.btnAdd:SetActive(self.openType ==3)
end
function FaLingSingleShowPopup:OnShow()
--上部装备基础信息
Log("装备id:"..tostring(self.equipData.staticId).." openType:"..tostring(self.openType))
self:SetBtns()
lv=self.equipData.lv
self.hLv.text=lv
self.hLv.gameObject:SetActive(lv>0)
self.btnStrongRed:SetActive(FaLingManager.CheckEquipStrongRedPoint(self.equipData.did))
equipConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig, self.equipData.staticId)
local itemConfigData=ConfigManager.GetConfigData(ConfigName.ItemConfig,self.equipData.staticId)
local aaa=equipConfigData.Quantity
self.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("Bg_hz_beibao_pinjise_00"..aaa)
self.equipQuaText.text= GetQuaStringByEquipQua(equipConfigData.Quantity) --GetStringByEquipQua(equipConfigData.Quantity,GetQuaStringByEquipQua(equipConfigData.Quantity))
self.eqiopName.text= equipConfigData.Name --GetStringByEquipQua(equipConfigData.Quantity,GetLanguageStrById(equipConfigData.Name))
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.equipInfoText.text=GetLanguageStrById(itemConfigData.ItemDescribe)
if equipConfigData.ExhibitionScore and equipConfigData.ExhibitionScore>0 then
self.powerNum.text=equipConfigData.ExhibitionScore
else
self.powerNum.text=EquipManager.CalculateWarForce(self.equipData.staticId)
end
self.equipType.text="法宝"
--下部按钮信息
self.effectbaijin:SetActive(equipConfigData.Quantity==7)
Util.SetParticleSortLayer(self.effectbaijin,self.sortingOrder + 1)
if self.openType == 4 then
self.powerNumUpDown.gameObject:SetActive(true)
local Power = EquipManager.CalculateWarForce(self.equipData.id)
local Power2 = EquipManager.CalculateWarForce(self.nextEquip.id)
-- LogGreen("Id:"..tostring(self.equipData.id).." Power:"..tostring(Power).." Id2:"..tostring(self.equipData.id).." Power2:"..tostring(Power2))
if(Power > Power2) then
self.powerNumUpDown.sprite = self.spLoader:LoadSprite(PowerChangeIconDef[1])
elseif(Power < Power2)then
self.powerNumUpDown.sprite = self.spLoader:LoadSprite(PowerChangeIconDef[2])
else
self.powerNumUpDown.gameObject:SetActive(false)
end
else
self.powerNumUpDown.gameObject:SetActive(false)
end
--护佑信息
local addPro=nil
if lv>= FaLingManager.GetBlessOpenLv() then
addPro=FaLingManager.GetBlessEquipAddPro()*#self.equipData.bless/100 .. "%"
self.addTxt.text="+"..addPro
self.costPro:SetActive(true)
local num=0
for i = 1, FaLingManager.GetBlessEquipNum() 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 add = Util.GetGameObject(go,"add")
local itemObj=Util.GetGameObject(go,"grid")
local red=Util.GetGameObject(go,"redPoint")
local farme=Util.GetGameObject(go,"grid"):GetComponent("Image")
local icon=Util.GetGameObject(go,"grid/icon"):GetComponent("Image")
local name=Util.GetGameObject(go,"grid/Text"):GetComponent("Text")
local lv=Util.GetGameObject(go,"grid/lv"):GetComponent("Text")
LogError("self.equipData.bless len==="..#self.equipData.bless)
if self.equipData.bless and self.equipData.bless[i] then
itemObj:SetActive(true)
local data=self.equipData.bless[i]
if data then
farme.sprite = self.spLoader:LoadSprite(data.frame)
icon.sprite = self.spLoader:LoadSprite(data.icon)
lv.text=data.lv
add:SetActive(false)
name.text=data.itemConfig.Name
Util.AddClick(icon.gameObject,function()
if self.openType~=2 then
return
end
--UIManager.OpenPanel(UIName.FaLingSingleShowPopup,self,data,2,false,false)
local sureFunc=function()
NetManager.BaublesDownBlessRequest(self.equipData.did,{self.equipData.bless[i].did},function()
LogError("刷新界面显示")
self:OnShow()
end)
end
local args={}
args[1]="是否卸下当前护佑法宝?"
args[2]="卸下"
args[3]="取消"
args[4]=sureFunc
UIManager.OpenPanel(UIName.GMCommonConfirmPanel,args)
end)
end
red:SetActive(false)
else
itemObj:SetActive(false)
add:SetActive(true)
red:SetActive(FaLingManager.CheckEquipBlessRedPoint(self.equipData.did))
end
Util.AddClick(add,function()
if self.openType~=2 then
return
end
local list=FaLingManager.GetCanBlessEquipList()
local curSelectList={}
UIManager.OpenPanel(UIName.FaLingListPanel,list,self,curSelectList,self.curHeroData,2)
end)
end
else
self.costPro:SetActive(false)
end
--basePro基础属性
local talismana=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",self.equipData.staticId,"Level",lv)
if talismana and talismana.Property then
self.basePro:SetActive(true)
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)
_BaseProList[num]:GetComponent("Text").text = GetLanguageStrById(proConfigData.Info)
local vText = Util.GetGameObject(_BaseProList[num], "curProVale"):GetComponent("Text")
local addTxt=Util.GetGameObject(_BaseProList[num], "addVale"):GetComponent("Text")
-- Util.GetGameObject(vText.gameObject, "homeValue"):GetComponent("Text").text = ""--摘星阁加持文字显示位置
if prop[2] > 0 then
vText.text = "+"..GetPropertyFormatStr(proConfigData.Style, prop[2])
else
vText.text = GetPropertyFormatStr(proConfigData.Style, prop[2])
end
if #self.equipData.bless>0 then
addTxt.gameObject:SetActive(true)
addTxt.text="("..addPro..")"
else
addTxt.gameObject:SetActive(false)
end
end
end
end
else
self.basePro:SetActive(false)
end
local star=talismana.Star
if star>0 then
self.star:SetActive(true)
local starType=1
local starSize=nil
starType=3
star=star+11
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 lvList=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.EquipTalismana,"TalismanaId",self.equipData.staticId)
local skillList={}
local curStar=0
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
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]].."职业专属".. ")"
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
skillData.des=skillData.des.."(".. heroConfig[lvList[i].ShowSkill[2]].ReadingName .."专属".. ")"
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("<color=#00ff66>%s</color>","["..skillData.openLv.."级开启]"..GetLanguageStrById(skillData.des))
else
info.text = string.format("<color=#574141>%s</color>","["..skillData.openLv.."级开启]"..GetLanguageStrById(skillData.des))
end
end
-- end
else
self.superPro:SetActive(false)
end
--获取途径
if self.jumpViewList and #self.jumpViewList > 0 then
for i = 1,#self.jumpViewList do
SubUIManager.Close(self.jumpViewList[i])
end
end
local curitemData = itemConfig[tonumber(self.equipData.id)]
if curitemData and curitemData.Jump then
if curitemData.Jump and #curitemData.Jump>0 then
self.canGetScrollView:SetData(curitemData.Jump,function (index, item)
local tempView = nil
if self.isShowGo then
tempView = SubUIManager.Open(SubUIConfig.JumpView, item.transform, curitemData.Jump[index],true)
else
tempView = SubUIManager.Open(SubUIConfig.JumpView, item.transform, curitemData.Jump[index],false)
end
table.insert(self.jumpViewList,tempView)
end,true,true)
end
end
--(此处需要三遍才能完全打开)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
if self.func then
self.func()
end
end
--界面关闭时调用(用于子类重写)
function FaLingSingleShowPopup:OnClose()
for i = 1, #self.jumpViewList do
destroy(self.jumpViewList[i].gameObject)
end
end
--界面销毁时调用(用于子类重写)
function FaLingSingleShowPopup:OnDestroy()
self.spLoader:Destroy()
_BaseProList = {}
_superProList = {}
_costProList = {}
self.jumpViewList = {}
end
return FaLingSingleShowPopup