2020-08-25 15:46:38 +08:00
require ( " Base/BasePanel " )
2020-05-09 13:31:21 +08:00
local spcialConfig = ConfigManager.GetConfig ( ConfigName.SpecialConfig )
2020-07-06 20:35:39 +08:00
local equipConfig = ConfigManager.GetConfig ( ConfigName.EquipConfig )
2020-05-09 13:31:21 +08:00
RoleEquipPanel = Inherit ( BasePanel )
2020-12-17 10:41:00 +08:00
local isGonming = 0
2020-05-09 13:31:21 +08:00
--local SortTypeConst = {
-- Natural = 1,--品阶 ur+ --> r 6 --> 1
-- Lv = 2
--}
local PosIdConst = {
2020-07-06 20:35:39 +08:00
All = 0 ,
--全部
WuQi = 1 ,
--武器
ZhanFu = 2 ,
--战服
TouShi = 3 ,
--头饰
ZhanXue = 4 ,
--战靴
Hun = 5 ,
--魂宝
Ling = 6
--灵宝
2020-05-09 13:31:21 +08:00
}
2020-07-06 20:35:39 +08:00
local this = RoleEquipPanel
--当前英雄穿的装备
local curHeroEquipDatas = { }
--当前英雄
2020-05-09 13:31:21 +08:00
local curHeroData
2020-07-06 20:35:39 +08:00
2020-05-09 13:31:21 +08:00
local heroListData
local curSelectEquipData
local index
2020-07-06 20:35:39 +08:00
local indexBtnNum = 0
2020-12-28 16:25:38 +08:00
local typeTab = {
[ 0 ] = " 全部 " ,
[ 1 ] = Language [ 10427 ] ,
[ 2 ] = Language [ 10428 ] ,
[ 3 ] = Language [ 10429 ] ,
[ 4 ] = Language [ 10430 ] ,
[ 5 ] = Language [ 10505 ] ,
[ 6 ] = Language [ 10506 ] }
2020-05-09 13:31:21 +08:00
local tabs = { }
local openThisPanel
2020-07-06 20:35:39 +08:00
local effectList = { }
2020-05-09 13:31:21 +08:00
local orginLayer1
local orginLayer
local isUpZhen = false
local teamHero = { }
local itemConfig = ConfigManager.GetConfig ( ConfigName.ItemConfig )
local jewerConfigs = ConfigManager.GetConfig ( ConfigName.JewelConfig )
2020-07-06 20:35:39 +08:00
local currPageIndex = 0
2020-05-09 13:31:21 +08:00
local curEquipTreasureDatas = { }
2020-06-13 11:47:13 +08:00
local isCanUpEquipTreasure = false
2020-12-24 18:57:19 +08:00
local isPlayAnim = true
local isFristOpenTime
2020-05-09 13:31:21 +08:00
--初始化组件( 用于子类重写) RoleEquipChangePopup
function RoleEquipPanel : InitComponent ( )
orginLayer = 10
2020-07-06 20:35:39 +08:00
orginLayer1 = { 0 , 0 , 0 , 0 , 0 , 0 }
this.bg2 = Util.GetGameObject ( self.transform , " bg2 " )
2020-05-09 13:31:21 +08:00
screenAdapte ( this.bg2 )
2020-07-06 20:35:39 +08:00
this.UpView = SubUIManager.Open ( SubUIConfig.UpView , self.gameObject . transform , { showType = UpViewOpenType.ShowLeft } )
this.btnBack = Util.GetGameObject ( self.transform , " btnBack/btnBack " )
2020-05-09 13:31:21 +08:00
--英雄
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 " )
2020-06-28 17:48:49 +08:00
Util.GetGameObject ( self.transform , " bg/heroInfo/pos " ) : SetActive ( false )
--this.heroPosIcon = Util.GetGameObject(self.transform, "bg/heroInfo/pos/icon"):GetComponent("Image")
2020-05-09 13:31:21 +08:00
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 " )
--英雄身上的装备
2020-07-06 20:35:39 +08:00
this.equipGrid = Util.GetGameObject ( self.transform , " bg/equipInfo " )
2020-05-09 13:31:21 +08:00
local scale = ( Screen.width / Screen.height / 1080 * 1920 + 1 ) / 2
if scale < 1 then
for i = 1 , this.equipGrid . transform.childCount do
2020-07-06 20:35:39 +08:00
Util.SetParticleScale ( Util.GetGameObject ( this.equipGrid . transform : GetChild ( i - 1 ) , " effect " ) , scale )
2020-05-09 13:31:21 +08:00
end
end
--装备list
2020-07-06 20:35:39 +08:00
this.effect = Util.GetGameObject ( self.transform , " bg/effect " )
2020-05-09 13:31:21 +08:00
for i = 0 , 6 do
tabs [ i ] = Util.GetGameObject ( self.transform , " Tabs/Btn " .. i )
2020-07-06 20:35:39 +08:00
effectList [ i ] = Util.GetGameObject ( self.transform , " bg/equipInfo/equip " .. i .. " /effect " )
2020-05-09 13:31:21 +08:00
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 " )
2020-07-06 20:35:39 +08:00
this.selsectSkillImage = Util.GetGameObject ( self.gameObject , " selsectSkillImage " )
2020-05-09 13:31:21 +08:00
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 " )
2020-07-06 20:35:39 +08:00
this.allEquipUpRedPoint = Util.GetGameObject ( self.transform , " allEquipUp/redPoint " )
2020-05-09 13:31:21 +08:00
2020-07-06 20:35:39 +08:00
this.ScrollBar = Util.GetGameObject ( self.gameObject , " Scrollbar " ) : GetComponent ( " Scrollbar " )
2020-05-09 13:31:21 +08:00
local v2 = Util.GetGameObject ( self.gameObject , " scroll " ) : GetComponent ( " RectTransform " ) . rect
2020-07-06 20:35:39 +08:00
this.ScrollView =
SubUIManager.Open (
SubUIConfig.ScrollCycleView ,
Util.GetGameObject ( self.transform , " scroll " ) . transform ,
this.equipPre ,
this.ScrollBar ,
2020-09-04 16:54:58 +08:00
Vector2.New ( v2.width , v2.height ) ,
2020-07-06 20:35:39 +08:00
1 ,
5 ,
2020-09-04 16:54:58 +08:00
Vector2.New ( 40 , 15 )
2020-07-06 20:35:39 +08:00
)
2020-05-09 13:31:21 +08:00
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 " )
2020-07-06 20:35:39 +08:00
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 " )
2020-05-09 13:31:21 +08:00
this.emptyObj . gameObject : SetActive ( false )
2020-12-24 18:57:19 +08:00
this.mask = Util.GetGameObject ( self.gameObject , " mask " )
2020-12-25 09:57:32 +08:00
this.equipBtn5 = Util.GetGameObject ( self.gameObject , " bg/equipInfo/equip5/Image " )
this.equipBtn6 = Util.GetGameObject ( self.gameObject , " bg/equipInfo/equip6/Image " )
2020-12-24 18:57:19 +08:00
this.equipBTn5Add = Util.GetGameObject ( self.gameObject , " bg/equipInfo/equip5/add " )
this.equipBtn6Add = Util.GetGameObject ( self.gameObject , " bg/equipInfo/equip6/add " )
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function RoleEquipPanel : BindEvent ( )
2020-07-06 20:35:39 +08:00
Util.AddClick (
this.btnBack ,
function ( )
PlaySoundWithoutClick ( SoundConfig.Sound_UICancel )
if openThisPanel.RefreshHeroDatas then
2020-07-21 16:04:07 +08:00
openThisPanel : RefreshHeroDatas ( curHeroData , HeroManager.heroSortedDatas )
2020-07-06 20:35:39 +08:00
end
self : ClosePanel ( )
end
)
Util.AddClick (
this.leftBtn ,
function ( )
2020-12-24 18:57:19 +08:00
isPlayAnim = true
2020-07-06 20:35:39 +08:00
this : LeftBtnOnClick ( )
end
)
2020-05-09 13:31:21 +08:00
2020-07-06 20:35:39 +08:00
Util.AddClick (
this.rightBtn ,
function ( )
2020-12-24 18:57:19 +08:00
isPlayAnim = true
2020-07-06 20:35:39 +08:00
this : RightBtnOnClick ( )
end
)
Util.AddOnceClick (
this.allEquipUp ,
function ( )
this : AllEquipUpBtnOnClick ( )
end
)
2020-05-09 13:31:21 +08:00
2020-07-06 20:35:39 +08:00
Util.AddOnceClick (
this.allEquipDown ,
function ( )
2021-01-08 17:29:54 +08:00
--HarmonyManager:IsShowGongMingEqiup(curHeroData.dnyamicId) and
2021-01-14 21:11:53 +08:00
--print(tostring(HarmonyManager:IsShowGongMingEqiup(curHeroData.dnyamicId)),tostring(curHeroData.harmonyGongMing))
2020-12-28 13:37:30 +08:00
if HarmonyManager : IsShowGongMingEqiup ( curHeroData.dynamicId ) and curHeroData.harmonyGongMing then
-- body
PopupTipPanel.ShowTip ( " 共鸣装备,无法一键卸下 " )
else
this : AllEquipDownBtnOnClick ( )
end
2020-07-06 20:35:39 +08:00
end
)
2020-05-09 13:31:21 +08:00
for i = 0 , 6 do
2020-07-06 20:35:39 +08:00
Util.AddClick (
2020-12-24 18:57:19 +08:00
tabs [ i ] ,
2020-07-06 20:35:39 +08:00
function ( )
2020-12-24 18:57:19 +08:00
isPlayAnim = true
2020-07-06 20:35:39 +08:00
if i == indexBtnNum then
2020-12-28 16:25:38 +08:00
return
end
indexBtnNum = i
if indexBtnNum == PosIdConst.All then
2020-07-06 20:35:39 +08:00
this : OnClickAllBtn ( )
else
this : OnClickTabBtn ( indexBtnNum )
2020-12-28 16:25:38 +08:00
end
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
)
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
Util.AddClick (
this.equipTreasureBtn ,
function ( )
if LengthOfTable ( curEquipTreasureDatas ) < 2 then
PopupTipPanel.ShowTip ( Language [ 11825 ] )
return
end
UIManager.OpenPanel ( UIName.EquipTreasureResonancePanel , curHeroData )
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
)
2020-12-24 18:57:19 +08:00
Util.AddClick (
this.equipBtn5 ,
function ( )
UIManager.OpenPanel ( UIName.RewardItemSingleShowPopup , 9999 , nil )
end
)
Util.AddClick (
this.equipBtn6 ,
function ( )
UIManager.OpenPanel ( UIName.RewardItemSingleShowPopup , 9998 , nil )
end
)
2020-05-09 13:31:21 +08:00
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
2020-07-06 20:35:39 +08:00
2020-05-09 13:31:21 +08:00
--界面打开时调用(用于子类重写)
function RoleEquipPanel : OnOpen ( ... )
2020-07-06 20:35:39 +08:00
local data = { ... }
2020-05-09 13:31:21 +08:00
if data [ 1 ] then
2020-07-06 20:35:39 +08:00
curHeroData = data [ 1 ]
HeroManager.roleEquipPanelCurHeroData = data [ 1 ]
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
curHeroData = HeroManager.roleEquipPanelCurHeroData
2020-05-09 13:31:21 +08:00
end
if data [ 2 ] then
2020-07-06 20:35:39 +08:00
heroListData = data [ 2 ]
HeroManager.roleEquipPanelHeroListData = data [ 2 ]
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
heroListData = HeroManager.GetAllHeroDatas ( )
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
openThisPanel = data [ 3 ]
2020-05-09 13:31:21 +08:00
isUpZhen = data [ 4 ]
end
function RoleEquipPanel : OnShow ( )
2020-12-24 18:57:19 +08:00
isPlayAnim = true
2020-05-09 13:31:21 +08:00
for i = 1 , # heroListData do
if curHeroData == heroListData [ i ] then
index = i
end
end
for i = 1 , 6 do
2020-07-06 20:35:39 +08:00
if ( effectList [ i ] ~= nil ) then
2020-05-09 13:31:21 +08:00
effectList [ i ] : SetActive ( false )
end
end
2020-07-06 20:35:39 +08:00
indexBtnNum = PosIdConst.All
2020-09-03 16:03:14 +08:00
teamHero = FormationManager.GetAllMainFormationHeroId ( )
2020-05-09 13:31:21 +08:00
this.ShowHeroEquip ( true )
this : OnClickAllBtn ( )
2020-07-06 20:35:39 +08:00
this.UpView : OnOpen ( { showType = UpViewOpenType.ShowLeft , panelType = PanelType.Main } )
2020-05-09 13:31:21 +08:00
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
2020-07-07 16:35:57 +08:00
2020-05-09 13:31:21 +08:00
--一键装备
function this : AllEquipUpBtnOnClick ( )
2020-07-06 20:35:39 +08:00
local allEquipIds = { }
local allTreasureIds = { }
2020-05-09 13:31:21 +08:00
--计算英雄身上的所有装备位的装备
2020-07-06 20:35:39 +08:00
local curHeroEquipDatas = { }
2020-12-17 10:41:00 +08:00
local curHeroDataequipIdList = curHeroData.equipIdList
for k , v in ipairs ( curHeroDataequipIdList ) do
2020-07-06 20:35:39 +08:00
local equipData = EquipManager.GetSingleHeroSingleEquipData ( v , curHeroData.dynamicId )
if equipData ~= nil then
curHeroEquipDatas [ equipData.equipConfig . Position ] = equipData
else
2020-07-10 19:13:29 +08:00
LogBlue ( Language [ 12238 ] )
2020-05-09 13:31:21 +08:00
end
end
2020-07-06 20:35:39 +08:00
2020-05-09 13:31:21 +08:00
--宝物数据
2020-07-06 20:35:39 +08:00
for k , v in ipairs ( curHeroData.jewels ) do
local equipData = EquipTreasureManager.GetSingleTreasureByIdDyn ( v )
if equipData ~= nil then
curHeroEquipDatas [ equipData.equipType + 4 ] = equipData
2020-05-09 13:31:21 +08:00
end
end
2020-07-06 20:35:39 +08:00
local equipEffectPos = { }
local treasureEffectPos = { }
2020-05-09 13:31:21 +08:00
for i = 1 , 6 do
2020-07-06 20:35:39 +08:00
local curPosEquip = { }
local index = i
2020-08-25 16:23:41 +08:00
if ( index == 5 or index == 6 ) and isCanUpEquipTreasure then
2020-07-06 20:35:39 +08:00
curPosEquip =
EquipTreasureManager.GetTreasureDataByPos (
index ,
curHeroData.dynamicId ,
curHeroData.heroConfig . PropertyName
)
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
--获取到所有未装备的装备
curPosEquip = BagManager.GetEquipDataByEquipPosition ( curHeroData.heroConfig . Profession , index )
2020-05-09 13:31:21 +08:00
end
2020-08-26 10:16:16 +08:00
-- LogBlue("i:"..index.." #curPosEquip:".. #curPosEquip)
-- LogBlue("计算每个位置可装备的装备战力")-- 取战力最大的装备
2020-07-06 20:35:39 +08:00
if curPosEquip and # curPosEquip > 0 then
local equiData = { }
local indexMaxPower = 0
if curHeroEquipDatas [ index ] then
equiData = curHeroEquipDatas [ index ]
2020-08-25 16:23:41 +08:00
--获取到宝物战力
if index == 5 or index == 6 then
2020-07-06 20:35:39 +08:00
indexMaxPower = EquipTreasureManager.CalculateWarForce ( curHeroEquipDatas [ index ] . idDyn )
2020-08-26 10:16:16 +08:00
--LogBlue("宝物id: "..curHeroEquipDatas[index].idDyn.." id:"..curHeroEquipDatas[index].id.." indexMaxPower:"..indexMaxPower)
2020-07-06 20:35:39 +08:00
else
2020-08-25 16:23:41 +08:00
--获取到装备战力
2020-07-06 20:35:39 +08:00
indexMaxPower = EquipManager.CalculateWarForce ( curHeroEquipDatas [ index ] . id )
2020-08-26 10:16:16 +08:00
--LogBlue("装备id: "..curHeroEquipDatas[index].id.." indexMaxPower:"..indexMaxPower)
2020-07-06 20:35:39 +08:00
end
end
2020-08-26 10:16:16 +08:00
--LogGreen("循环计算每个装备的战力")
2020-05-09 13:31:21 +08:00
for i = 1 , # curPosEquip do
2020-07-06 20:35:39 +08:00
local addPower = 0
local curEquip = curPosEquip [ i ]
2020-05-09 13:31:21 +08:00
if curEquip then
2020-08-25 16:23:41 +08:00
if index == 5 or index == 6 then
2020-07-06 20:35:39 +08:00
addPower = EquipTreasureManager.CalculateWarForce ( curEquip.idDyn )
2020-08-26 10:16:16 +08:00
--LogGreen("宝物id: "..curEquip.idDyn.." id:"..curEquip.id.." addPower:"..addPower)
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
addPower = EquipManager.CalculateWarForce ( curEquip.id )
2020-08-26 10:16:16 +08:00
--LogGreen("装备id: "..curEquip.id.." addPower:"..addPower)
2020-05-09 13:31:21 +08:00
end
end
2020-08-25 16:23:41 +08:00
if addPower > indexMaxPower then
2020-07-06 20:35:39 +08:00
indexMaxPower = addPower
equiData = curEquip
2020-05-09 13:31:21 +08:00
end
end
2020-08-26 10:16:16 +08:00
-- if index == 5 or index == 6 then
-- LogYellow("宝物id: "..equiData.idDyn.." id:"..equiData.id)
-- else
-- LogYellow("装备id: "..equiData.id)
-- end
2020-08-25 16:23:41 +08:00
if ( index == 5 or index == 6 ) then
if ( ( curHeroEquipDatas [ index ] and equiData.idDyn ~= curHeroEquipDatas [ index ] . idDyn )
or ( not curHeroEquipDatas [ index ] ) ) then
table.insert ( allTreasureIds , equiData.idDyn )
end
2020-05-09 13:31:21 +08:00
else
2020-08-25 16:23:41 +08:00
if ( not curHeroEquipDatas [ index ] or tonumber ( equiData.id ) ~= tonumber ( curHeroEquipDatas [ index ] . id ) ) then
2020-07-06 20:35:39 +08:00
table.insert ( allEquipIds , tostring ( equiData.id ) )
end
2020-05-09 13:31:21 +08:00
end
2020-08-25 16:23:41 +08:00
2020-05-09 13:31:21 +08:00
--特效
if curHeroEquipDatas [ equiData.position ] then
if equiData.idDyn then
if equiData.idDyn ~= curHeroEquipDatas [ equiData.position ] . idDyn then
2020-07-06 20:35:39 +08:00
table.insert ( treasureEffectPos , i )
2020-05-09 13:31:21 +08:00
end
else
2020-07-06 20:35:39 +08:00
if equiData.id ~= curHeroEquipDatas [ equiData.position ] . id then
table.insert ( equipEffectPos , i )
2020-05-09 13:31:21 +08:00
end
end
else
--table.insert(showEffectPos,i)
end
end
end
2020-08-26 10:16:16 +08:00
-- LogYellow("装备:"..#allEquipIds)
-- LogYellow("宝物:"..#allTreasureIds)
-- LogYellow("isCanUpEquipTreasure:"..tostring(isCanUpEquipTreasure))
2020-07-07 16:35:57 +08:00
if ( allEquipIds and # allEquipIds > 0 ) or ( isCanUpEquipTreasure and allTreasureIds and # allTreasureIds > 0 ) then
--isCanUpEquipTreasure
2021-01-08 17:29:54 +08:00
if allEquipIds and # allEquipIds > 0 and not curHeroData.harmonyGongMing then
2020-08-26 10:16:16 +08:00
-- for i = 1, #allEquipIds do
-- LogGreen("一键装备"..allEquipIds[i])
-- end
2020-07-07 16:35:57 +08:00
--穿装备协议
2020-12-17 10:41:00 +08:00
NetManager.EquipWearRequest (
2020-07-07 16:35:57 +08:00
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 )
2020-07-06 20:35:39 +08:00
end
2020-06-13 11:47:13 +08:00
end
2020-07-07 16:35:57 +08:00
end
)
end
2021-01-08 17:29:54 +08:00
if curHeroData.harmonyGongMing then
PopupTipPanel.ShowTip ( " 装备共鸣中,不可一键装备! " )
end
2020-07-07 16:35:57 +08:00
--穿戴宝物
2020-08-24 15:08:21 +08:00
if isCanUpEquipTreasure and allTreasureIds and # allTreasureIds > 0 then
2020-08-26 10:16:16 +08:00
-- for i = 1, #allTreasureIds do
-- LogGreen("一键宝物"..allTreasureIds[i])
-- end
2020-07-07 16:35:57 +08:00
--穿装备协议
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
)
end
else
if not allEquipIds or # allEquipIds < 1 then
2020-12-23 16:46:41 +08:00
if # curHeroData.equipIdList <= 0 then
PopupTipPanel.ShowTip ( Language [ 11826 ] )
else
PopupTipPanel.ShowTip ( " 已为最强装备 " )
end
2020-07-07 16:35:57 +08:00
else
PopupTipPanel.ShowTip ( Language [ 11827 ] )
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
end
PlaySoundWithoutClick ( SoundConfig.Sound_Wear )
this.ShowHeroEquip ( )
end
--一键卸下
function this : AllEquipDownBtnOnClick ( )
2020-07-06 20:35:39 +08:00
if
( curHeroData.equipIdList and # curHeroData.equipIdList > 0 ) or
( curHeroData.jewels and # curHeroData.jewels > 0 and isCanUpEquipTreasure )
then
if curHeroData.equipIdList and # curHeroData.equipIdList > 0 then
NetManager.EquipUnLoadOptRequest (
curHeroData.dynamicId ,
curHeroData.equipIdList ,
1 ,
function ( )
this.UpdateEquipPosHeroData ( 1 , 5 , curHeroData.equipIdList )
end
)
end
--寶物
if curHeroData.jewels and # curHeroData.jewels > 0 then
-- 一键卸下音效
NetManager.EquipUnLoadOptRequest (
curHeroData.dynamicId ,
curHeroData.jewels ,
2 ,
function ( )
this.UpdateEquipPosHeroData ( 2 , 5 , curHeroData.jewels )
end
)
end
2020-05-09 13:31:21 +08:00
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 ( )
2020-07-06 20:35:39 +08:00
-- this:OnClickTabBtn(indexBtnNum)
2020-05-09 13:31:21 +08:00
end
2020-07-07 16:35:57 +08:00
2020-05-09 13:31:21 +08:00
function this . ShowHeroEquip ( )
--装备
if curHeroData and spcialConfig then
2020-07-06 20:35:39 +08:00
local config = spcialConfig [ 40 ]
2020-05-09 13:31:21 +08:00
if config then
local limits = string.split ( config.Value , " | " )
if limits then
2020-07-06 20:35:39 +08:00
local heroConfig = ConfigManager.GetConfigData ( ConfigName.HeroConfig , curHeroData.id )
local lvs = string.split ( limits [ 1 ] , " # " )
local stars = string.split ( limits [ 2 ] , " # " )
2020-12-17 10:41:00 +08:00
--LogBlue("tonumber(lvs[2]):" ..lvs[2].."PlayerManager.level:"..PlayerManager.level)
2020-07-06 20:35:39 +08:00
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
2020-08-04 20:49:42 +08:00
SetHeroBg ( Util.GetGameObject ( this.transform , " bg/heroInfo " ) , Util.GetGameObject ( this.transform , " bg/heroInfo/bg " ) , curHeroData.star )
2020-05-09 13:31:21 +08:00
this.heroLv . text = curHeroData.lv
this.heroIcon . sprite = Util.LoadSprite ( curHeroData.painting )
2020-06-28 17:48:49 +08:00
--this.heroPosIcon.sprite = Util.LoadSprite(curHeroData.professionIcon)
2020-05-09 13:31:21 +08:00
this.heroProIcon . sprite = Util.LoadSprite ( GetProStrImageByProNum ( curHeroData.heroConfig . PropertyName ) )
--this.heroStage.sprite = Util.LoadSprite(HeroStageSprite[curHeroData.heroConfig.HeroStage])
2020-07-24 20:03:06 +08:00
SetHeroStars ( this.heroStarGrid , curHeroData.star , 1 , nil , - 10 )
2020-05-09 13:31:21 +08:00
--装备的数据
2020-07-06 20:35:39 +08:00
curHeroEquipDatas = { }
2020-05-09 13:31:21 +08:00
for i = 1 , # curHeroData.equipIdList do
2020-07-06 20:35:39 +08:00
local equipData = EquipManager.GetSingleHeroSingleEquipData ( curHeroData.equipIdList [ i ] , curHeroData.dynamicId )
if equipData ~= nil then
curHeroEquipDatas [ equipData.equipConfig . Position ] = equipData
2020-05-09 13:31:21 +08:00
end
end
--宝器的数据
2020-07-06 20:35:39 +08:00
curEquipTreasureDatas = { }
2020-05-09 13:31:21 +08:00
--LogError("#curHeroData.jewels "..#curHeroData.jewels)
for i = 1 , # curHeroData.jewels do
2020-07-06 20:35:39 +08:00
local treasureData = EquipTreasureManager.GetSingleEquipTreasreData ( curHeroData.jewels [ i ] )
if treasureData ~= nil then
local id = treasureData.id
local pos = jewerConfigs [ id ] . Location + 4
curEquipTreasureDatas [ pos ] = treasureData
2020-05-09 13:31:21 +08:00
end
end
--this.equipTreasureBtn:SetActive(LengthOfTable(curEquipTreasureDatas) >= 2)
for i = 1 , this.equipGrid . transform.childCount do
2020-07-06 20:35:39 +08:00
local go = this.equipGrid . transform : GetChild ( i - 1 ) . gameObject
local effect = Util.GetGameObject ( go.transform , " effect " )
2020-05-09 13:31:21 +08:00
screenAdapte ( effect )
Util.AddParticleSortLayer ( effect , this.sortingOrder - orginLayer1 [ i ] )
2020-07-06 20:35:39 +08:00
orginLayer1 [ i ] = this.sortingOrder
effectList [ i ] = effect
local lvObj = Util.GetGameObject ( go.transform , " lv " )
local refineObj = Util.GetGameObject ( go.transform , " refine " )
2020-05-09 13:31:21 +08:00
if curHeroEquipDatas [ i ] then
2020-12-17 10:41:00 +08:00
this : UpdateEquipItem ( go , curHeroEquipDatas [ i ] , lvObj , refineObj )
2020-05-09 13:31:21 +08:00
elseif curEquipTreasureDatas [ i ] then
2020-12-17 10:41:00 +08:00
-- print(curEquipTreasureDatas[i])
2020-07-06 20:35:39 +08:00
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-07-06 20:35:39 +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-07-06 20:35:39 +08:00
Util.GetGameObject ( go.transform , " frame/star " ) : SetActive ( false )
2020-08-17 11:39:41 +08:00
Util.GetGameObject ( go.transform , " num " ) . gameObject : SetActive ( false )
Util.GetGameObject ( go.transform , " proIcon " ) : GetComponent ( " Image " ) . sprite =
2020-12-17 10:41:00 +08:00
Util.LoadSprite ( GetProStrImageByProNum ( curEquipTreasureDatas [ i ] . itemConfig.PropertyName ) )
--鸿蒙阵 共享数据判断
2020-12-26 15:07:51 +08:00
if HarmonyManager.IsInfo ( curEquipTreasureDatas [ i ] . upHeroDid ) and HarmonyManager.GetSingleAdditions ( HarmonyAddType.HunSoulPrint ) ~= - 1 then
2020-12-17 10:41:00 +08:00
-- body
2021-01-14 21:11:53 +08:00
--curEquipTreasureDatas[i].lv = curEquipTreasureDatas[i].lv > HarmonyManager.GetSingleAdditions(HarmonyAddType.HunSoulPrint) and curEquipTreasureDatas[i].lv or HarmonyManager.GetSingleAdditions(HarmonyAddType.HunSoulPrint)
2020-12-17 10:41:00 +08:00
Util.GetGameObject ( go.transform , " HongMenging " ) : SetActive ( true )
2020-12-26 15:07:51 +08:00
elseif HarmonyManager.IsInfo ( curEquipTreasureDatas [ i ] . upHeroDid ) and HarmonyManager.GetSingleAdditions ( HarmonyAddType.LingSoulPrint ) ~= - 1 then
2021-01-14 21:11:53 +08:00
--curEquipTreasureDatas[i].lv = curEquipTreasureDatas[i].lv > HarmonyManager.GetSingleAdditions(HarmonyAddType.LingSoulPrint) and curEquipTreasureDatas[i].lv or HarmonyManager.GetSingleAdditions(HarmonyAddType.LingSoulPrint)
2020-12-26 15:07:51 +08:00
Util.GetGameObject ( go.transform , " HongMenging " ) : SetActive ( true )
2020-12-17 10:41:00 +08:00
else
2020-12-26 15:07:51 +08:00
-- body
2020-12-17 10:41:00 +08:00
Util.GetGameObject ( go.transform , " HongMenging " ) : SetActive ( false )
end
2020-07-06 20:35:39 +08:00
if curEquipTreasureDatas [ i ] . lv > 0 and lvObj then
lvObj : GetComponent ( " Text " ) . text = curEquipTreasureDatas [ i ] . lv
2021-01-14 21:11:53 +08:00
print ( curEquipTreasureDatas [ i ] . lv , " ..... " )
2020-05-09 13:31:21 +08:00
lvObj : SetActive ( true )
else
lvObj : SetActive ( false )
end
2020-07-06 20:35:39 +08:00
if curEquipTreasureDatas [ i ] . refineLv > 0 then
refineObj : GetComponent ( " Text " ) . text = " + " .. curEquipTreasureDatas [ i ] . refineLv
2020-05-09 13:31:21 +08:00
refineObj : SetActive ( true )
else
refineObj : SetActive ( false )
end
2021-01-07 21:45:22 +08:00
-- if i==5 then
-- this.equipBTn5Add:SetActive(false)
-- elseif i==6 then
-- this.equipBtn6Add:SetActive(false)
-- end
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
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 )
2020-05-09 13:31:21 +08:00
end
if lvObj then
lvObj : SetActive ( false )
end
if refineObj then
refineObj : SetActive ( false )
end
2021-01-07 21:45:22 +08:00
-- if i==5 then
-- this.equipBTn5Add:SetActive(true)
-- elseif i==6 then
-- this.equipBtn6Add:SetActive(true)
-- end
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
local iconBtn = Util.GetGameObject ( go.transform , " icon " )
Util.AddOnceClick (
iconBtn ,
function ( )
2020-12-17 10:41:00 +08:00
2020-07-06 20:35:39 +08:00
if curHeroEquipDatas [ i ] then
2020-12-17 10:41:00 +08:00
2020-07-06 20:35:39 +08:00
curSelectEquipData = curHeroEquipDatas [ i ]
2020-12-17 10:41:00 +08:00
UIManager.OpenPanel ( UIName.RoleEquipChangePopup , this , 2 , curHeroData , curHeroEquipDatas [ i ] )
-- end
-- if HarmonyManager:IsShowGongMingEqiup(curHeroData.dynamicId) then
-- -- body
-- this:OpenTips()
-- else
-- end
2020-07-06 20:35:39 +08:00
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
)
2020-05-09 13:31:21 +08:00
end
end
end
end
2020-07-06 20:35:39 +08:00
)
2020-05-09 13:31:21 +08:00
end
2020-08-31 11:03:16 +08:00
-- local allAddProVal = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false)
local allAddProVal
--计算面板属性
if isUpZhen then
local formationList = FormationManager.GetFormationByID ( FormationTypeDef.FORMATION_NORMAL )
local allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal ( formationList.teamHeroInfos , curHeroData.dynamicId )
allAddProVal = HeroManager.CalculateHeroAllProValList ( 1 , curHeroData.dynamicId , false , nil , nil , true , allHeroTeamAddProVal )
else
allAddProVal = HeroManager.CalculateHeroAllProValList ( 1 , curHeroData.dynamicId , false )
end
2020-07-06 20:35:39 +08:00
this.force . text = allAddProVal [ HeroProType.WarPower ]
2020-05-09 13:31:21 +08:00
end
2020-07-07 16:35:57 +08:00
2020-05-09 13:31:21 +08:00
function this : SetSelectBtn ( )
2020-12-28 16:25:38 +08:00
this.selectBtn : SetActive ( true )
this.selectBtn . transform : SetParent ( tabs [ indexBtnNum ] . transform )
this.selectBtn : GetComponent ( " RectTransform " ) . anchoredPosition3D = Vector3 ( - 12.28 , 1.08 , 0 )
--this.selectBtn.transform.localScale = Vector3.one
--this.selectBtn:GetComponent("Image"):SetNativeSize()
Util.GetGameObject ( this.selectBtn . transform , " Text " ) : GetComponent ( " Text " ) . text = typeTab [ indexBtnNum ]
2020-05-09 13:31:21 +08:00
end
2020-12-17 10:41:00 +08:00
function this : OpenTips ( nextEquipData , pos )
local content = " 更换后将暂时失去共鸣装备,确定更换? "
MsgPanel.ShowTwo ( content , function ( )
end , function ( )
local equipIdList = { }
local equipDataList = { }
table.insert ( equipIdList , tostring ( nextEquipData.id ) )
table.insert ( equipDataList , nextEquipData )
NetManager.EquipWearRequest ( curHeroData.dynamicId , equipIdList , 1 , function ( )
this.UpdateEquipPosHeroData ( 1 , 3 , equipDataList , nextEquipData , pos )
end )
end , " 取消 " , " 确认 " )
end
function this : UpdateEquipItem ( go , data , lvObj , refineObj )
Util.GetGameObject ( go.transform , " frame " ) : SetActive ( true )
Util.GetGameObject ( go.transform , " mask " ) : SetActive ( false )
if HarmonyManager : IsShowGongMingEqiup ( curHeroData.dynamicId ) and curHeroData.harmonyGongMing then
-- body
Util.GetGameObject ( go.transform , " HongMenging " ) : SetActive ( true )
else
Util.GetGameObject ( go.transform , " HongMenging " ) : SetActive ( false )
end
--Util.GetGameObject(go.transform,"proIcon"):SetActive(false)
Util.GetGameObject ( go.transform , " frame/icon " ) : GetComponent ( " Image " ) . sprite =
Util.LoadSprite ( data.icon )
Util.GetGameObject ( go.transform , " frame " ) : GetComponent ( " Image " ) . sprite =
Util.LoadSprite ( data.frame )
--Util.GetGameObject(go.transform,"proIcon"):GetComponent("Image").sprite=Util.LoadSprite(curHeroEquipDatas[i].frame)
if lvObj then
lvObj : SetActive ( false )
end
if refineObj then
refineObj : SetActive ( false )
end
EquipManager.SetEquipStarShow (
Util.GetGameObject ( go.transform , " frame/star " ) ,
data.itemConfig . Id
)
end
2020-05-09 13:31:21 +08:00
--点击全部按钮
function this : OnClickAllBtn ( )
this : SetSelectBtn ( )
2020-07-06 20:35:39 +08:00
local itemData = BagManager.GetEquipDataByEquipPosition ( curHeroData.heroConfig . Profession )
2020-05-09 13:31:21 +08:00
this : SortEquipDatas ( itemData )
2020-07-09 10:53:15 +08:00
local count = 0
for i = 1 , # itemData do
count = count + itemData [ i ] . num
end
2020-05-09 13:31:21 +08:00
--加上宝器数据
2020-06-13 11:47:13 +08:00
local curAllEquipTreasure = EquipTreasureManager.GetAllTreasures ( curHeroData.heroConfig . PropertyName )
2020-05-09 13:31:21 +08:00
--宝器排序
2020-07-06 20:35:39 +08:00
for i = 1 , # curAllEquipTreasure do
table.insert ( itemData , curAllEquipTreasure [ i ] )
2020-05-09 13:31:21 +08:00
end
2020-07-09 10:53:15 +08:00
this.itemNumText . text = Language [ 10188 ] .. count + LengthOfTable ( curAllEquipTreasure )
2020-05-09 13:31:21 +08:00
this : SetItemData ( itemData )
end
2020-07-06 20:35:39 +08:00
2020-05-09 13:31:21 +08:00
--点击装备按钮
function this : OnClickTabBtn ( _index )
this : SetSelectBtn ( )
if _index < 5 then
2020-07-06 20:35:39 +08:00
local allEquip = BagManager.GetEquipDataByEquipPosition ( curHeroData.heroConfig . Profession , _index )
2020-05-09 13:31:21 +08:00
this : SortEquipDatas ( allEquip )
2020-07-09 10:53:15 +08:00
local count = 0
for i = 1 , # allEquip do
count = count + allEquip [ i ] . num
end
this.itemNumText . text = Language [ 10188 ] .. count
2020-05-09 13:31:21 +08:00
this : SetItemData ( allEquip )
else
local allEquipTreasure
2020-07-06 20:35:39 +08:00
allEquipTreasure =
EquipTreasureManager.GetAllTreasuresByLocation ( _index - 4 , curHeroData.heroConfig . PropertyName )
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
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
return a.refineLv > b.refineLv
2020-05-09 13:31:21 +08:00
end
end
2020-07-06 20:35:39 +08:00
)
2020-07-09 10:53:15 +08:00
this.itemNumText . text = Language [ 10188 ] .. LengthOfTable ( allEquipTreasure )
this : SetItemData ( allEquipTreasure )
2020-05-09 13:31:21 +08:00
end
end
2020-07-07 16:35:57 +08:00
2020-05-09 13:31:21 +08:00
--设置背包列表数据
local curHeroCanUpEquipTabs = { }
2020-07-09 10:53:15 +08:00
function this : SetItemData ( _itemDatas )
2020-07-06 20:35:39 +08:00
if LengthOfTable ( _itemDatas ) == 0 then
2020-05-09 13:31:21 +08:00
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
2020-07-06 20:35:39 +08:00
this.ScrollView : SetData (
_itemDatas ,
function ( index , go )
this.SingleItemDataShow ( go , _itemDatas [ index ] )
end
)
2020-12-24 18:57:19 +08:00
if isPlayAnim then
if isFristOpenTime then
isFristOpenTime : Stop ( )
isFristOpenTime = nil
end
isFristOpenTime = Timer.New ( function ( )
this.mask : SetActive ( false )
2020-12-28 16:25:38 +08:00
end , 0.3 ) : Start ( )
2020-12-24 18:57:19 +08:00
this.mask : SetActive ( true )
SecTorPlayAnimByScroll ( this.ScrollView )
isPlayAnim = false
end
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
function this . SingleItemDataShow ( _go , _itemData )
if not itemConfig [ _itemData.id ] then
return
end
2020-12-29 19:13:14 +08:00
-- if isPlayAnim then
-- _go.gameObject:SetActive(false)
-- else
-- _go.gameObject:SetActive(true)
-- end
2020-07-06 20:35:39 +08:00
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 " )
local proIcon = Util.GetGameObject ( _go.transform , " proIcon " )
local jewerConfig = ConfigManager.TryGetConfigData ( ConfigName.JewelConfig , _itemData.id )
local pos = 0
2020-05-09 13:31:21 +08:00
if jewerConfig then
2020-07-09 10:53:15 +08:00
Util.GetGameObject ( _go.transform , " num " ) . gameObject : SetActive ( false )
2020-07-06 20:35:39 +08:00
if jewerConfig.Location == 1 then
pos = 5
else
if jewerConfig.Location == 2 then
pos = 6
end
2020-05-09 13:31:21 +08:00
end
2020-07-09 10:53:15 +08:00
else
Util.GetGameObject ( _go.transform , " num " ) . gameObject : SetActive ( true )
Util.GetGameObject ( _go.transform , " num " ) : GetComponent ( " Text " ) . text = _itemData.num
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
local lvObj = Util.GetGameObject ( _go.transform , " lv " ) : GetComponent ( " Text " )
local refineObj = Util.GetGameObject ( _go.transform , " refine " ) : GetComponent ( " Text " )
2020-05-09 13:31:21 +08:00
if itemConfig [ _itemData.id ] . ItemType == ItemType.EquipTreasure then
2020-07-06 20:35:39 +08:00
icon.sprite = Util.LoadSprite ( _itemData.icon )
frame.sprite = Util.LoadSprite ( _itemData.frame )
2020-06-13 11:47:13 +08:00
proIcon : SetActive ( true )
2020-07-06 20:35:39 +08:00
proIcon : GetComponent ( " Image " ) . sprite =
Util.LoadSprite ( GetProStrImageByProNum ( _itemData.itemConfig . PropertyName ) )
name.text = itemConfig [ _itemData.id ] . Name
2020-05-09 13:31:21 +08:00
star : SetActive ( false )
2020-07-06 20:35:39 +08:00
Util.GetGameObject ( _go.transform , " redPoint " ) : SetActive ( false )
lvObj.text = _itemData.lv
if _itemData.lv > 0 then
2020-05-09 13:31:21 +08:00
lvObj.gameObject : SetActive ( true )
else
lvObj.gameObject : SetActive ( false )
end
2020-07-06 20:35:39 +08:00
refineObj.text = " + " .. _itemData.refineLv
if _itemData.refineLv > 0 then
2020-05-09 13:31:21 +08:00
refineObj.gameObject : SetActive ( true )
else
refineObj.gameObject : SetActive ( false )
end
-- 0.查看属性 1.穿戴 2.卸下 3.交换
2020-07-06 20:35:39 +08:00
--宝物界面
Util.AddOnceClick (
Util.GetGameObject ( _go.transform , " icon " ) ,
function ( )
if curEquipTreasureDatas [ pos ] then
2020-12-17 10:41:00 +08:00
UIManager.OpenPanel (
UIName.RoleEquipTreasureChangePopup ,
this ,
3 ,
curHeroData ,
curEquipTreasureDatas [ pos ] ,
_itemData ,
pos
)
-- end
2020-07-06 20:35:39 +08:00
else
2020-12-17 10:41:00 +08:00
2020-07-06 20:35:39 +08:00
UIManager.OpenPanel ( UIName.RoleEquipTreasureChangePopup , this , 1 , curHeroData , _itemData , nil , pos )
end
end
)
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
frame.sprite = Util.LoadSprite ( _itemData.frame )
icon.sprite = Util.LoadSprite ( _itemData.icon )
2020-05-09 13:31:21 +08:00
lvObj.gameObject : SetActive ( false )
refineObj.gameObject : SetActive ( false )
2020-06-13 11:47:13 +08:00
proIcon : SetActive ( false )
2020-07-06 20:35:39 +08:00
name.text = _itemData.itemConfig . Name
2020-05-09 13:31:21 +08:00
star : SetActive ( true )
2020-07-06 20:35:39 +08:00
EquipManager.SetEquipStarShow ( star , _itemData.itemConfig . Id )
local redPoint = Util.GetGameObject ( _go.transform , " redPoint " )
2020-05-09 13:31:21 +08:00
if curHeroCanUpEquipTabs and # curHeroCanUpEquipTabs > 0 then
local isShow = false
for i = 1 , # curHeroCanUpEquipTabs do
2020-07-06 20:35:39 +08:00
if curHeroCanUpEquipTabs [ i ] == _itemData.id then
2020-05-09 13:31:21 +08:00
isShow = true
end
end
if isShow then
redPoint : SetActive ( true )
else
redPoint : SetActive ( false )
end
else
redPoint : SetActive ( false )
end
2020-07-06 20:35:39 +08:00
Util.GetGameObject ( _go.transform , " num " ) : GetComponent ( " Text " ) . text = _itemData.num
Util.AddOnceClick (
Util.GetGameObject ( _go.transform , " icon " ) ,
function ( )
2020-12-17 10:41:00 +08:00
print ( " 点击交换icon " )
2020-07-06 20:35:39 +08:00
if curHeroEquipDatas [ equipConfig [ _itemData.id ] . Position ] then
local nextEquipData = EquipManager.GetSingleEquipData ( _itemData.id )
2020-12-17 10:41:00 +08:00
print ( " equipIdList长度是 " .. # curHeroData.equipIdList )
if curHeroData.harmonyGongMing then
-- body
this : OpenTips ( nextEquipData , equipConfig [ _itemData.id ] . Position )
else
UIManager.OpenPanel (
UIName.RoleEquipChangePopup ,
this ,
3 ,
curHeroData ,
curHeroEquipDatas [ equipConfig [ _itemData.id ] . Position ] ,
nextEquipData ,
equipConfig [ _itemData.id ] . Position
)
end
2020-07-06 20:35:39 +08:00
else
2020-12-17 10:41:00 +08:00
print ( " 点击交换else语句 " )
2020-07-06 20:35:39 +08:00
UIManager.OpenPanel (
UIName.RoleEquipChangePopup ,
this ,
1 ,
curHeroData ,
_itemData ,
equipConfig [ _itemData.id ] . Position
)
end
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
)
2020-05-09 13:31:21 +08:00
end
end
--刷新当前英雄装备坑位的信息
2020-07-06 20:35:39 +08:00
function this . UpdateEquipPosHeroData ( _equipOrTreasure , _type , _selectEquipDataList , _oldSelectEquip , position ) --type
2020-05-09 13:31:21 +08:00
--1 穿单件装备 2 卸单件装备 3 替换单件装备 4 一键穿装备 5一键脱装备
2020-07-06 20:35:39 +08:00
if _type == 1 then
2020-05-09 13:31:21 +08:00
effectList [ position ] : SetActive ( false )
effectList [ position ] : SetActive ( true )
if _equipOrTreasure == 1 then
2020-07-06 20:35:39 +08:00
curSelectEquipData = _selectEquipDataList [ 1 ]
2020-05-09 13:31:21 +08:00
--装备绑英雄
2020-07-06 20:35:39 +08:00
EquipManager.SetEquipUpHeroDid ( curSelectEquipData.id , curHeroData.dynamicId )
2020-05-09 13:31:21 +08:00
--英雄加装备
2020-07-06 20:35:39 +08:00
table.insert ( curHeroData.equipIdList , curSelectEquipData.id )
HeroManager.SetHeroEquipIdList ( curHeroData.dynamicId , curHeroData.equipIdList )
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
curEquipTreasureDatas = _selectEquipDataList [ 1 ]
2020-05-09 13:31:21 +08:00
--装备绑英雄
2020-07-06 20:35:39 +08:00
EquipTreasureManager.SetEquipTreasureUpHeroDid ( curEquipTreasureDatas.idDyn , curHeroData.dynamicId )
2020-05-09 13:31:21 +08:00
--英雄加装备
2020-07-06 20:35:39 +08:00
table.insert ( curHeroData.jewels , curEquipTreasureDatas.idDyn )
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
elseif _type == 2 then
2020-05-09 13:31:21 +08:00
if _equipOrTreasure == 1 then
2020-12-17 10:41:00 +08:00
if not curHeroData.harmonyGongMing then
--装备解绑英雄
curSelectEquipData = _selectEquipDataList [ 1 ]
EquipManager.DeleteSingleEquip ( curSelectEquipData.id , curHeroData.dynamicId )
for i = 1 , # curHeroData.equipIdList do
if tonumber ( curHeroData.equipIdList [ i ] ) == tonumber ( curSelectEquipData.id ) then
--英雄删除装备
table.remove ( curHeroData.equipIdList , i )
break
end
end
local a = curHeroData.equipIdList
if not curHeroData.harmonyGongMing then
HeroManager.SetHeroEquipIdList ( curHeroData.dynamicId , curHeroData.equipIdList )
else
HeroManager.SetHeroEquipIdList ( curHeroData.dynamicId , { } )
2020-05-09 13:31:21 +08:00
end
end
else
curEquipTreasureDatas = _selectEquipDataList [ 1 ]
2020-07-06 20:35:39 +08:00
EquipTreasureManager.SetEquipTreasureUpHeroDid ( curEquipTreasureDatas.idDyn , " " )
2020-05-09 13:31:21 +08:00
for i = 1 , # curHeroData.jewels do
2020-07-06 20:35:39 +08:00
if curHeroData.jewels [ i ] == curEquipTreasureDatas.idDyn then
2020-05-09 13:31:21 +08:00
--英雄删除装备
2020-07-06 20:35:39 +08:00
table.remove ( curHeroData.jewels , i )
2020-05-09 13:31:21 +08:00
break
end
end
end
2020-07-06 20:35:39 +08:00
elseif _type == 3 then
2020-05-09 13:31:21 +08:00
effectList [ position ] : SetActive ( false )
effectList [ position ] : SetActive ( true )
if _equipOrTreasure == 1 then
2020-12-17 10:41:00 +08:00
local a = curHeroData.equipIdList
if not curHeroData.harmonyGongMing then
curSelectEquipData = _selectEquipDataList [ 1 ]
EquipManager.SetEquipUpHeroDid ( curSelectEquipData.id , curHeroData.dynamicId )
--穿
if _oldSelectEquip and tonumber ( _oldSelectEquip.id ) ~= tonumber ( curSelectEquipData.id ) then
EquipManager.DeleteSingleEquip ( _oldSelectEquip.id , curHeroData.dynamicId )
end
2020-07-06 20:35:39 +08:00
2020-12-17 10:41:00 +08:00
--英雄替换新选择装备
if curHeroEquipDatas [ curSelectEquipData.equipConfig . Position ] then
for i = 1 , # curHeroData.equipIdList do
if
tonumber ( curHeroData.equipIdList [ i ] ) ==
tonumber ( curHeroEquipDatas [ curSelectEquipData.equipConfig . Position ] . id )
then
curHeroData.equipIdList [ i ] = curSelectEquipData.id
break
end
2020-05-09 13:31:21 +08:00
end
end
2020-12-17 10:41:00 +08:00
HeroManager.SetHeroEquipIdList ( curHeroData.dynamicId , curHeroData.equipIdList )
else
curSelectEquipData = _selectEquipDataList [ 1 ]
HeroManager.SetHeroEquipIdList ( curHeroData.dynamicId , { curSelectEquipData.id } )
EquipManager.SetEquipUpHeroDid ( curSelectEquipData.id , curHeroData.dynamicId )
-- curHeroData.equipIdList[1] = curSelectEquipData.id
-- HeroManager.SetHeroEquipIdList(curHeroData.dynamicId, curHeroData.equipIdList)
2020-05-09 13:31:21 +08:00
end
else
2020-07-06 20:35:39 +08:00
curEquipTreasureDatas = _selectEquipDataList [ 1 ]
2020-05-09 13:31:21 +08:00
--新装备绑英雄
2020-07-06 20:35:39 +08:00
EquipTreasureManager.SetEquipTreasureUpHeroDid ( curEquipTreasureDatas.idDyn , curHeroData.dynamicId )
2020-05-09 13:31:21 +08:00
if _oldSelectEquip then
--被替换装备解绑英雄
2020-07-06 20:35:39 +08:00
EquipTreasureManager.SetEquipTreasureUpHeroDid ( _oldSelectEquip.idDyn , " " )
2020-05-09 13:31:21 +08:00
end
--英雄替换新选择装备
2020-07-06 20:35:39 +08:00
for i = 1 , # curHeroData.jewels do
if curHeroData.jewels [ i ] == _oldSelectEquip.idDyn then
curHeroData.jewels [ i ] = curEquipTreasureDatas.idDyn
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
end
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
elseif _type == 4 then
2020-05-09 13:31:21 +08:00
--一键穿 把身上装备解绑英雄id
2020-07-06 20:35:39 +08:00
if _equipOrTreasure == 1 then
2020-12-17 10:41:00 +08:00
if not curHeroData.harmonyGongMing then
local isadd
for n , m in ipairs ( _selectEquipDataList ) do
isadd = true
for i = 1 , # curHeroData.equipIdList do
if equipConfig [ tonumber ( curHeroData.equipIdList [ i ] ) ] . Position == equipConfig [ tonumber ( m ) ] . Position then
EquipManager.DeleteSingleEquip ( curHeroData.equipIdList [ i ] , curHeroData.dynamicId )
curHeroData.equipIdList [ i ] = m
HeroManager.GetHeroEquipIdList1 ( curHeroData.dynamicId , m )
isadd = false
break
end
end
if isadd then
table.insert ( curHeroData.equipIdList , m )
2020-07-06 20:35:39 +08:00
end
end
2020-12-17 10:41:00 +08:00
EquipManager.UpdateEquipData ( _selectEquipDataList , curHeroData.dynamicId )
else
local curEquilist = { }
for n , m in ipairs ( _selectEquipDataList ) do
table.insert ( curEquilist , m )
2020-07-06 20:35:39 +08:00
end
2020-12-17 10:41:00 +08:00
curHeroData.equipIdList = curEquilist
HeroManager.SetHeroEquipIdList ( curHeroData.dynamicId , curHeroData.equipIdList )
EquipManager.UpdateEquipData ( _selectEquipDataList , curHeroData.dynamicId )
2020-07-06 20:35:39 +08:00
end
2020-05-09 13:31:21 +08:00
else
2020-08-26 10:16:16 +08:00
local isadd
2020-05-09 13:31:21 +08:00
for i = 1 , # _selectEquipDataList do
2020-08-26 10:16:16 +08:00
isadd = true
for j = 1 , # curHeroData.jewels do
2020-08-25 18:17:15 +08:00
--如果英雄身上有和选中的宝物的位置相同的,就替换
2020-08-26 10:16:16 +08:00
if EquipTreasureManager.GetSingleTreasureByIdDyn ( curHeroData.jewels [ j ] ) . equipType ==
2020-08-25 18:17:15 +08:00
EquipTreasureManager.GetSingleTreasureByIdDyn ( _selectEquipDataList [ i ] ) . equipType then
2020-08-26 10:16:16 +08:00
EquipTreasureManager.SetTreasureUpOrDown ( curHeroData.jewels [ j ] , " 0 " )
2020-08-25 18:17:15 +08:00
EquipTreasureManager.SetTreasureUpOrDown ( _selectEquipDataList [ i ] , curHeroData.dynamicId )
2020-08-26 10:18:46 +08:00
curHeroData.jewels [ j ] = _selectEquipDataList [ i ]
2020-08-25 18:17:15 +08:00
isadd = false
break
end
end
2020-08-26 10:16:16 +08:00
-- LogGreen("_selectEquipDataList[i]:".._selectEquipDataList[i])
-- LogGreen("isadd:"..tostring(isadd))
2020-08-25 18:17:15 +08:00
if isadd then
EquipTreasureManager.SetTreasureUpOrDown ( _selectEquipDataList [ i ] , curHeroData.dynamicId )
table.insert ( curHeroData.jewels , _selectEquipDataList [ i ] )
2020-08-26 10:16:16 +08:00
end
2020-05-09 13:31:21 +08:00
end
2020-08-26 10:16:16 +08:00
-- for i = 1, #curHeroData.jewels do
-- LogYellow("curHeroData.jewels:"..i.. " id:"..curHeroData.jewels[i])
-- end
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
elseif _type == 5 then
2020-05-09 13:31:21 +08:00
--一键脱 把身上装备英雄id置为“0” 再把英雄装备list清空
2020-07-06 20:35:39 +08:00
if _equipOrTreasure == 1 then
2020-05-09 13:31:21 +08:00
if _selectEquipDataList then
for i = 1 , # _selectEquipDataList do
2020-07-06 20:35:39 +08:00
EquipManager.DeleteSingleEquip ( _selectEquipDataList [ i ] , curHeroData.dynamicId )
2020-05-09 13:31:21 +08:00
end
end
2020-07-06 20:35:39 +08:00
curHeroData.equipIdList = { }
HeroManager.SetHeroEquipIdList ( curHeroData.dynamicId , { } )
curHeroData.equipIdList = { }
2020-05-09 13:31:21 +08:00
else
if _selectEquipDataList then
for i = 1 , # _selectEquipDataList do
2020-07-06 20:35:39 +08:00
EquipTreasureManager.SetTreasureUpOrDown ( _selectEquipDataList [ i ] , " " )
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
curHeroData.jewels = { }
2020-05-09 13:31:21 +08:00
end
end
end
--刷新界面
this.ShowHeroEquip ( )
--上阵刷新红点
2020-07-07 16:35:57 +08:00
this.allEquipUpRedPoint : SetActive ( # HeroManager.GetHeroIsUpEquip ( curHeroData.dynamicId ) > 0 and isUpZhen )
2020-05-09 13:31:21 +08:00
--刷新当前英雄可穿装备
if indexBtnNum == PosIdConst.All then
this : OnClickAllBtn ( )
else
this : OnClickTabBtn ( indexBtnNum )
end
--对比战力并更新战力值 播放战力变更动画
HeroManager.CompareWarPower ( curHeroData.dynamicId )
end
2020-07-06 20:35:39 +08:00
2020-05-09 13:31:21 +08:00
--选择图片设置父级
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 ( )
2020-12-24 18:57:19 +08:00
if isFristOpenTime then
isFristOpenTime : Stop ( )
isFristOpenTime = nil
end
2020-05-09 13:31:21 +08:00
end
function this : AddRedPointVale ( _equipDatas )
for j = 1 , # _equipDatas do
_equipDatas [ j ] . isRedPointShow = 1
for i = 1 , # curHeroCanUpEquipTabs do
2020-07-06 20:35:39 +08:00
if curHeroCanUpEquipTabs [ i ] == _equipDatas [ j ] . id then
2020-05-09 13:31:21 +08:00
_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 )
2020-07-06 20:35:39 +08:00
table.sort (
_equipDatas ,
function ( a , b )
if a.isRedPointShow == b.isRedPointShow then
if a.itemConfig . Quantity == b.itemConfig . Quantity then
if equipConfig [ a.id ] . Position == equipConfig [ b.id ] . Position then
return a.id > b.id
else
return equipConfig [ a.id ] . Position < equipConfig [ b.id ] . Position
end
2020-05-09 13:31:21 +08:00
else
2020-07-06 20:35:39 +08:00
return a.itemConfig . Quantity > b.itemConfig . Quantity
2020-05-09 13:31:21 +08:00
end
else
2020-07-06 20:35:39 +08:00
return a.isRedPointShow > b.isRedPointShow
2020-05-09 13:31:21 +08:00
end
end
2020-07-06 20:35:39 +08:00
)
2020-05-09 13:31:21 +08:00
end
2020-07-06 20:35:39 +08:00
-- --做装备叠加特殊组拼数据
-- 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
2020-05-09 13:31:21 +08:00
--界面销毁时调用(用于子类重写)
function RoleEquipPanel : OnDestroy ( )
SubUIManager.Close ( this.UpView )
this.ScrollView = nil
end
2020-07-10 19:13:29 +08:00
return RoleEquipPanel