miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/RoleEquipPanel.lua

929 lines
38 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
local spcialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
RoleEquipPanel = Inherit(BasePanel)
--local SortTypeConst = {
-- Natural = 1,--品阶 ur+ --> r 6 --> 1
-- Lv = 2
--}
local PosIdConst = {
All = 0,--全部
WuQi = 1,--武器
ZhanFu = 2,--战服
TouShi = 3,--头饰
ZhanXue = 4,--战靴
Hun = 5,--魂宝
Ling = 6,--灵宝
}
local this=RoleEquipPanel
local curHeroEquipDatas={}
local curHeroData
local heroListData
local curSelectEquipData
local index
local indexBtnNum=0
2020-06-23 18:36:24 +08:00
local typeTab = { Language[10427], Language[10428], Language[10429], Language[10430], Language[10505],Language[10506] }
2020-05-09 13:31:21 +08:00
local tabs = {}
local openThisPanel
local effectList={}
local orginLayer1
local orginLayer
local isUpZhen = false
local teamHero = {}
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local jewerConfigs = ConfigManager.GetConfig(ConfigName.JewelConfig)
local currPageIndex=0
local curEquipTreasureDatas = {}
2020-06-13 11:47:13 +08:00
local isCanUpEquipTreasure = false
2020-05-09 13:31:21 +08:00
--初始化组件用于子类重写RoleEquipChangePopup
function RoleEquipPanel:InitComponent()
orginLayer = 10
orginLayer1={0,0,0,0,0,0}
this.bg2 = Util.GetGameObject(self.transform,"bg2")
screenAdapte(this.bg2)
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft})
this.btnBack= Util.GetGameObject(self.transform, "btnBack/btnBack")
--英雄
this.heroBg = Util.GetGameObject(self.transform, "bg/heroInfo/bg"):GetComponent("Image")
this.heroLv = Util.GetGameObject(self.transform, "bg/heroInfo/lv/Text"):GetComponent("Text")
this.heroIcon = Util.GetGameObject(self.transform, "bg/heroInfo/icon"):GetComponent("Image")
this.heroPosIcon = Util.GetGameObject(self.transform, "bg/heroInfo/pos/icon"):GetComponent("Image")
this.heroProIcon = Util.GetGameObject(self.transform, "bg/heroInfo/pro/Image"):GetComponent("Image")
--this.heroStage = Util.GetGameObject(self.transform, "bg/heroInfo/heroStage"):GetComponent("Image")
Util.GetGameObject(self.transform, "bg/heroInfo/heroStage"):SetActive(false)
this.heroStarGrid = Util.GetGameObject(self.transform, "bg/heroInfo/star")
this.heroStarPre = Util.GetGameObject(self.transform, "bg/heroInfo/starPre")
--英雄身上的装备
this.equipGrid=Util.GetGameObject(self.transform,"bg/equipInfo")
local scale = (Screen.width / Screen.height / 1080 * 1920 + 1) / 2
if scale < 1 then
for i = 1, this.equipGrid.transform.childCount do
Util.SetParticleScale(Util.GetGameObject(this.equipGrid.transform:GetChild(i-1),"effect"), scale)
end
end
--装备list
this.effect=Util.GetGameObject(self.transform,"bg/effect")
for i = 0, 6 do
tabs[i] = Util.GetGameObject(self.transform, "Tabs/Btn" .. i)
effectList[i] = Util.GetGameObject(self.transform, "bg/equipInfo/equip".. i.."/effect")
end
this.selectBtn = Util.GetGameObject(self.gameObject, "selectBtn")
this.btnPrant = Util.GetGameObject(self.gameObject, "Tabs")
this.equipPre = Util.GetGameObject(self.gameObject, "equipPre")
this.grid = Util.GetGameObject(self.gameObject, "scroll/grid")
this.selsectSkillImage=Util.GetGameObject(self.gameObject, "selsectSkillImage")
this.ShaiXuanBtn = Util.GetGameObject(self.gameObject, "ShaiXuanBtn")
this.ShaiXuanBtn:SetActive(false)
this.ShaiXuanBtnLv = Util.GetGameObject(self.gameObject, "ShaiXuanBtn/Lv")
this.ShaiXuanBtnQu = Util.GetGameObject(self.gameObject, "ShaiXuanBtn/Qu")
this.leftBtn = Util.GetGameObject(self.transform, "leftBtn/GameObject")
this.rightBtn = Util.GetGameObject(self.transform, "rightBtn/GameObject")
this.allEquipUp = Util.GetGameObject(self.transform, "allEquipUp")
this.allEquipDown = Util.GetGameObject(self.transform, "allEquipDown")
this.allEquipUpRedPoint=Util.GetGameObject(self.transform,"allEquipUp/redPoint")
this.ScrollBar=Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
local v2 = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.transform, "scroll").transform,
this.equipPre, this.ScrollBar, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(50,15))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
this.force = Util.GetGameObject(self.transform, "powerBtn/value"):GetComponent("Text")
this.itemNumText = Util.GetGameObject(self.transform, "itemNumText"):GetComponent("Text")
this.upLvEffect = Util.GetGameObject(self.transform,"powerBtn/effect")
this.equipTreasureBtn = Util.GetGameObject(self.transform,"equipTreasureBtn")
this.treasure1=Util.GetGameObject(self.transform,"bg/equipInfo/equip5")
this.treasure2=Util.GetGameObject(self.transform,"bg/equipInfo/equip6")
this.treasurePage1=Util.GetGameObject(self.transform,"Tabs/Btn5")
this.treasurePage2=Util.GetGameObject(self.transform,"Tabs/Btn6")
this.emptyObj=Util.GetGameObject(self.transform,"emptyObj")
this.emptyObj.gameObject:SetActive(false)
end
--绑定事件(用于子类重写)
function RoleEquipPanel:BindEvent()
Util.AddClick(this.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
if openThisPanel.RefreshHeroDatas then
openThisPanel:RefreshHeroDatas(curHeroData,HeroManager.GetAllHeroDatas())
end
self:ClosePanel()
end)
Util.AddClick(this.leftBtn, function()
this:LeftBtnOnClick()
end)
Util.AddClick(this.rightBtn, function()
this:RightBtnOnClick()
end)
Util.AddClick(this.allEquipUp, function()
this:AllEquipUpBtnOnClick()
end)
Util.AddClick(this.allEquipDown, function()
this:AllEquipDownBtnOnClick()
end)
for i = 0, 6 do
Util.AddClick(tabs[i], function()
if i == indexBtnNum then
indexBtnNum=PosIdConst.All
this:OnClickAllBtn()
else
indexBtnNum=i
this:OnClickTabBtn(indexBtnNum)
end
end)
end
Util.AddClick(this.equipTreasureBtn, function()
if LengthOfTable(curEquipTreasureDatas)<2 then
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11825])
2020-05-09 13:31:21 +08:00
return
end
UIManager.OpenPanel(UIName.EquipTreasureResonancePanel,curHeroData)
end)
end
--添加事件监听(用于子类重写)
function RoleEquipPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Treasure.TreasureLvUp, this.CurrEquipDataChange)
end
--移除事件监听(用于子类重写)
function RoleEquipPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Treasure.TreasureLvUp, this.CurrEquipDataChange)
end
function this.CurrEquipDataChange()
this.ShowHeroEquip()
2020-05-15 16:52:35 +08:00
if indexBtnNum == PosIdConst.All then
this:OnClickAllBtn()
else
this:OnClickTabBtn(indexBtnNum)
end
2020-05-09 13:31:21 +08:00
end
--界面打开时调用(用于子类重写)
function RoleEquipPanel:OnOpen(...)
local data={...}
if data[1] then
curHeroData=data[1]
HeroManager.roleEquipPanelCurHeroData=data[1]
else
curHeroData=HeroManager.roleEquipPanelCurHeroData
end
if data[2] then
heroListData=data[2]
HeroManager.roleEquipPanelHeroListData=data[2]
else
heroListData=HeroManager.GetAllHeroDatas()
end
openThisPanel=data[3]
isUpZhen = data[4]
end
function RoleEquipPanel:OnShow()
for i = 1, #heroListData do
if curHeroData == heroListData[i] then
index = i
end
end
for i = 1, 6 do
if(effectList[i]~=nil) then
effectList[i]:SetActive(false)
end
end
indexBtnNum=PosIdConst.All
teamHero=FormationManager.GetAllFormationHeroId()
this.ShowHeroEquip(true)
this:OnClickAllBtn()
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
end
function this:OnSortingOrderChange()
Util.AddParticleSortLayer(this.effect, this.sortingOrder - orginLayer)
orginLayer = this.sortingOrder
end
--右切换按钮点击
function this:RightBtnOnClick()
index = (index + 1 <= #heroListData and index + 1 or 1)
curHeroData = heroListData[index]
this.ShowHeroEquip()
if indexBtnNum == PosIdConst.All then
this:OnClickAllBtn()
else
this:OnClickTabBtn(indexBtnNum)
end
end
--左切换按钮点击
function this:LeftBtnOnClick()
index = (index - 1 > 0 and index - 1 or #heroListData)
curHeroData = heroListData[index]
this.ShowHeroEquip()
if indexBtnNum == PosIdConst.All then
this:OnClickAllBtn()
else
this:OnClickTabBtn(indexBtnNum)
end
end
--一键装备
function this:AllEquipUpBtnOnClick()
local allEquipIds={}
local allTreasureIds={}
--计算英雄身上的所有装备位的装备
local curHeroEquipDatas={}
for k,v in ipairs(curHeroData.equipIdList) do
local equipData=EquipManager.GetSingleEquipData(v)
if equipData~=nil then
curHeroEquipDatas[equipData.equipConfig.Position]=equipData
end
end
--宝物数据
for k,v in ipairs(curHeroData.jewels) do
local equipData=EquipTreasureManager.GetSingleTreasureByIdDyn(v)
if equipData~=nil then
curHeroEquipDatas[equipData.equipType+4]=equipData
end
end
local equipEffectPos={}
local treasureEffectPos={}
--如果身上的装备 带锁 则不替换
for i = 1, 6 do
local curPosEquip = {}
local index=i
if curHeroEquipDatas[i] then
if curHeroEquipDatas[i].isLocked == 0 then
curPosEquip = EquipManager.GetEquipDataByEquipJobAndPos(i,curHeroData.heroConfig.Profession,curHeroData.dynamicId)
else
curPosEquip = {curHeroEquipDatas[i]}
end
else
2020-06-13 11:47:13 +08:00
if index==5 or index==6 and isCanUpEquipTreasure then
curPosEquip=EquipTreasureManager.GetTreasureDataByPos(index,curHeroData.dynamicId,curHeroData.heroConfig.PropertyName)
2020-05-09 13:31:21 +08:00
else
curPosEquip = EquipManager.GetEquipDataByEquipJobAndPos(i,curHeroData.heroConfig.Profession,curHeroData.dynamicId)
end
end
--计算每个位置可装备的装备战力 取战力最大的装备
if curPosEquip and #curPosEquip>0 then
local equiData={}
local indexMaxPower=0
for i = 1, #curPosEquip do
local addPower=0
local curEquip = curPosEquip[i]
if curEquip then
if curEquip.idDyn then
addPower=EquipTreasureManager.CalculateWarForce(curEquip.idDyn)
else
addPower = EquipManager.CalculateWarForce(curEquip.did)
end
end
if addPower>=indexMaxPower then
indexMaxPower=addPower
equiData=curEquip
end
end
2020-06-13 11:47:13 +08:00
if equiData.idDyn and isCanUpEquipTreasure then
2020-05-09 13:31:21 +08:00
table.insert(allTreasureIds,equiData.idDyn)
else
table.insert(allEquipIds,equiData.did)
end
--特效
if curHeroEquipDatas[equiData.position] then
if equiData.idDyn then
if equiData.idDyn ~= curHeroEquipDatas[equiData.position].idDyn then
table.insert(treasureEffectPos,i)
end
else
if equiData.did ~= curHeroEquipDatas[equiData.position].did then
table.insert(equipEffectPos,i)
end
end
else
--table.insert(showEffectPos,i)
end
end
end
2020-06-13 11:47:13 +08:00
--isCanUpEquipTreasure
2020-05-09 13:31:21 +08:00
if allEquipIds and #allEquipIds>0 then
2020-06-13 11:47:13 +08:00
--for i = 1, #allEquipIds do
-- LogGreen(curHeroData.dynamicId.. " "..curHeroData.id .." "..curHeroData.lv.." 一键穿装备 "..i.." "..allEquipIds[i])
--end
2020-05-09 13:31:21 +08:00
--穿装备协议
NetManager.EquipWearRequest(curHeroData.dynamicId,allEquipIds ,1,function ()
this.UpdateEquipPosHeroData(1,4,allEquipIds)
--特效播放
if equipEffectPos then
for i = 1, #equipEffectPos do
effectList[equipEffectPos[i]]:SetActive(false)
effectList[equipEffectPos[i]]:SetActive(true)
end
end
end)
else
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11826])
2020-05-09 13:31:21 +08:00
end
2020-05-15 16:52:35 +08:00
--6星英雄才能穿宝物
2020-06-13 11:47:13 +08:00
if isCanUpEquipTreasure then
if curHeroData.star >=6 then
--穿戴宝物
if allTreasureIds and #allTreasureIds>0 then
--for i = 1, #allEquipIds do
-- Log(curHeroData.dynamicId.. " "..curHeroData.id .." "..curHeroData.lv.." 一键宝物 "..i.." "..allEquipIds[i])
--end
--穿装备协议
NetManager.EquipWearRequest(curHeroData.dynamicId,allTreasureIds ,2,function ()
this.UpdateEquipPosHeroData(2,4,allTreasureIds)
--特效播放
for i, v in pairs(treasureEffectPos) do
effectList[v]:SetActive(false)
effectList[v]:SetActive(true)
end
end)
else
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11827])
2020-05-09 13:31:21 +08:00
end
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
end
2020-05-15 16:52:35 +08:00
2020-05-09 13:31:21 +08:00
PlaySoundWithoutClick(SoundConfig.Sound_Wear)
this.ShowHeroEquip()
end
--一键卸下
function this:AllEquipDownBtnOnClick()
if curHeroData.equipIdList and #curHeroData.equipIdList>0 then
NetManager.EquipUnLoadOptRequest(curHeroData.dynamicId,curHeroData.equipIdList,1 ,function ()
this.UpdateEquipPosHeroData(1,5,curHeroData.equipIdList)
end)
else
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11828])
2020-05-09 13:31:21 +08:00
end
--寶物
if curHeroData.jewels and #curHeroData.jewels>0 then
NetManager.EquipUnLoadOptRequest(curHeroData.dynamicId,curHeroData.jewels,2 ,function ()
this.UpdateEquipPosHeroData(2,5,curHeroData.jewels)
end)
-- 一键卸下音效
else
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11828])
2020-05-09 13:31:21 +08:00
end
PlaySoundWithoutClick(SoundConfig.Sound_TakeOff)
this.ShowHeroEquip()
-- this:OnClickTabBtn(indexBtnNum)
end
function this.ShowHeroEquip()
--装备
if curHeroData and spcialConfig then
local config=spcialConfig[40]
if config then
local limits = string.split(config.Value, "|")
if limits then
local heroConfig=ConfigManager.GetConfigData(ConfigName.HeroConfig,curHeroData.id)
local lvs=string.split(limits[1],"#")
local stars=string.split(limits[2],"#")
if PlayerManager.level>=tonumber(lvs[2]) and heroConfig~=nil and heroConfig.MaxRank>=tonumber(stars[2]) then
2020-06-13 11:47:13 +08:00
isCanUpEquipTreasure = true
2020-05-09 13:31:21 +08:00
this.equipTreasureBtn.gameObject:SetActive(true)
this.treasure1.gameObject:SetActive(true)
this.treasure2.gameObject:SetActive(true)
this.treasurePage1.gameObject:SetActive(true)
this.treasurePage2.gameObject:SetActive(true)
else
2020-06-13 11:47:13 +08:00
isCanUpEquipTreasure = false
2020-05-09 13:31:21 +08:00
this.equipTreasureBtn.gameObject:SetActive(false)
this.treasure1.gameObject:SetActive(false)
this.treasure2.gameObject:SetActive(false)
this.treasurePage1.gameObject:SetActive(false)
this.treasurePage2.gameObject:SetActive(false)
end
end
end
end
this.heroBg.sprite = Util.LoadSprite(GetHeroCardQuantityImage[curHeroData.heroConfig.Quality])
this.heroLv.text = curHeroData.lv
this.heroIcon.sprite = Util.LoadSprite(curHeroData.painting)
this.heroPosIcon.sprite = Util.LoadSprite(curHeroData.professionIcon)
this.heroProIcon.sprite = Util.LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
--this.heroStage.sprite = Util.LoadSprite(HeroStageSprite[curHeroData.heroConfig.HeroStage])
SetHeroStars(this.heroStarGrid, curHeroData.star)
--装备的数据
curHeroEquipDatas={}
for i = 1, #curHeroData.equipIdList do
local equipData=EquipManager.GetSingleEquipData(curHeroData.equipIdList[i])
if equipData~=nil then
curHeroEquipDatas[equipData.equipConfig.Position]=equipData
end
end
--宝器的数据
curEquipTreasureDatas={}
--LogError("#curHeroData.jewels "..#curHeroData.jewels)
for i = 1, #curHeroData.jewels do
local treasureData=EquipTreasureManager.GetSingleEquipTreasreData(curHeroData.jewels[i])
if treasureData~=nil then
local id=treasureData.id
local pos=jewerConfigs[id].Location+4
curEquipTreasureDatas[pos]=treasureData
end
end
--this.equipTreasureBtn:SetActive(LengthOfTable(curEquipTreasureDatas) >= 2)
for i = 1, this.equipGrid.transform.childCount do
local go= this.equipGrid.transform:GetChild(i-1).gameObject
local effect= Util.GetGameObject(go.transform,"effect")
screenAdapte(effect)
Util.AddParticleSortLayer(effect, this.sortingOrder - orginLayer1[i])
orginLayer1[i]=this.sortingOrder
effectList[i]=effect
local lvObj=Util.GetGameObject(go.transform,"lv")
local refineObj=Util.GetGameObject(go.transform,"refine")
if curHeroEquipDatas[i] then
Util.GetGameObject(go.transform,"frame"):SetActive(true)
Util.GetGameObject(go.transform,"mask"):SetActive(false)
2020-06-13 11:47:13 +08:00
--Util.GetGameObject(go.transform,"proIcon"):SetActive(false)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go.transform,"frame/icon"):GetComponent("Image").sprite=Util.LoadSprite(curHeroEquipDatas[i].icon)
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(curHeroEquipDatas[i].frame)
2020-06-13 11:47:13 +08:00
--Util.GetGameObject(go.transform,"proIcon"):GetComponent("Image").sprite=Util.LoadSprite(curHeroEquipDatas[i].frame)
2020-05-09 13:31:21 +08:00
if lvObj then
lvObj:SetActive(false)
end
if refineObj then
refineObj:SetActive(false)
end
EquipManager.SetEquipStarShow(Util.GetGameObject(go.transform,"frame/star"),curHeroEquipDatas[i].itemConfig.Id)
elseif curEquipTreasureDatas[i] then
Util.GetGameObject(go.transform,"frame"):SetActive(true)
Util.GetGameObject(go.transform,"mask"):SetActive(false)
2020-06-13 11:47:13 +08:00
--Util.GetGameObject(go.transform,"proIcon"):SetActive(true)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go.transform,"frame/icon"):GetComponent("Image").sprite=Util.LoadSprite(curEquipTreasureDatas[i].icon)
Util.GetGameObject(go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(curEquipTreasureDatas[i].frame)
2020-06-13 11:47:13 +08:00
--Util.GetGameObject(go.transform,"proIcon"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(curEquipTreasureDatas[i].itemConfig.PropertyName))
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go.transform,"frame/star"):SetActive(false)
Util.GetGameObject(go.transform,"num").gameObject:SetActive(false)
if curEquipTreasureDatas[i].lv>0 and lvObj then
lvObj:GetComponent("Text").text=curEquipTreasureDatas[i].lv
lvObj:SetActive(true)
else
lvObj:SetActive(false)
end
if curEquipTreasureDatas[i].refineLv>0 then
refineObj:GetComponent("Text").text="+" ..curEquipTreasureDatas[i].refineLv
refineObj:SetActive(true)
else
refineObj:SetActive(false)
end
else
Util.GetGameObject(go.transform,"frame"):SetActive(false)
Util.GetGameObject(go.transform,"mask"):SetActive(true)
if Util.GetGameObject(go.transform,"num") then
Util.GetGameObject(go.transform,"num").gameObject:SetActive(false)
end
if lvObj then
lvObj:SetActive(false)
end
if refineObj then
refineObj:SetActive(false)
end
end
local iconBtn=Util.GetGameObject(go.transform,"icon")
Util.AddOnceClick(iconBtn, function()
if curHeroEquipDatas[i] then
curSelectEquipData=curHeroEquipDatas[i]
UIManager.OpenPanel(UIName.RoleEquipChangePopup,this,2,curHeroData,curHeroEquipDatas[i])
elseif curEquipTreasureDatas[i] then
if itemConfig[curEquipTreasureDatas[i].id].ItemType == ItemType.EquipTreasure then
local pos=0;
local jewerConfig=ConfigManager.TryGetConfigData(ConfigName.JewelConfig,curEquipTreasureDatas[i].id)
if jewerConfig then
if jewerConfig.Location==1 then
pos=5
elseif jewerConfig.Location==2 then
pos=6
end
UIManager.OpenPanel(UIName.RoleEquipTreasureChangePopup,this,2,curHeroData,curEquipTreasureDatas[i],nil,pos)
end
end
end
end)
end
local allAddProVal=HeroManager.CalculateHeroAllProValList(1,curHeroData.dynamicId,false)
this.force.text =allAddProVal[HeroProType.WarPower]
end
function this:SetSelectBtn()
this.selectBtn:SetActive(indexBtnNum ~= PosIdConst.All)
if indexBtnNum ~= PosIdConst.All then
this.selectBtn.transform:SetParent(tabs[indexBtnNum].transform)
this.selectBtn.transform.localPosition =Vector3(0,-8,0)
--this.selectBtn.transform.localScale = Vector3.one
--this.selectBtn:GetComponent("Image"):SetNativeSize()
Util.GetGameObject(this.selectBtn.transform, "Text"):GetComponent("Text").text = typeTab[indexBtnNum]
end
end
--点击全部按钮
function this:OnClickAllBtn()
this:SetSelectBtn()
local itemData = EquipManager.GetAllEquipData()
itemData=this:EquipListFilter(itemData)
itemData = this:EquipDJDatas(itemData)
this:SortEquipDatas(itemData)
--加上宝器数据
2020-06-13 11:47:13 +08:00
local curAllEquipTreasure = EquipTreasureManager.GetAllTreasures(curHeroData.heroConfig.PropertyName)
2020-05-09 13:31:21 +08:00
--宝器排序
for i=1,#curAllEquipTreasure do
table.insert( itemData, curAllEquipTreasure[i] )
end
this:SetItemData(itemData)
end
--点击装备按钮
function this:OnClickTabBtn(_index)
this:SetSelectBtn()
if _index < 5 then
local allEquip
allEquip = EquipManager.GetEquipDataByEquipPosition(_index)
allEquip=this:EquipListFilter(allEquip)
allEquip = this:EquipDJDatas(allEquip)
this:SortEquipDatas(allEquip)
this:SetItemData(allEquip)
else
local allEquipTreasure
2020-06-13 11:47:13 +08:00
allEquipTreasure = EquipTreasureManager.GetAllTreasuresByLocation(_index - 4,curHeroData.heroConfig.PropertyName)
2020-05-09 13:31:21 +08:00
table.sort(allEquipTreasure, function(a, b)
if a.refineLv == b.refineLv then
if a.lv == b.lv then
return a.id > b.id
else
return a.lv > b.lv
end
else
return a.refineLv > b.refineLv
end
end)
this:SetItemData(allEquipTreasure)
end
end
--设置背包列表数据
local curHeroCanUpEquipTabs = {}
function this:SetItemData(_itemDatas)
2020-06-13 11:47:13 +08:00
--LogError(" " ..LengthOfTable(_itemDatas) )
2020-06-23 18:36:24 +08:00
this.itemNumText.text = Language[10188]..LengthOfTable(_itemDatas)
2020-05-09 13:31:21 +08:00
if LengthOfTable(_itemDatas)==0 then
this.emptyObj.gameObject:SetActive(true)
else
this.emptyObj.gameObject:SetActive(false)
end
--this:SortEquipDatas(_itemDatas)
--做装备叠加特殊组拼数据
-- local equips = {}
-- for i = 1, #_itemDatas do
-- --table.insert(equips,v)
-- if equips[_itemDatas[i].id] then
-- equips[_itemDatas[i].id].num = equips[_itemDatas[i].id].num + 1
-- else
-- equips[_itemDatas[i].id] = _itemDatas[i]
-- equips[_itemDatas[i].id].num = 1
-- end
-- end
-- local showList = {}
-- for i, v in pairs(equips) do
-- table.insert(showList, v)
-- end
this.ScrollView:SetData(_itemDatas, function (index, go)
this.SingleItemDataShow(go, _itemDatas[index])
end)
end
function this.SingleItemDataShow(_go,_itemData)
if not itemConfig[_itemData.id] then return end
local frame = Util.GetGameObject(_go.transform,"frame"):GetComponent("Image")
local icon =Util.GetGameObject(_go.transform,"icon"):GetComponent("Image")
local name = Util.GetGameObject(_go.transform,"name"):GetComponent("Text")
local star = Util.GetGameObject(_go.transform,"star")
2020-06-13 11:47:13 +08:00
local proIcon = Util.GetGameObject(_go.transform,"proIcon")
2020-05-09 13:31:21 +08:00
local jewerConfig=ConfigManager.TryGetConfigData(ConfigName.JewelConfig, _itemData.id)
local pos=0;
if jewerConfig then
if jewerConfig.Location==1 then
pos=5
else if jewerConfig.Location==2 then
pos=6
end
end
end
local lvObj=Util.GetGameObject(_go.transform,"lv"):GetComponent("Text")
local refineObj=Util.GetGameObject(_go.transform,"refine"):GetComponent("Text")
if itemConfig[_itemData.id].ItemType == ItemType.EquipTreasure then
icon.sprite=Util.LoadSprite(_itemData.icon)
frame.sprite=Util.LoadSprite(_itemData.frame)
2020-06-13 11:47:13 +08:00
proIcon:SetActive(true)
proIcon:GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(_itemData.itemConfig.PropertyName))
2020-05-09 13:31:21 +08:00
name.text=itemConfig[_itemData.id].Name
star:SetActive(false)
Util.GetGameObject(_go.transform,"redPoint"):SetActive(false)
lvObj.text=_itemData.lv
if _itemData.lv>0 then
lvObj.gameObject:SetActive(true)
else
lvObj.gameObject:SetActive(false)
end
refineObj.text="+".._itemData.refineLv
if _itemData.refineLv>0 then
refineObj.gameObject:SetActive(true)
else
refineObj.gameObject:SetActive(false)
end
Util.GetGameObject(_go.transform,"num").gameObject:SetActive(false)
-- 0.查看属性 1.穿戴 2.卸下 3.交换
--宝物界面
Util.AddOnceClick(Util.GetGameObject(_go.transform,"icon"), function()
if curEquipTreasureDatas[pos] then
UIManager.OpenPanel(UIName.RoleEquipTreasureChangePopup,this,3,curHeroData,curEquipTreasureDatas[pos],_itemData,pos)
else
UIManager.OpenPanel(UIName.RoleEquipTreasureChangePopup,this,1,curHeroData,_itemData,nil,pos)
end
end)
else
frame.sprite=Util.LoadSprite(_itemData.frame)
icon.sprite=Util.LoadSprite(_itemData.icon)
lvObj.gameObject:SetActive(false)
refineObj.gameObject:SetActive(false)
2020-06-13 11:47:13 +08:00
proIcon:SetActive(false)
2020-05-09 13:31:21 +08:00
name.text=_itemData.itemConfig.Name
star:SetActive(true)
EquipManager.SetEquipStarShow(star,_itemData.itemConfig.Id)
local redPoint = Util.GetGameObject(_go.transform,"redPoint")
if curHeroCanUpEquipTabs and #curHeroCanUpEquipTabs > 0 then
local isShow = false
for i = 1, #curHeroCanUpEquipTabs do
if curHeroCanUpEquipTabs[i] ==_itemData.did then
isShow = true
end
end
if isShow then
redPoint:SetActive(true)
else
redPoint:SetActive(false)
end
else
redPoint:SetActive(false)
end
Util.GetGameObject(_go.transform,"num"):GetComponent("Text").text = _itemData.num
Util.AddOnceClick(Util.GetGameObject(_go.transform,"icon"), function()
if curHeroEquipDatas[_itemData.equipConfig.Position] then
UIManager.OpenPanel(UIName.RoleEquipChangePopup,this,3,curHeroData,curHeroEquipDatas[_itemData.equipConfig.Position],_itemData,_itemData.equipConfig.Position)
else
UIManager.OpenPanel(UIName.RoleEquipChangePopup,this,1,curHeroData,_itemData,_itemData.equipConfig.Position)
end
end)
end
end
--刷新当前英雄装备坑位的信息
function this.UpdateEquipPosHeroData(_equipOrTreasure,_type,_selectEquipDataList,_oldSelectEquip,position)--type
--1 穿单件装备 2 卸单件装备 3 替换单件装备 4 一键穿装备 5一键脱装备
if _type==1 then
effectList[position]:SetActive(false)
effectList[position]:SetActive(true)
if _equipOrTreasure == 1 then
curSelectEquipData=_selectEquipDataList[1]
--装备绑英雄
EquipManager.SetEquipUpHeroDid(curSelectEquipData.did,curHeroData.dynamicId)
--英雄加装备
table.insert(curHeroData.equipIdList,curSelectEquipData.did)
else
curEquipTreasureDatas=_selectEquipDataList[1]
--装备绑英雄
EquipTreasureManager.SetEquipTreasureUpHeroDid(curEquipTreasureDatas.idDyn,curHeroData.dynamicId)
--英雄加装备
table.insert(curHeroData.jewels,curEquipTreasureDatas.idDyn)
end
elseif _type==2 then
if _equipOrTreasure == 1 then
--装备解绑英雄
curSelectEquipData = _selectEquipDataList[1]
EquipManager.SetEquipUpHeroDid(curSelectEquipData.did,"0")
for i = 1, #curHeroData.equipIdList do
if curHeroData.equipIdList[i]==curSelectEquipData.did then
--英雄删除装备
table.remove(curHeroData.equipIdList,i)
break
end
end
else
curEquipTreasureDatas = _selectEquipDataList[1]
EquipTreasureManager.SetEquipTreasureUpHeroDid(curEquipTreasureDatas.idDyn,"")
for i = 1, #curHeroData.jewels do
if curHeroData.jewels[i]==curEquipTreasureDatas.idDyn then
--英雄删除装备
table.remove(curHeroData.jewels,i)
break
end
end
end
elseif _type==3 then
effectList[position]:SetActive(false)
effectList[position]:SetActive(true)
if _equipOrTreasure == 1 then
curSelectEquipData=_selectEquipDataList[1]
--新装备绑英雄
EquipManager.SetEquipUpHeroDid(curSelectEquipData.did,curHeroData.dynamicId)--穿
if _oldSelectEquip then
--被替换装备解绑英雄
EquipManager.SetEquipUpHeroDid(_oldSelectEquip.did,"0")
end
--英雄替换新选择装备
if curHeroEquipDatas[curSelectEquipData.equipConfig.Position] then
for i = 1, #curHeroData.equipIdList do
if curHeroData.equipIdList[i]==curHeroEquipDatas[curSelectEquipData.equipConfig.Position].did then
curHeroData.equipIdList[i]=curSelectEquipData.did
end
end
end
else
curEquipTreasureDatas=_selectEquipDataList[1]
--新装备绑英雄
EquipTreasureManager.SetEquipTreasureUpHeroDid(curEquipTreasureDatas.idDyn,curHeroData.dynamicId)
if _oldSelectEquip then
--被替换装备解绑英雄
EquipTreasureManager.SetEquipTreasureUpHeroDid(_oldSelectEquip.idDyn,"")
end
--英雄替换新选择装备
for i = 1, #curHeroData.jewels do
if curHeroData.jewels[i]==_oldSelectEquip.idDyn then
curHeroData.jewels[i]=curEquipTreasureDatas.idDyn
end
end
end
elseif _type==4 then
--一键穿 把身上装备解绑英雄id
if _equipOrTreasure==1 then
for k,v in ipairs(curHeroData.equipIdList) do
EquipManager.SetEquipUpHeroDid(v,"0")
end
curHeroData.equipIdList={}
for i = 1, #_selectEquipDataList do
--把选择的装备绑上英雄
EquipManager.SetEquipUpHeroDid(_selectEquipDataList[i],curHeroData.dynamicId)--穿
--再把英雄装备list 清空并添加上新选择的装备
table.insert(curHeroData.equipIdList,_selectEquipDataList[i])
end
--宝物
else
for k,v in ipairs(curHeroData.jewels) do
EquipTreasureManager.SetTreasureUpOrDown(v,"0")
end
curHeroData.jewels={}
for i = 1, #_selectEquipDataList do
--把选择的装备绑上英雄
EquipTreasureManager.SetTreasureUpOrDown(_selectEquipDataList[i],curHeroData.dynamicId)--穿
--再把英雄装备list 清空并添加上新选择的装备
table.insert(curHeroData.jewels,_selectEquipDataList[i])
end
end
elseif _type==5 then
--一键脱 把身上装备英雄id置为“0” 再把英雄装备list清空
if _equipOrTreasure==1 then
if _selectEquipDataList then
for i = 1, #_selectEquipDataList do
EquipManager.SetEquipUpHeroDid(_selectEquipDataList[i],"0")
end
end
--for i = 1, #_selectEquipDataList do
-- --把选择的装备绑上英雄
-- -- EquipTreasureManager.SetTreasureUpOrDown(_selectEquipDataList[i],curHeroData.dynamicId)--穿
-- --再把英雄装备list 清空并添加上新选择的装备
-- table.remove(curHeroData.equipIdList,i)
--end
curHeroData.equipIdList={}
else
if _selectEquipDataList then
for i = 1, #_selectEquipDataList do
EquipTreasureManager.SetTreasureUpOrDown(_selectEquipDataList[i],"")
end
--table.remove(curHeroData.jewels,i)
curHeroData.jewels={}
end
--for i = 1, #_selectEquipDataList do
-- --把选择的装备绑上英雄
-- EquipTreasureManager.SetTreasureUpOrDown(_selectEquipDataList[i],curHeroData.dynamicId)--穿
-- --再把英雄装备list 清空并添加上新选择的装备
-- table.remove(curHeroData.equipIdList,_selectEquipDataList[i])
--end
end
--curHeroData.equipIdList={}
end
--刷新界面
this.ShowHeroEquip()
--上阵刷新红点
if isUpZhen then
this.allEquipUpRedPoint:SetActive(#HeroManager.GetHeroIsUpEquip(curHeroData.dynamicId) > 0)
end
--刷新当前英雄可穿装备
if indexBtnNum == PosIdConst.All then
this:OnClickAllBtn()
else
this:OnClickTabBtn(indexBtnNum)
end
--对比战力并更新战力值 播放战力变更动画
HeroManager.CompareWarPower(curHeroData.dynamicId)
end
--去除已穿的装备
function this:EquipListFilter(_allEquip)
local allShowEquip={}
for k, v in pairs(_allEquip) do
if v.upHeroDid=="0" then
if v.equipConfig.ProfessionLimit==0 or v.equipConfig.ProfessionLimit==curHeroData.profession then
table.insert(allShowEquip,v)
end
end
end
return allShowEquip
end
--选择图片设置父级
function this.SelectImageSetParent(_objPoint)
this.selsectSkillImage:SetActive(false)
this.selsectSkillImage.transform:SetParent(_objPoint.transform)
this.selsectSkillImage.transform.localScale = Vector3.one
this.selsectSkillImage.transform.localPosition = Vector3.zero
end
--界面关闭时调用(用于子类重写)
function RoleEquipPanel:OnClose()
end
function this:AddRedPointVale(_equipDatas)
for j = 1, #_equipDatas do
_equipDatas[j].isRedPointShow = 1
for i = 1, #curHeroCanUpEquipTabs do
if curHeroCanUpEquipTabs[i] ==_equipDatas[j].did then
_equipDatas[j].isRedPointShow = 2
end
end
end
end
function this:SortEquipDatas(_equipDatas)
if teamHero[curHeroData.dynamicId] then
isUpZhen = true
this.allEquipUpRedPoint:SetActive(#HeroManager.GetHeroIsUpEquip(curHeroData.dynamicId) > 0)
curHeroCanUpEquipTabs = HeroManager.GetHeroIsUpEquip(curHeroData.dynamicId)
else
isUpZhen = false
this.allEquipUpRedPoint:SetActive(false)
curHeroCanUpEquipTabs = {}
end
this:AddRedPointVale(_equipDatas)
table.sort(_equipDatas, function(a, b)
if a.isRedPointShow ==b.isRedPointShow then
if a.equipConfig.Quality ==b.equipConfig.Quality then
if a.equipConfig.Position ==b.equipConfig.Position then
return a.id < b.id
else
return a.equipConfig.Position < b.equipConfig.Position
end
else
return a.equipConfig.Quality > b.equipConfig.Quality
end
else
return a.isRedPointShow > b.isRedPointShow
end
end)
end
--做装备叠加特殊组拼数据
function this:EquipDJDatas(_itemDatas)
local equips = {}
for i = 1, #_itemDatas do
if equips[_itemDatas[i].id] then
equips[_itemDatas[i].id].num = equips[_itemDatas[i].id].num + 1
else
equips[_itemDatas[i].id] = _itemDatas[i]
equips[_itemDatas[i].id].num = 1
end
end
local showList = {}
for i, v in pairs(equips) do
table.insert(showList, v)
end
return showList
end
--界面销毁时调用(用于子类重写)
function RoleEquipPanel:OnDestroy()
SubUIManager.Close(this.UpView)
this.ScrollView = nil
end
2020-06-23 18:36:24 +08:00
return RoleEquipPanel