709 lines
29 KiB
Lua
709 lines
29 KiB
Lua
require("Base/BasePanel")
|
||
RoleGiftPanel = Inherit(BasePanel)
|
||
local spcialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
|
||
local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig)
|
||
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
RoleGiftPanel = Inherit(BasePanel)
|
||
local isGonming = 0
|
||
local tableName = { "礼物", "碎片" }
|
||
local isUpZhen = false
|
||
local this = RoleGiftPanel
|
||
local indexBtnNum = 0
|
||
local tabs = {}
|
||
local redTabs = {}
|
||
local curHeroData = nil
|
||
local teamHero
|
||
local v1
|
||
local allUpIds = {}
|
||
local upSuitId = {}
|
||
local allEquip = {}
|
||
local index = 0
|
||
local lv, curNum, maxNum
|
||
local heroListData
|
||
local isDown = false
|
||
local _MainProList = {}
|
||
local giftDatas
|
||
--初始化组件(用于子类重写)RoleEquipChangePopup
|
||
function RoleGiftPanel:InitComponent()
|
||
--this.spLoader = SpriteLoader.New()
|
||
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")
|
||
|
||
for i = 1, 2 do
|
||
tabs[i] = Util.GetGameObject(self.transform, "Tabs/Btn" .. i)
|
||
local nameTxt = Util.GetGameObject(tabs[i], "Text"):GetComponent("Text")
|
||
nameTxt.fontSize = GetCurLanguage() == 0 and 48 or 40
|
||
nameTxt.text = tableName[i]
|
||
redTabs[i] = Util.GetGameObject(tabs[i], "red")
|
||
if i == 2 then
|
||
tabs[i]:SetActive(false)
|
||
end
|
||
--effectList[i] = Util.GetGameObject(self.transform, "bg/equipInfo/equip" .. i .. "/effect")
|
||
end
|
||
this.mainPro = Util.GetGameObject(self.transform, "mainPro")
|
||
this.mainProGrid = Util.GetGameObject(self.transform, "mainPro/bg")
|
||
this.mainProItem = Util.GetGameObject(self.transform, "mainPro/bg/proPre")
|
||
this.mainProItem:SetActive(false)
|
||
this.titleTxt = Util.GetGameObject(self.gameObject, "title"):GetComponent("Text")
|
||
this.titleTxt.text = "英雄礼物"
|
||
this.selectBtn = Util.GetGameObject(self.gameObject, "selectBtn")
|
||
this.btnPrant = Util.GetGameObject(self.gameObject, "Tabs")
|
||
this.equipPreList2 = {}
|
||
this.equipPreList = {}
|
||
--this.equipPre = Util.GetGameObject(self.gameObject, "equipPre")
|
||
this.upItemPre = Util.GetGameObject(self.gameObject, "upItemPre")
|
||
this.grid = Util.GetGameObject(self.gameObject, "scroll/grid")
|
||
this.selsectSkillImage = Util.GetGameObject(self.gameObject, "selsectSkillImage")
|
||
|
||
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.allEquipUpRedPoint:SetActive(false)
|
||
--[[
|
||
this.ScrollBar = Util.GetGameObject(self.gameObject, "listObj/bg/Scrollbar"):GetComponent("Scrollbar")
|
||
local v2 = Util.GetGameObject(self.gameObject, "listObj/bg/scroll"):GetComponent("RectTransform").rect
|
||
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,
|
||
Util.GetGameObject(self.transform, "listObj/bg/scroll").transform,
|
||
this.equipPre, this.ScrollBar, Vector2.New(v2.width, v2.height), 1, 4, Vector2.New(40, 25))
|
||
this.ScrollView.moveTween.MomentumAmount = 1
|
||
this.ScrollView.moveTween.Strength = 1
|
||
]]
|
||
|
||
|
||
this.scorllRoot = Util.GetGameObject(self.gameObject, "listObj/bg/scroll")
|
||
this.equipPre = Util.GetGameObject(self.gameObject, "listObj/bg/equipPre")
|
||
this.equipPre:SetActive(false)
|
||
v1 = Util.GetGameObject(self.gameObject, "upScroll"):GetComponent("RectTransform").rect
|
||
this.UpScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,
|
||
Util.GetGameObject(self.transform, "upScroll").transform, this.upItemPre, nil, Vector2.New(v1.width, v1.height),
|
||
1, 4, Vector2.New(50, 65))
|
||
this.UpScrollView.moveTween.MomentumAmount = 1
|
||
this.UpScrollView.moveTween.Strength = 1
|
||
Util.GetGameObject(self.transform, "powerBtn"):GetComponent("Image").sprite = Util.LoadSprite(
|
||
"UI_hz_shenjiang_15_zh")
|
||
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.emptyObj = Util.GetGameObject(self.transform, "listObj/bg/emptyObj")
|
||
this.emptyObj.gameObject:SetActive(false)
|
||
this.mask = Util.GetGameObject(self.gameObject, "mask")
|
||
this.mask:SetActive(false)
|
||
this.collectImg = Util.GetGameObject(self.gameObject, "collectImg"):GetComponent("Image")
|
||
--this.lvTxt = Util.GetGameObject(self.gameObject, "lvTxt"):GetComponent("Text")
|
||
--this.collectImg.sprite=Util.LoadSprite("gh_tt_8")
|
||
this.gainChipBtn = Util.GetGameObject(self.gameObject, "gainBtn")
|
||
this.btn_help = Util.GetGameObject(self.gameObject, "btn_help")
|
||
this.listObj = Util.GetGameObject(self.transform, "listObj")
|
||
this.listCloseBtn = Util.GetGameObject(self.transform, "listObj/bg/btn_close")
|
||
Util.GetGameObject(self.transform, "listObj/bg/title (1)"):GetComponent("Text").text = "英雄礼物"
|
||
this.proTitle = Util.GetGameObject(self.transform, "proTitle/name/text"):GetComponent("Text")
|
||
this.proTitle.text = "当前礼物加成"
|
||
this.proGrid = Util.GetGameObject(self.transform, "pro")
|
||
this.proPre = Util.GetGameObject(self.transform, "propre")
|
||
--this.tipInfo = Util.GetGameObject(self.transform, "tipInfo"):GetComponent("Text")
|
||
|
||
this.proEmptyObj = Util.GetGameObject(self.transform, "proEmptyObj")
|
||
Util.GetGameObject(self.transform, "proEmptyObj/Text"):GetComponent("Text").text = "暂无加成属性"
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function RoleGiftPanel:BindEvent()
|
||
Util.AddClick(this.listCloseBtn, function()
|
||
this.listObj:SetActive(false)
|
||
end)
|
||
Util.AddClick(this.btn_help, function()
|
||
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Gift, -150, 0)
|
||
end)
|
||
--礼物获取
|
||
Util.AddClick(this.gainChipBtn, function()
|
||
--UIManager.OpenPanel(UIName.ReconnaissancePanel)
|
||
UIManager.OpenPanel(UIName.DailyCarbonPanel, 6)
|
||
end)
|
||
Util.AddClick(this.collectImg.gameObject, function()
|
||
-- local data = {}
|
||
-- local singData = {}
|
||
-- singData.title = "当前礼物总加成"
|
||
-- singData.pro = IncarnationManager.GetproDesLst(GiftManager.GetHeroGiftAddPro(curHeroData.dynamicId),"00FF00")
|
||
-- singData.tip ="" --"总加成包括化身之力提供的属性"
|
||
-- table.insert(data,singData)
|
||
-- UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.IncarnationDes,data)
|
||
end)
|
||
Util.AddClick(this.btnBack, function()
|
||
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.leftBtn, function()
|
||
index = (index - 1 > 0 and index - 1 or #heroListData)
|
||
curHeroData = heroListData[index]
|
||
this.RefreshWindowData()
|
||
end)
|
||
|
||
Util.AddClick(this.rightBtn, function()
|
||
index = (index + 1 <= #heroListData and index + 1 or 1)
|
||
curHeroData = heroListData[index]
|
||
this.RefreshWindowData()
|
||
end)
|
||
Util.AddOnceClick(this.allEquipUp, function()
|
||
local canNum = curNum - #allUpIds
|
||
if canNum > 0 then
|
||
local list = {}
|
||
table.sort(allEquip, function(a, b)
|
||
if equipConfig[a.id].Quality ~= equipConfig[b.id].Quality then
|
||
return equipConfig[a.id].Quality > equipConfig[b.id].Quality
|
||
else
|
||
return equipConfig[a.id].Star > equipConfig[b.id].Star
|
||
end
|
||
end)
|
||
for i = 1, #allEquip do
|
||
if #list < canNum then
|
||
if CheckListIsContainValue1(allUpIds, allEquip[i].id) == false and CheckListIsContainValue1(upSuitId, equipConfig[allEquip[i].id].SuiteID) == false then
|
||
table.insert(list, allEquip[i].id)
|
||
table.insert(upSuitId, equipConfig[allEquip[i].id].SuiteID)
|
||
end
|
||
end
|
||
end
|
||
--LogError("ssssssssssssssssssssssssss".."/"..tostring(canNum).."/"..tostring(#allEquip))
|
||
NetManager.GiftEquipWearRequest(1, curHeroData.dynamicId, list, function()
|
||
GiftManager.SetHeroGift(curHeroData.dynamicId, list, 1)
|
||
this.RefreshWindowData()
|
||
end)
|
||
end
|
||
end)
|
||
|
||
Util.AddOnceClick(this.allEquipDown, function()
|
||
isDown = true
|
||
NetManager.GiftEquipWearRequest(2, curHeroData.dynamicId, allUpIds, function()
|
||
isDown = false
|
||
GiftManager.SetHeroGift(curHeroData.dynamicId, allUpIds, 2)
|
||
this.RefreshWindowData()
|
||
end)
|
||
end)
|
||
|
||
for i = 1, 2 do
|
||
Util.AddClick(tabs[i], function()
|
||
-- isPlayAnim = true
|
||
if i == indexBtnNum then
|
||
return
|
||
end
|
||
indexBtnNum = i
|
||
this:OnClickTabBtn(indexBtnNum)
|
||
end)
|
||
end
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function RoleGiftPanel:AddListener()
|
||
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.RefreshWindowData)
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function RoleGiftPanel:RemoveListener()
|
||
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.RefreshWindowData)
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function RoleGiftPanel:OnOpen(...)
|
||
local data = { ... }
|
||
curHeroData = data[1]
|
||
if data[2] then
|
||
heroListData = data[2]
|
||
else
|
||
heroListData = HeroManager.GetAllHeroDatas()
|
||
end
|
||
this.listObj:SetActive(false)
|
||
|
||
local scrollWidth = this.scorllRoot.transform.rect.width
|
||
local scrollHight = this.scorllRoot.transform.rect.height
|
||
|
||
Util.ClearChild(this.scorllRoot.transform)
|
||
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scorllRoot.transform,
|
||
this.equipPre, nil, Vector2.New(scrollWidth, scrollHight), 1, 1, Vector2.New(50, 15))
|
||
this.ScrollView.moveTween.MomentumAmount = 1
|
||
this.ScrollView.moveTween.Strength = 1
|
||
end
|
||
|
||
function RoleGiftPanel:OnShow()
|
||
for i = 1, #heroListData do
|
||
if curHeroData == heroListData[i] then
|
||
index = i
|
||
end
|
||
end
|
||
teamHero = FormationManager.GetAllFormationHeroId()
|
||
this.RefreshWindowData()
|
||
end
|
||
|
||
function this:OnSortingOrderChange()
|
||
|
||
end
|
||
|
||
function this.RefreshWindowData()
|
||
local WarPower = 0
|
||
if isDown then
|
||
return
|
||
end
|
||
isUpZhen = teamHero[curHeroData.dynamicId]
|
||
--[[
|
||
if isUpZhen then
|
||
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId, FormationTypeDef.FORMATION_NORMAL)
|
||
else
|
||
WarPower = HeroPowerManager.GetHeroPower(curHeroData.dynamicId)
|
||
end
|
||
this.force.text = WarPower
|
||
|
||
]]
|
||
this.force.text = ""
|
||
--显示上面赠送的
|
||
local list = GiftManager.GetHeroGifts(curHeroData.dynamicId)
|
||
curNum = GiftManager.GetHeroGiftBoxNum(curHeroData.dynamicId)
|
||
--if #list>=50 then
|
||
--curNum=#list+6
|
||
--maxNum=#list+6
|
||
--else
|
||
maxNum = curNum + 1
|
||
if maxNum > 12 then
|
||
maxNum = 12
|
||
end
|
||
--maxNum = 12
|
||
--end
|
||
--this.lvTxt.text = "收集度" .. lv .. "级"
|
||
--LogError("lv========="..lv.." curnum=="..curNum.." maxNum=="..maxNum)
|
||
--maxNum=0
|
||
giftDatas = {}
|
||
allUpIds = {}
|
||
upSuitId = {}
|
||
for i = 1, maxNum do
|
||
local data = {}
|
||
data.type = 1
|
||
data.qua = 0
|
||
data.id = 0
|
||
data.isRed = false
|
||
if i <= #list then
|
||
data.type = 2
|
||
data.id = list[i]
|
||
data.qua = itemConfig[list[i]].Quantity
|
||
table.insert(allUpIds, data.id)
|
||
table.insert(upSuitId, equipConfig[data.id].SuiteID)
|
||
else
|
||
data.isRed = GiftManager.CheckRoleRedPointById(curHeroData.dynamicId)
|
||
end
|
||
table.insert(giftDatas, data)
|
||
end
|
||
table.sort(giftDatas, function(a, b)
|
||
if a.type == b.type then
|
||
if a.qua and a.qua == b.qua then
|
||
return a.id < b.id
|
||
else
|
||
return a.qua > b.qua
|
||
end
|
||
else
|
||
return a.type > b.type
|
||
end
|
||
end)
|
||
--LogError("当前礼物数量:"..#list)
|
||
this.UpScrollView:SetData(giftDatas,
|
||
function(index, go)
|
||
this.SingleUpItemShow(go, giftDatas[index], index)
|
||
end
|
||
)
|
||
|
||
local proList = GiftManager.GetHeroGiftAddPro(curHeroData.dynamicId)
|
||
table.insert(proList, string.format("英雄潜能等级+%s", GiftManager.GetHeroGiftAddPotencyLv(curHeroData.dynamicId)))
|
||
local originalList = GiftManager.GetHeroGiftAddOriginalPro(curHeroData.dynamicId)
|
||
LogError("属性:" .. tostring(#proList))
|
||
if proList and #proList > 0 then
|
||
this.proGrid:SetActive(true)
|
||
this.proEmptyObj:SetActive(false)
|
||
local len = this.proGrid.transform.childCount
|
||
local create = #proList - len
|
||
if create > 0 then
|
||
for i = 1, create do
|
||
newObjToParent(this.proPre, this.proGrid)
|
||
end
|
||
end
|
||
len = this.proGrid.transform.childCount
|
||
for i = 1, len do
|
||
if i <= #proList then
|
||
this.proGrid.transform:GetChild(i - 1).gameObject:SetActive(true)
|
||
--LogError("originalList[i]======================"..originalList[i])
|
||
--this.proGrid.transform:GetChild(i-1):GetComponent("Text").text=proList[i]
|
||
this.SingleProShowData({ proId = i, proVal = proList[i] },
|
||
this.proGrid.transform:GetChild(i - 1).gameObject)
|
||
else
|
||
this.proGrid.transform:GetChild(i - 1).gameObject:SetActive(false)
|
||
end
|
||
end
|
||
else
|
||
this.proGrid:SetActive(false)
|
||
this.proEmptyObj:SetActive(true)
|
||
end
|
||
for _, item in ipairs(_MainProList) do
|
||
item:SetActive(false)
|
||
end
|
||
local props = {}
|
||
|
||
|
||
for _, data in ipairs(giftDatas) do
|
||
local equipConfigData = ConfigManager.GetConfigData(ConfigName.EquipConfig, tonumber(data.id))
|
||
--LogError("礼物id:" .. data.id)
|
||
if equipConfigData and equipConfigData.Property then
|
||
for index, prop in ipairs(equipConfigData.Property) do
|
||
local find = false
|
||
for i = 1, #props do
|
||
if props[i].id == prop[1] then
|
||
props[i].value = props[i].value + prop[2]
|
||
find = true
|
||
break
|
||
end
|
||
end
|
||
if find == false then
|
||
table.insert(props, { id = prop[1], value = prop[2] })
|
||
end
|
||
end
|
||
end
|
||
if #props > 0 then
|
||
this.mainPro:SetActive(true)
|
||
for i = 1, #props do
|
||
local proConfigData = ConfigManager.GetConfigData(ConfigName.PropertyConfig, props[i].id)
|
||
if proConfigData then
|
||
if not _MainProList[i] then
|
||
_MainProList[i] = newObjToParent(this.mainProItem, this.mainProGrid)
|
||
end
|
||
_MainProList[i]:SetActive(true)
|
||
Util.GetGameObject(_MainProList[i], "curProName"):GetComponent("Text").text = GetLanguageStrById(
|
||
proConfigData.Info)
|
||
local vText = Util.GetGameObject(_MainProList[i], "curProVale"):GetComponent("Text")
|
||
Util.GetGameObject(_MainProList[i], "curProIcon"):GetComponent("Image").sprite = Util.LoadSprite(
|
||
proConfigData.Icon)
|
||
-- if prop[2] > 0 then
|
||
-- vText.text = "+"..GetPropertyFormatStr(proConfigData.Style, prop[2])
|
||
-- else
|
||
vText.text = "+" .. GetPropertyFormatStr(proConfigData.Style, props[i].value)
|
||
-- end
|
||
end
|
||
end
|
||
else
|
||
this.mainPro:SetActive(false)
|
||
end
|
||
--LogError("属性数量:" .. tostring(#props))
|
||
end
|
||
|
||
--this.tipInfo.text=string.format("神将潜能等级+%s",GiftManager.GetHeroGiftAddPotencyLv(curHeroData.dynamicId))
|
||
--显示下面可赠送的
|
||
this:OnClickTabBtn(1)
|
||
end
|
||
|
||
function this.SingleProShowData(data, go)
|
||
go:SetActive(true)
|
||
for i = 1, 2 do
|
||
local curGo = go.transform:GetChild(i - 1).gameObject
|
||
if #data > 1 then
|
||
curGo:SetActive(true)
|
||
Util.GetGameObject(curGo, "proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig
|
||
[data[i].proId].Info) .. ":"
|
||
local proVale = Util.GetGameObject(curGo, "proVale"):GetComponent("Text")
|
||
if propertyConfig[data[i].proId].Style == 1 then --绝对值
|
||
proVale.text = GetPropertyFormatStr(propertyConfig[data[i].proId].Style, data[i].proVal)
|
||
elseif propertyConfig[data[i].proId].Style == 2 then --百分百
|
||
-- 暴击默认 10% 前端加显示
|
||
-- LogError("str:"..data[i].proId.." ".. GetLanguageStrById(propertyConfig[data[i].proId].Info))
|
||
if data[i].proId == 55 then
|
||
proVale.text = GetPropertyFormatStr(propertyConfig[data[i].proId].Style, data[i].proVal * 100 + 1000)
|
||
else
|
||
proVale.text = GetPropertyFormatStr(propertyConfig[data[i].proId].Style, data[i].proVal * 100)
|
||
end
|
||
end
|
||
Util.GetGameObject(curGo, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(propertyConfig
|
||
[data[i].proId].Icon)
|
||
else
|
||
curGo:SetActive(false)
|
||
end
|
||
end
|
||
end
|
||
|
||
--显示上面几个
|
||
function this.SingleUpItemShow(_go, data, _index)
|
||
_go:SetActive(true)
|
||
_go.transform:SetAsFirstSibling()
|
||
--local frame=_go:GetComponent("Image")
|
||
local frame = Util.GetGameObject(_go, "Image"):GetComponent("Image")
|
||
local icon = Util.GetGameObject(_go, "icon"):GetComponent("Image")
|
||
local name = Util.GetGameObject(_go, "name"):GetComponent("Text")
|
||
local lockObj = Util.GetGameObject(_go, "lock")
|
||
local lockText = Util.GetGameObject(_go, "Text"):GetComponent("Text")
|
||
local add = Util.GetGameObject(_go, "add")
|
||
local red = Util.GetGameObject(_go, "red")
|
||
local starGrid = Util.GetGameObject(_go, "starGrid")
|
||
if data.id and data.id ~= 0 then
|
||
red:SetActive(false)
|
||
frame.sprite = Util.LoadSprite(GetQuantityImageByquality(itemConfig[data.id].Quantity))
|
||
icon.gameObject:SetActive(true)
|
||
name.gameObject:SetActive(false)
|
||
lockObj:SetActive(false)
|
||
starGrid:SetActive(true)
|
||
lockText.gameObject:SetActive(false)
|
||
add:SetActive(false)
|
||
name.text = GetLanguageStrById(itemConfig[data.id].Name)
|
||
icon.sprite = Util.LoadSprite(GetResourcePath(itemConfig[data.id].ResourceID))
|
||
SetHeroStars(starGrid, equipConfig[data.id].Star, 1, nil, -15)
|
||
Util.AddOnceClick(icon.gameObject, function()
|
||
if curHeroData == nil then
|
||
return
|
||
end
|
||
BagManager.isBagPanel = false
|
||
--UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2,this,data,2,false,nil,curHeroData,4)
|
||
UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2, this, data, curHeroData, nil, false, false, true)
|
||
end
|
||
)
|
||
else
|
||
frame.sprite = Util.LoadSprite("X1_tongyong_daojukuang_07")
|
||
--frame.gameObject:SetActive(false)
|
||
icon.gameObject:SetActive(false)
|
||
name.gameObject:SetActive(false)
|
||
starGrid:SetActive(false)
|
||
if _index > curNum then
|
||
lockObj:SetActive(true)
|
||
add:SetActive(false)
|
||
red:SetActive(false)
|
||
lockText.gameObject:SetActive(true)
|
||
lockText.text = GetLanguageStrById(16010122)
|
||
else
|
||
lockObj:SetActive(false)
|
||
lockText.gameObject:SetActive(false)
|
||
add:SetActive(true)
|
||
red:SetActive(data.isRed)
|
||
end
|
||
end
|
||
Util.AddOnceClick(add, function()
|
||
this.listObj:SetActive(true)
|
||
end)
|
||
end
|
||
|
||
--点击装备按钮
|
||
function this:OnClickTabBtn(_index)
|
||
indexBtnNum = _index
|
||
this:SetSelectBtn()
|
||
allEquip = BagManager.GetBagItemDataByItemType(ItemBaseType.HeroGift)
|
||
-- this:SortEquipDatas(allEquip)
|
||
local count = 0
|
||
for i = 1, #allEquip do
|
||
count = count + 1
|
||
if CheckListIsContainValue1(allUpIds, allEquip[i].id) or CheckListIsContainValue1(upSuitId, equipConfig[allEquip[i].id].SuiteID) then
|
||
allEquip[i].isUp = 1
|
||
--LogError("rrrrrrrrrrrrrrrr:"..tostring(allEquip[i].id).."/"..tostring(equipConfig[allEquip[i].id].SuiteID))
|
||
else
|
||
allEquip[i].isUp = 2
|
||
--LogError("bbbbbbbbbbbbbbbb:"..tostring(allEquip[i].id).."/"..tostring(equipConfig[allEquip[i].id].SuiteID))
|
||
end
|
||
end
|
||
table.sort(allEquip, function(a, b)
|
||
if a.isUp == b.isUp then
|
||
if a.quality == b.quality then
|
||
return a.id < b.id
|
||
else
|
||
return a.quality > b.quality
|
||
end
|
||
else
|
||
return a.isUp > b.isUp
|
||
end
|
||
end)
|
||
--"装备数量:"
|
||
this.itemNumText.text = "礼物种类:" .. count
|
||
--LogError("xxxxxxxxxxxxxxxxxxxx"..#allEquip)
|
||
this:SetItemData(allEquip)
|
||
|
||
--this.CheckRedTab()
|
||
end
|
||
|
||
function this:SetItemData(_itemDatas)
|
||
if LengthOfTable(_itemDatas) == 0 then
|
||
this.emptyObj.gameObject:SetActive(true)
|
||
else
|
||
this.emptyObj.gameObject:SetActive(false)
|
||
end
|
||
for k, v in pairs(this.equipPreList) do
|
||
v.gameObject:SetActive(false)
|
||
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
|
||
if not this.equipPreList[_go] then
|
||
this.equipPreList[_go] = SubUIManager.Open(SubUIConfig.ItemView, _go.transform)
|
||
end
|
||
local redPoint = Util.GetGameObject(_go.transform, "redPoint")
|
||
local tip = Util.GetGameObject(_go.transform, "tip")
|
||
tip:SetActive(_itemData.isUp == 1)
|
||
local isHave = CheckListIsContainValue1(allUpIds, _itemData.id) or
|
||
CheckListIsContainValue1(upSuitId, equipConfig[_itemData.id].SuiteID)
|
||
redPoint:SetActive(isHave == false and curNum > #allUpIds)
|
||
this.equipPreList[_go].gameObject:SetActive(true)
|
||
this.equipPreList[_go].transform:SetAsFirstSibling()
|
||
this.equipPreList[_go]:ResetNameColor(Color.New(178 / 255, 85 / 255, 55 / 255, 1))
|
||
--if itemConfig[_itemData.id].ItemType == ItemType.Equip then
|
||
this.equipPreList[_go]:OnOpen(false, { _itemData.id, _itemData.num }, 1.1, false, false, false, this.sortingOrder + 1,
|
||
_itemData.idDyn)
|
||
-- 0.查看属性 1.穿戴 2.卸下 3.交换
|
||
--宝物界面
|
||
Util.AddOnceClick(Util.GetGameObject(_go.transform, "mask"), function()
|
||
BagManager.isBagPanel = true
|
||
if isHave then
|
||
UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2, this, _itemData, curHeroData, nil, false, false, true)
|
||
else
|
||
--UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2,this,_itemData,3,false,nil,curHeroData,4)
|
||
UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2, this, _itemData, curHeroData, nil, false, true, false)
|
||
end
|
||
end
|
||
)
|
||
]]
|
||
|
||
--end
|
||
|
||
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 power = Util.GetGameObject(_go.transform, "score"):GetComponent("Text")
|
||
local star = Util.GetGameObject(_go.transform, "star")
|
||
local pro = Util.GetGameObject(_go.transform, "pro")
|
||
local proBG = Util.GetGameObject(_go.transform, "pro/proBG")
|
||
local proIcon = Util.GetGameObject(_go.transform, "pro/proIcon")
|
||
Util.GetGameObject(_go.transform, "num").gameObject:SetActive(true)
|
||
Util.GetGameObject(_go.transform, "num"):GetComponent("Text").text = _itemData.num
|
||
power.text = GetLanguageStrById(22327) .. EquipManager.CalculateWarForce(_itemData.id)
|
||
local lvObj = Util.GetGameObject(_go.transform, "lv"):GetComponent("Text")
|
||
local refineObj = Util.GetGameObject(_go.transform, "refine"):GetComponent("Text")
|
||
frame.sprite = Util.LoadSprite(_itemData.frame)
|
||
icon.sprite = Util.LoadSprite(_itemData.icon)
|
||
lvObj.gameObject:SetActive(false)
|
||
refineObj.gameObject:SetActive(false)
|
||
pro:SetActive(false)
|
||
name.text = GetLanguageStrById(_itemData.itemConfig.Name)
|
||
star:SetActive(true)
|
||
--EquipManager.SetEquipStarShow(star, _itemData.itemConfig.Id)
|
||
SetHeroStars(star, equipConfig[_itemData.itemConfig.Id].Star, 1, nil, -15)
|
||
-- 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.id 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(icon.gameObject, function()
|
||
-- if curHeroEquipDatas[equipConfig[_itemData.id].Position] then
|
||
-- local nextEquipData = EquipManager.GetSingleEquipData(_itemData.id)
|
||
-- UIManager.OpenPanel(
|
||
-- UIName.RoleEquipChangePopup,
|
||
-- this,
|
||
-- 3,
|
||
-- curHeroData,
|
||
-- curHeroEquipDatas[equipConfig[_itemData.id].Position],
|
||
-- nextEquipData,
|
||
-- equipConfig[_itemData.id].Position
|
||
-- )
|
||
-- else
|
||
--UIManager.OpenPanel(UIName.RoleEquipChangePopup, this, 2, curHeroData, _itemData,
|
||
--equipConfig[_itemData.id].Position)
|
||
UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2, this, _itemData, curHeroData, nil, false, false, false)
|
||
-- end
|
||
end)
|
||
|
||
-- 穿戴
|
||
if _itemData.isUp == 2 then
|
||
Util.GetGameObject(_go.transform, "btn_sure"):GetComponent("Image").sprite = Util.LoadSprite(GetPictureFont(
|
||
"X1_genghuan_zhuangbei"))
|
||
else
|
||
Util.GetGameObject(_go.transform, "btn_sure"):GetComponent("Image").sprite = Util.LoadSprite(GetPictureFont(
|
||
"X1_xinpian_xinpianyizhuangbei"))
|
||
end
|
||
Util.AddOnceClick(Util.GetGameObject(_go.transform, "btn_sure"), function()
|
||
if _itemData.isUp == 2 then
|
||
local idList = {}
|
||
table.insert(idList, _itemData.id)
|
||
local heroId = ""
|
||
if curHeroData then
|
||
heroId = curHeroData.dynamicId
|
||
local list = GiftManager.GetHeroGifts(heroId)
|
||
if #list >= curNum then
|
||
PopupTipPanel.ShowTip(GetLanguageStrById(16010123))
|
||
return
|
||
end
|
||
else
|
||
heroId = "0"
|
||
local list = GiftManager.GetPlayerGifts()
|
||
if #list >= 12 then
|
||
PopupTipPanel.ShowTip(GetLanguageStrById(16010123))
|
||
return
|
||
end
|
||
end
|
||
NetManager.GiftEquipWearRequest(1, heroId, idList, function()
|
||
--self:ClosePanel()
|
||
if heroId == "0" then
|
||
GiftManager.SetPlayerGift(idList)
|
||
--HeroManager.ChangeAllHeroGiftLV()
|
||
else
|
||
GiftManager.SetHeroGift(curHeroData.dynamicId, idList, 1)
|
||
end
|
||
this.RefreshWindowData()
|
||
end)
|
||
end
|
||
end)
|
||
end
|
||
|
||
function this:SetSelectBtn()
|
||
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:SetSiblingIndex(1)
|
||
Util.GetGameObject(this.selectBtn.transform, "Text"):GetComponent("Text").text = GetCurLanguage() == 0 and
|
||
tableName[indexBtnNum] or
|
||
"<size=40>" ..
|
||
tableName[indexBtnNum] ..
|
||
"</size>" --typeTab[indexBtnNum]
|
||
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 RoleGiftPanel:OnClose()
|
||
BagManager.isBagPanel = false
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function RoleGiftPanel:OnDestroy()
|
||
_MainProList = {}
|
||
end
|
||
|
||
return RoleGiftPanel
|