571 lines
23 KiB
Lua
571 lines
23 KiB
Lua
local Gem = quick_class("Gem", BasePanel)
|
|
local itemData = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local gemConfig = ConfigManager.GetConfig(ConfigName.GemConfig)
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local gemLottery = ConfigManager.GetConfig(ConfigName.GemLotteryConfig)
|
|
local typeName = {
|
|
[1] = Language[10980], [2] = Language[10981], [3] = Language[10982], [4] = Language[10983], [5] = Language[10980],
|
|
[6] = Language[10981], [7] = Language[10982], [8] = Language[10983],
|
|
}
|
|
local imgName = {
|
|
[1] = "m_mingge_gongji",
|
|
[2] = "m_mingge_shengming",
|
|
[3] = "m_mingge_zengshang",
|
|
[4] = "m_mingge_shanghai",
|
|
[5] = "m_mingge_renjie",
|
|
[6] = "m_mingge_pochan",
|
|
[7] = "m_mingge_yaoling",
|
|
[8] = "m_mingge_daoxuan",
|
|
}
|
|
|
|
--抽卡类型
|
|
local drawType = {
|
|
[1] = { 162, 163 },
|
|
[2] = { 164, 165 }
|
|
}
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabData = {
|
|
[1] = { default = "r_hero_yuansukuang", select = "z_icon_guang", name = Language[10984], type = 0, funcId = 136 },
|
|
[2] = { default = "r_hero_yuansukuang", select = "z_icon_guang", name = Language[10985], type = 1, funcId = 144 },
|
|
[3] = { default = "r_hero_yuansukuang", select = "z_icon_guang", name = Language[10986], type = 2, funcId = 145 },
|
|
}
|
|
local TabAdapter = nil
|
|
local SwitchView = nil
|
|
local curType = 0
|
|
local activityId = 0
|
|
local progresss = 0
|
|
local wishLv = 0
|
|
local oldWarPower = 0
|
|
local redList = {}
|
|
function Gem:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
if not self.playerInfoView then
|
|
self.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, self.transform)
|
|
end
|
|
self.BtView = SubUIManager.Open(SubUIConfig.BtView, self.transform)
|
|
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
|
|
--MidPart
|
|
self.mid = Util.GetGameObject(self.gameObject, "Mid")
|
|
self.img = Util.GetGameObject(self.mid, "Man"):GetComponent("Image")
|
|
self.ManCanvas = Util.GetGameObject(self.mid, "Man"):GetComponent("Canvas")
|
|
self.fx_ui_xiuxingshengxin_cangzhu = Util.GetGameObject(self.gameObject, "Bg/fx_ui_xiuxingshengxin_cangzhu")
|
|
--Gems
|
|
self.gems = Util.GetGameObject(self.gameObject, "Gems")
|
|
self.stones = Util.GetGameObject(self.gameObject, "Stones")
|
|
self.gemName = Util.GetGameObject(self.gameObject, "Stones/Name/Text"):GetComponent("Text")
|
|
self.itemList = {}
|
|
self.propertyList = {}
|
|
self.lightList = {}
|
|
self.btns = {}
|
|
for i = 1, 2 do
|
|
self.btns[i] = {}
|
|
self.btns[i].btn = Util.GetGameObject(self.gameObject, "btngroup/btn" .. i)
|
|
-- self.btns[i].layoutDi = Util.GetGameObject(self.btns[i].btn.gameObject,"layout/di"):GetComponent("Image")
|
|
--self.btns[i].layoutDi.sprite=self.spLoader:LoadSprite("z_zhaohuan_xiaohaodi_1")
|
|
self.btns[i].red = Util.GetGameObject(self.btns[i].btn.gameObject, "redPoint")
|
|
self.btns[i].info = Util.GetGameObject(self.btns[i].btn.gameObject, "layout/Text"):GetComponent("Text")
|
|
self.btns[i].icon = Util.GetGameObject(self.btns[i].btn.gameObject, "layout/icon"):GetComponent("Image")
|
|
self.btns[i].num = Util.GetGameObject(self.btns[i].btn.gameObject, "layout/num"):GetComponent("Text")
|
|
self.btns[i].time = Util.GetGameObject(self.btns[i].btn.gameObject, "time"):GetComponent("Text")
|
|
end
|
|
|
|
--页签
|
|
self.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn")
|
|
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
|
|
self.additionBtn = Util.GetGameObject(self.gameObject, "additionBtn")
|
|
self.curType = 1
|
|
|
|
--页签
|
|
self.tab = Util.GetGameObject(self.gameObject, "TabBox")
|
|
|
|
TabAdapter = function(tab, index, status)
|
|
local tabLab = Util.GetGameObject(tab, "Text")
|
|
Util.GetGameObject(tab, "Image"):GetComponent("Image").sprite = self.spLoader:LoadSprite(_TabData[index][status])
|
|
tabLab:GetComponent("Text").text = _TabData[index].name
|
|
local red = Util.GetGameObject(tab, "Redpot")
|
|
if index == 2 then
|
|
red:SetActive(GemNewManager.CheckGemRed())
|
|
elseif index == 3 then
|
|
red:SetActive(GemNewManager.CheckSuperGemRed())
|
|
end
|
|
redList[index] = red
|
|
end
|
|
--切换视图
|
|
SwitchView = function(_index)
|
|
if _index == 1 then
|
|
UIManager.OpenPanel(UIName.PracticePanel)
|
|
self:ClosePanel()
|
|
else
|
|
local isOpen = CheckFunctionOpen(_TabData[_index].funcId)
|
|
local tip = GetFunctionOpenTip(_TabData[_index].funcId)
|
|
if not isOpen then
|
|
PopupTipPanel.ShowTip(tip)
|
|
return
|
|
end
|
|
self:UpdatePanelData(_TabData[_index].type)
|
|
end
|
|
end
|
|
self.TabCtrl = TabBox.New()
|
|
self.TabCtrl:SetTabAdapter(TabAdapter)
|
|
self.TabCtrl:SetChangeTabCallBack(SwitchView)
|
|
|
|
--命石位置
|
|
self.gemPosList = {}
|
|
for i = 1, 8 do
|
|
self.gemPosList[i] = {}
|
|
self.gemPosList[i].go = Util.GetGameObject(self.gameObject, "Gems/" .. "item (" .. i .. ")")
|
|
self.gemPosList[i].red = Util.GetGameObject(self.gemPosList[i].go, "RedPoint")
|
|
self.gemPosList[i].red:SetActive(false)
|
|
Util.GetGameObject(self.gemPosList[i].go, "frame/Image"):SetActive(false)
|
|
self.gemPosList[i].frame = Util.GetGameObject(self.gemPosList[i].go, "frame"):GetComponent("Image")
|
|
self.gemPosList[i].icon = Util.GetGameObject(self.gemPosList[i].go, "frame/icon"):GetComponent("Image")
|
|
self.gemPosList[i].btn = Util.GetGameObject(self.gemPosList[i].go, "frame/icon")
|
|
end
|
|
|
|
--宝箱
|
|
self.btn_box = Util.GetGameObject(self.gameObject, "btngroup/rewardBox/Btn")
|
|
self.boxLv = Util.GetGameObject(self.gameObject, "btngroup/rewardBox/di/Text"):GetComponent("Text")
|
|
self.boxIcon = Util.GetGameObject(self.gameObject, "btngroup/rewardBox/boxIcon"):GetComponent("Image")
|
|
|
|
self.boxProgress = Util.GetGameObject(self.gameObject, "btngroup/rewardBox/progress/Text"):GetComponent("Text")
|
|
self.proPreList = {}
|
|
for i = 1, 8 do
|
|
self.propertyList[i] = Util.GetGameObject(self.gameObject, "pro/name (" .. i .. ")"):GetComponent("Text")
|
|
end
|
|
end
|
|
|
|
function Gem:BindEvent()
|
|
--帮助按钮
|
|
Util.AddClick(self.helpBtn, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Gem, self.helpPosition.x, self.helpPosition.y)
|
|
end)
|
|
|
|
Util.AddClick(self.btn_box, function()
|
|
UIManager.OpenPanel(UIName.GemRewardInfoPanel, curType, wishLv, progresss, activityId)
|
|
end)
|
|
|
|
|
|
Util.AddClick(self.additionBtn, function()
|
|
local tempData = GemManager.GetSortAttri()
|
|
if #tempData > 0 then
|
|
UIManager.OpenPanel(UIName.GeneralInfoPopup, GENERALINFO_TYPE.Gem)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10987])
|
|
end
|
|
end)
|
|
|
|
BindRedPointObject(RedPointType.Practice, self.practice_tab)
|
|
BindRedPointObject(RedPointType.Gem, self.gem_tab)
|
|
end
|
|
|
|
function Gem:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Gem.RefreshPanel, self.Refresh, self)
|
|
end
|
|
|
|
function Gem:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Gem.RefreshPanel, self.Refresh, self)
|
|
end
|
|
|
|
--刷新剩余次数
|
|
function Gem:UpdatePanelData(_type)
|
|
curType = _type
|
|
--宝箱显示
|
|
if _type == 1 then
|
|
activityId = 12301
|
|
self.boxIcon.sprite = self.spLoader:LoadSprite("i_act_nwsdyy_box5")
|
|
else
|
|
activityId = 12401
|
|
self.boxIcon.sprite = self.spLoader:LoadSprite("i_act_nwsdyy_box6")
|
|
end
|
|
local isCan = false
|
|
local actconfigs = ActivityGiftManager.GetActivityInfoByType(activityId)
|
|
if actconfigs then
|
|
for i = 1, #actconfigs.mission do
|
|
progresss = actconfigs.mission[i].progress
|
|
--LogError("curtype==============="..curType)
|
|
local config = ConfigManager.GetConfigData(ConfigName.GemLotteryConfig, actconfigs.mission[i].missionId) --ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.GemLotteryConfig,"Library",curType,"Level",actconfigs.mission[i].missionId)
|
|
if actconfigs.mission[i].state == 0 and progresss >= config.LibraryNumber then
|
|
--LogError("-------------------------------------------------")
|
|
isCan = true
|
|
break
|
|
end
|
|
end
|
|
end
|
|
local nextNum = 0
|
|
--LogError("progress==============="..progresss)
|
|
self.boxIcon.gameObject:GetComponent("Animator").enabled = isCan
|
|
local curBoxConfig = ConfigManager.TryGetAllConfigsDataByKey(ConfigName.GemLotteryConfig, "Library", _type)
|
|
if curBoxConfig then
|
|
for i = 1, #curBoxConfig do
|
|
if curBoxConfig[i].Library == _type and progresss >= curBoxConfig[i].LibraryNumber then
|
|
wishLv = curBoxConfig[i].Level
|
|
else
|
|
nextNum = curBoxConfig[i].LibraryNumber
|
|
break
|
|
end
|
|
end
|
|
-- for i, v in ConfigPairs(curBoxConfig) do
|
|
-- if v.Library==_type and progresss>= v.LibraryNumber then
|
|
-- wishLv=v.Level
|
|
-- else
|
|
-- nextNum=v.LibraryNumber
|
|
-- break
|
|
-- end
|
|
-- end
|
|
end
|
|
if _type == 1 then
|
|
self.boxLv.text = Language[10988] .. wishLv
|
|
else
|
|
self.boxLv.text = Language[10989] .. wishLv
|
|
end
|
|
|
|
LogError("nextnum===" .. nextNum .. " progersss==" .. progresss)
|
|
if nextNum == 0 and progresss ~= 0 then
|
|
self.boxProgress.text = Language[10990]
|
|
else
|
|
self.boxProgress.text = progresss .. "/" .. nextNum
|
|
end
|
|
|
|
--设置命石属性
|
|
local proList = GemNewManager.GetProListByType(_type)
|
|
for i = 1, 8 do
|
|
if i <= #proList then
|
|
self.propertyList[i].gameObject:SetActive(true)
|
|
else
|
|
self.propertyList[i].gameObject:SetActive(false)
|
|
end
|
|
end
|
|
local index = 0
|
|
for k, v in pairs(proList) do
|
|
local str = ""
|
|
index = index + 1
|
|
self.propertyList[index].gameObject:SetActive(true)
|
|
if PropertyConfig[k].Style == 1 then
|
|
str = string.format("<color=#4AFF00>%s+%s</color>", GetLanguageStrById(PropertyConfig[k].Info), v)
|
|
elseif PropertyConfig[k].Style == 2 then
|
|
str = string.format("<color=#4AFF00>%s+%s%s</color>", GetLanguageStrById(PropertyConfig[k].Info), v / 100, "%")
|
|
end
|
|
self.propertyList[index].text = str
|
|
end
|
|
--命石显示
|
|
local list = GemNewManager.GetGemListByType(_type)
|
|
for i = 1, #self.gemPosList do
|
|
local index = i
|
|
if _type == 2 then
|
|
index = i + 8
|
|
end
|
|
if list[index] then
|
|
self.gemPosList[i].icon.gameObject:SetActive(true)
|
|
self.gemPosList[i].frame.sprite = self.spLoader:LoadSprite(list[index].frame)
|
|
self.gemPosList[i].icon.sprite = self.spLoader:LoadSprite(list[index].icon)
|
|
Util.AddClick(self.gemPosList[i].btn, function()
|
|
UIManager.OpenPanel(UIName.RewardGemSingleShowPopup, list[index], 3)
|
|
end)
|
|
else
|
|
self.gemPosList[i].frame.sprite = self.spLoader:LoadSprite("r_characterbg_gray")
|
|
self.gemPosList[i].icon.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
|
|
|
|
if _type == 1 then
|
|
redList[_type + 1]:SetActive(GemNewManager.CheckGemRed())
|
|
elseif _type == 2 then
|
|
redList[_type + 1]:SetActive(GemNewManager.CheckSuperGemRed())
|
|
end
|
|
--按钮赋值
|
|
for n, m in ipairs(self.btns) do
|
|
--存在免费次数 并且 免费>=1 并且是1按钮
|
|
local isFree = false
|
|
m.icon.gameObject:SetActive(not isFree)
|
|
m.num.gameObject:SetActive(not isFree)
|
|
local itemId = 0
|
|
local itemNum = 0
|
|
if n == 1 then
|
|
--type = self.singleConfig.Id
|
|
m.info.text = Language[10577]
|
|
m.time.gameObject:SetActive(true)
|
|
m.red.gameObject:SetActive(false)
|
|
else
|
|
m.time.gameObject:SetActive(false)
|
|
m.info.text = Language[10578]
|
|
m.red.gameObject:SetActive(false)
|
|
end
|
|
--if self.config.ShopData[1][1] == TableRecruitType.Youqing then
|
|
m.time.gameObject:SetActive(false)
|
|
--end
|
|
local d = {}
|
|
local costId = drawType[_type][n]
|
|
local str = ConfigManager.GetConfigData(ConfigName.SpecialConfig, costId).Value
|
|
str = StringToTable(str)
|
|
d = RecruitManager.GetExpendDataByCostItem(str, n, 100)
|
|
if (isFree) then
|
|
m.time.gameObject:SetActive(false)
|
|
m.info.text = Language[10588]
|
|
else
|
|
-- local d = RecruitManager.GetExpendData(type)
|
|
itemId = d[1]
|
|
itemNum = d[2]
|
|
m.icon.sprite = self.spLoader:LoadSprite(artResourcesConfig[itemConfig[itemId].ResourceID].Name)
|
|
m.num.text = PrintWanNum2(itemNum)
|
|
end
|
|
|
|
Util.AddOnceClick(m.btn, function()
|
|
if not isFree then
|
|
if BagManager.GetItemCountById(itemId) < itemNum then
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[itemId].Name) .. Language[10584])
|
|
return
|
|
end
|
|
end
|
|
|
|
local state = PlayerPrefs.GetInt(PlayerManager.uid .. "GeneralPopup_RecruitConfirm" .. 1111)
|
|
-- local recrutId = n == 1 and self.singleConfig.Id or self.tenConfig.Id
|
|
local recrutNum = n == 1 and 1 or 10
|
|
-- if state==0 and itemId == 16 and not isFree then
|
|
-- UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,recrutId,function()
|
|
-- self:Recruit(_type,recrutNum)
|
|
-- end)
|
|
-- else
|
|
self:Recruit(_type, recrutNum, costId)
|
|
--end
|
|
end)
|
|
end
|
|
|
|
-- HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Gem)
|
|
-- --获取新战力
|
|
-- NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
|
|
-- local tempPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
-- LogError("oldwar===="..oldWarPower.." temppower=="..tempPower)
|
|
-- if oldWarPower ~= tempPower then
|
|
-- oldWarPower=tempPower
|
|
-- UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldWarPower,newValue = tempPower})
|
|
-- end
|
|
end
|
|
|
|
function Gem:Recruit(recrutType, num, costId)
|
|
NetManager.GemNewDrawRequest(recrutType, num, function(msg)
|
|
if num == 1 then
|
|
UIManager.OpenPanel(UIName.WishGemBuyOnePanel, msg.drop, recrutType, costId, activityId)
|
|
else
|
|
UIManager.OpenPanel(UIName.WishGemBuyTenPanel, msg.drop, recrutType, costId, activityId)
|
|
end
|
|
--CheckRedPointStatus(self.config.RpType)
|
|
end)
|
|
end
|
|
|
|
--待功能扩展(试图打开某个状态)
|
|
function Gem:OnOpen()
|
|
self.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Gem })
|
|
self.BtView:OnOpen(self, { sortOrder = self.sortingOrder, panelType = PanelTypeView.Practice })
|
|
self.TabCtrl:Init(self.tab, _TabData, 2)
|
|
end
|
|
|
|
function Gem:OnSortingOrderChange()
|
|
self.BtView:OnOpen(self, { sortOrder = self.sortingOrder, panelType = PanelTypeView.Practice })
|
|
self.ManCanvas.sortingOrder = self.sortingOrder + 2
|
|
Util.SetParticleSortLayer(self.fx_ui_xiuxingshengxin_cangzhu, self.sortingOrder + 1)
|
|
-- 头像层级
|
|
if self.playerInfoView then
|
|
self.playerInfoView:SetLayer(self.sortingOrder)
|
|
end
|
|
end
|
|
|
|
function Gem:OnShow()
|
|
oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
GemNewManager.oldPower = oldWarPower
|
|
LogError("oldWarPower=====================" .. oldWarPower)
|
|
self.playerInfoView:OnShow()
|
|
Util.SetParticleSortLayer(self.fx_ui_xiuxingshengxin_cangzhu, self.sortingOrder + 1)
|
|
--self:Refresh()
|
|
self:UpdatePanelData(curType)
|
|
end
|
|
|
|
function Gem:Refresh()
|
|
CheckRedPointStatus(RedPointType.Gem)
|
|
self:UpdatePanelData(curType)
|
|
--self:RefreshMid()
|
|
--self:SetGems()
|
|
--self:SetStones(GemManager.myGemList[self.curType],self.curType)
|
|
end
|
|
|
|
--刷新中部人物
|
|
function Gem:RefreshMid()
|
|
local playerImg = NameManager.roleSex == 0 and "x_xiuxing_liangongren_nan" or "x_xiuxing_liangongren_nv"
|
|
self.img.sprite = self.spLoader:LoadSprite(playerImg)
|
|
self.ManCanvas.sortingOrder = self.sortingOrder + 2
|
|
end
|
|
|
|
--设置中部宝石数据
|
|
function Gem:SetGems()
|
|
local gemData = GemManager.myGemList
|
|
for i = 1, 8 do
|
|
local itemGo = Util.GetGameObject(self.gems, "item (" .. i .. ")")
|
|
local nameImg = Util.GetGameObject(itemGo, "Name"):GetComponent("Text")
|
|
local redPoint = Util.GetGameObject(itemGo, "RedPoint")
|
|
self.lightList[i] = Util.GetGameObject(itemGo, "Light")
|
|
nameImg.text = typeName[i]
|
|
redPoint:SetActive(false)
|
|
for j = 1, 3 do
|
|
local stoneGo = Util.GetGameObject(itemGo, "stone (" .. j .. ")")
|
|
local level = Util.GetGameObject(stoneGo, "Text"):GetComponent("Text")
|
|
local icon = Util.GetGameObject(stoneGo, "icon"):GetComponent("Image")
|
|
local img = Util.GetGameObject(stoneGo, "icon"):GetComponent("Image")
|
|
local name = nil
|
|
level.text = ""
|
|
if gemData[i] and gemData[i][j] and gemData[i][j] > 0 then
|
|
name = GetSpriteNameByItemId(gemData[i][j])
|
|
level.text = gemConfig[gemData[i][j]].Level
|
|
end
|
|
|
|
--红点和命石icon
|
|
local redPointData = GemManager.GetGemsFromBagByType(i)
|
|
if name ~= nil then --装备了命石
|
|
icon.gameObject:SetActive(true)
|
|
icon.sprite = self.spLoader:LoadSprite(name)
|
|
local numInBag = BagManager.GetTotalItemNum(gemData[i][j])
|
|
for key, value in pairs(redPointData) do --有更高级的命石红点显示
|
|
if value.id > gemData[i][j] then
|
|
redPoint:SetActive(true)
|
|
break
|
|
end
|
|
if numInBag + 1 > gemConfig[gemData[i][j]].UpgradeNum and gemConfig[gemData[i][j]].NextGem > 0 then
|
|
redPoint:SetActive(true)
|
|
break
|
|
end
|
|
end
|
|
else
|
|
icon.gameObject:SetActive(false)
|
|
for key, value in pairs(redPointData) do --有多余命石,红点显示
|
|
if value.num > 0 then
|
|
redPoint:SetActive(true)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
Util.AddOnceClick(itemGo, function()
|
|
self.curType = i
|
|
self:SetStones(gemData[i], i)
|
|
end)
|
|
end
|
|
end
|
|
|
|
--设置下部宝石数据
|
|
function Gem:SetStones(_data, index)
|
|
local data = _data
|
|
local redPointData = GemManager.GetGemsFromBagByType(index)
|
|
self.gemName.text = typeName[index] .. Language[10985]
|
|
for i = 1, #self.lightList do
|
|
self.lightList[i]:SetActive(self.curType == i)
|
|
end
|
|
for i = 1, 3 do
|
|
local stoneGo = Util.GetGameObject(self.stones, "Stone (" .. i .. ")")
|
|
local item = Util.GetGameObject(stoneGo, "Item")
|
|
local mask = Util.GetGameObject(stoneGo, "Mask")
|
|
local property = Util.GetGameObject(stoneGo, "Property")
|
|
local textPre = Util.GetGameObject(property, "Text")
|
|
local name = Util.GetGameObject(stoneGo, "Name"):GetComponent("Text")
|
|
local redPoint = Util.GetGameObject(stoneGo, "RedPoint")
|
|
|
|
textPre:GetComponent("Text").text = ""
|
|
textPre:SetActive(false)
|
|
property:SetActive(false)
|
|
item:SetActive(false)
|
|
redPoint:SetActive(false)
|
|
name.text = ""
|
|
if data and data[i] and data[i] > 0 then
|
|
if not self.itemList[i] then
|
|
local view = SubUIManager.Open(SubUIConfig.ItemView, item.transform)
|
|
self.itemList[i] = view
|
|
end
|
|
self.itemList[i]:OnOpen(false, { data[i], 0 }, 1.1, false, false, false, self.sortingOrder + 1)
|
|
self.itemList[i].gameObject:SetActive(true)
|
|
item:SetActive(true)
|
|
name.text = GetLanguageStrById(gemConfig[data[i]].Name)
|
|
self:SetProperty(gemConfig[data[i]], data, property, textPre)
|
|
|
|
local numInBag = BagManager.GetTotalItemNum(data[i])
|
|
--红点
|
|
for key, value in pairs(redPointData) do --有更高级的命石红点显示
|
|
if value.id > data[i] then
|
|
redPoint:SetActive(true)
|
|
break
|
|
end
|
|
if numInBag + 1 >= gemConfig[data[i]].UpgradeNum and gemConfig[data[i]].NextGem > 0 then
|
|
redPoint:SetActive(true)
|
|
break
|
|
end
|
|
end
|
|
else
|
|
for key, value in pairs(redPointData) do --有多余命石,红点显示
|
|
if value.num > 0 then
|
|
redPoint:SetActive(true)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
Util.AddOnceClick(mask, function()
|
|
if data and data[i] and data[i] > 0 then
|
|
UIManager.OpenPanel(UIName.RewardGemSingleShowPopup, data[i], 2, nil, index, i)
|
|
else
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup, GENERAL_POPUP_TYPE.SelectGem, index, i)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
function Gem:SetProperty(configData, data, parent, text)
|
|
if not configData then
|
|
return
|
|
end
|
|
if not self.propertyList[parent] then
|
|
self.propertyList[parent] = {}
|
|
end
|
|
for k = 1, #self.propertyList[parent] do
|
|
self.propertyList[parent][k]:SetActive(false)
|
|
end
|
|
for j = 1, #configData.Property do
|
|
local data = configData.Property[j]
|
|
local item = self.propertyList[parent][j]
|
|
parent:SetActive(true)
|
|
if not item then
|
|
item = newObjToParent(text, parent.transform)
|
|
self.propertyList[parent][j] = item
|
|
end
|
|
item:SetActive(true)
|
|
local str = ""
|
|
if PropertyConfig[data[1]].Style == 1 then
|
|
str = string.format(Language[10991], PropertyConfig[data[1]].Info, data[2])
|
|
elseif PropertyConfig[data[1]].Style == 2 then
|
|
str = string.format(Language[10991], PropertyConfig[data[1]].Info, data[2] / 100) .. "%"
|
|
end
|
|
item:GetComponent("Text").text = str -- string.format( "%s+%s",PropertyConfig[data[1]].Info,data[2]/100).."%"
|
|
end
|
|
end
|
|
|
|
function Gem:OnClose()
|
|
self.lightList = {}
|
|
end
|
|
|
|
function Gem:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
SubUIManager.Close(self.UpView)
|
|
SubUIManager.Close(self.BtView)
|
|
ClearRedPointObject(RedPointType.Practice, self.practice_tab)
|
|
ClearRedPointObject(RedPointType.Gem, self.gem_tab)
|
|
self.UpView = nil
|
|
self.BtView = nil
|
|
if self.playerInfoView then
|
|
SubUIManager.Close(self.playerInfoView)
|
|
self.playerInfoView = nil
|
|
end
|
|
redList = {}
|
|
self.itemList = {}
|
|
self.propertyList = {}
|
|
self.lightList = {}
|
|
end
|
|
|
|
return Gem
|