138 lines
5.3 KiB
Lua
138 lines
5.3 KiB
Lua
local QiJieTreasure = {}
|
|
--传入父脚本模块
|
|
local parent
|
|
--传入特效层级
|
|
local sortingOrder=0
|
|
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
-- Tab管理器
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabImgData = {select = "r_tongyong_xiaanniu_01", default = "r_tongyong_xiaanniu_02",}
|
|
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
|
|
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1) }
|
|
local _TabData = {
|
|
[1]= {txt = "全部",quality = 0},
|
|
[2]= {txt = "蓝色",quality = 2},
|
|
[3]= {txt = "紫色",quality = 3},
|
|
[4]= {txt = "金色",quality = 4},
|
|
[5]= {txt = "红色",quality = 5},
|
|
}
|
|
|
|
local QUALITY = {
|
|
-- [1] = {light="q_qjsl_yw_jhl",kuang="q_qjsl_yw_jsl"},
|
|
[2] = {light="q_qjsl_yw_jhl",kuang="q_qjsl_yw_jsl"},
|
|
[3] = {light="q_qjsl_yw_jhz",kuang="q_qjsl_yw_jsz"},
|
|
[4] = {light="q_qjsl_yw_jhhs",kuang="q_qjsl_yw_jshs"},
|
|
[5] = {light="q_qjsl_yw_jhh",kuang="q_qjsl_yw_jsh"},
|
|
[6] = {light="q_qjsl_yw_jhh",kuang="q_qjsl_yw_jsh"},
|
|
-- [7] = {light="q_qjsl_yw_jhl",kuang="q_qjsl_yw_jsl"},
|
|
}
|
|
|
|
--初始化组件(用于子类重写)
|
|
function QiJieTreasure:InitComponent(gameObject)
|
|
self.spLoader = SpriteLoader.New()
|
|
self.GameObject = Util.GetGameObject(gameObject,"Scroll")
|
|
self.itemPre = Util.GetGameObject(gameObject, "Pre")
|
|
self.tabbox = Util.GetGameObject(gameObject, "tabbox")
|
|
self.goBtn = Util.GetGameObject(gameObject, "Button")
|
|
self.treasureNum = Util.GetGameObject(gameObject, "Num"):GetComponent("Text")
|
|
|
|
local rootHight = self.GameObject.transform.rect.height
|
|
local width = self.GameObject.transform.rect.width
|
|
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollFitterView, self.GameObject.transform,
|
|
self.itemPre, Vector2.New(width, rootHight), 1, 0)
|
|
self.ScrollView.moveTween.MomentumAmount = 1
|
|
self.ScrollView.moveTween.Strength = 2
|
|
self.ScrollView.elastic = false
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function QiJieTreasure:BindEvent()
|
|
Util.AddClick(self.goBtn,function ()
|
|
if #QiJieShiLianManager.treasureActiveList <= 0 then
|
|
PopupTipPanel.ShowTip("暂无遗物加成。")
|
|
return
|
|
end
|
|
UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.QiJieAllTreasure,QiJieShiLianManager.treasureActiveList)
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function QiJieTreasure:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.QiJieShiLian.BuySingleTreasure, self.Refresh,self)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function QiJieTreasure:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.QiJieShiLian.BuySingleTreasure, self.Refresh,self)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function QiJieTreasure:OnShow(_parent,...)
|
|
parent =_parent
|
|
sortingOrder = _parent.sortingOrder
|
|
self:SetTabBox()
|
|
self:Refresh()
|
|
end
|
|
|
|
function QiJieTreasure:SetTabBox()
|
|
local TabAdapter = function (tab, index, status)
|
|
local img = Util.GetGameObject(tab, "Image")
|
|
local txt = Util.GetGameObject(tab, "Text")
|
|
img:GetComponent("Image").sprite = self.spLoader:LoadSprite(_TabImgData[status])
|
|
txt:GetComponent("Text").text = _TabData[index].txt
|
|
txt:GetComponent("Text").color = _TabFontColor[status]
|
|
end
|
|
|
|
local OnTabChange = function (index)
|
|
self:Refresh(_TabData[index].quality)
|
|
end
|
|
|
|
self.TabCtrl = TabBox.New()
|
|
self.TabCtrl:SetTabAdapter(TabAdapter)
|
|
self.TabCtrl:SetChangeTabCallBack(OnTabChange)
|
|
self.TabCtrl:Init(self.tabbox, _TabData)
|
|
end
|
|
|
|
function QiJieTreasure:Refresh(_tabNum)
|
|
self.dataList = QiJieShiLianManager.FormatTreasureData(_tabNum)
|
|
self.treasureNum.text = string.format( "%s/%s",#QiJieShiLianManager.treasureActiveList,#QiJieShiLianManager.treasureList)
|
|
self.ScrollView:SetData(self.dataList, function(index, go)
|
|
self:SetSingleData(index,go,self.dataList[index])
|
|
end)
|
|
end
|
|
|
|
function QiJieTreasure:SetSingleData(index,_go,_data)
|
|
for i = 1, 4 do
|
|
local obj = Util.GetGameObject(_go,"Pre ("..i..")")
|
|
if _data[i] then
|
|
obj:SetActive(true)
|
|
Util.GetGameObject(obj,"Name"):GetComponent("Text").text = _data[i].Name
|
|
local img = Util.GetGameObject(obj,"Image"):GetComponent("Image")
|
|
local imgLight = Util.GetGameObject(obj,"light"):GetComponent("Image")
|
|
local imgKuang = Util.GetGameObject(obj,"kuang"):GetComponent("Image")
|
|
img.sprite = self.spLoader:LoadSprite(artConfig[_data[i].Icon].Name)
|
|
imgLight.sprite = self.spLoader:LoadSprite(QUALITY[_data[i].Quality].light)
|
|
imgKuang.sprite = self.spLoader:LoadSprite(QUALITY[_data[i].Quality].kuang)
|
|
Util.SetGray(img.gameObject,_data[i].state == 2)
|
|
Util.SetGray(imgKuang.gameObject,_data[i].state == 2)
|
|
imgLight.gameObject:SetActive(_data[i].state == 1)
|
|
else
|
|
obj:SetActive(false)
|
|
end
|
|
Util.AddOnceClick(obj,function ()
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.QiJieSingleTreasure,_data[i])
|
|
end)
|
|
end
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function QiJieTreasure:OnClose()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function QiJieTreasure:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
end
|
|
|
|
return QiJieTreasure |