112 lines
3.6 KiB
Lua
112 lines
3.6 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 = "全部"},
|
|
[2]= {txt = "白色"},
|
|
[3]= {txt = "蓝色"},
|
|
[4]= {txt = "金色"},
|
|
[5]= {txt = "红色"},
|
|
}
|
|
|
|
--初始化组件(用于子类重写)
|
|
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")
|
|
|
|
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()
|
|
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function QiJieTreasure:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function QiJieTreasure:RemoveListener()
|
|
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.tabNum = index - 1
|
|
self:Refresh(self.tabNum)
|
|
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.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")
|
|
img.sprite = self.spLoader:LoadSprite(artConfig[_data[i].Icon].Name)
|
|
Util.SetGray(img.gameObject,i%2==0)
|
|
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 |