158 lines
4.8 KiB
Lua
158 lines
4.8 KiB
Lua
|
local this={}
|
||
|
|
||
|
this.tab=ConfigManager.GetConfig(ConfigName.Hongmeng)
|
||
|
local Box=0;
|
||
|
local OpenBox=2
|
||
|
function this:InitComponent(gameObject)
|
||
|
|
||
|
-- item预制件
|
||
|
|
||
|
this.item = Util.GetGameObject(gameObject , "HarmonyPanel/item")
|
||
|
|
||
|
--btn组件
|
||
|
this.addBtn = Util.GetGameObject(gameObject,"HarmonyPanel/AddBtn")
|
||
|
this.GongMingMsgBtn = Util.GetGameObject(gameObject,"HarmonyPanel/KnowGongMing")
|
||
|
this.NumText = Util.GetGameObject(gameObject,"HarmonyPanel/itemNumText"):GetComponent("Text")
|
||
|
this.scrollbar = Util.GetGameObject(gameObject,"HarmonyPanel/Scrollbar"):GetComponent("Scrollbar")
|
||
|
local scrollParent = Util.GetGameObject(gameObject, "HarmonyPanel/scroll"):GetComponent("RectTransform").rect
|
||
|
|
||
|
|
||
|
|
||
|
this.ScrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,Util.GetGameObject(gameObject,"HarmonyPanel/scroll").transform,
|
||
|
this.item,this.scrollbar,Vector2.New(-scrollParent.x*2,-scrollParent.y*2),1,5,Vector2.New(35,15))
|
||
|
|
||
|
this.ScrollView.moveTween.MomentumAmount = 1
|
||
|
this.ScrollView.moveTween.Strength = 1
|
||
|
-- for key, value in ConfigPairs(this.tab) do
|
||
|
-- print("key:",key,"value",value.Id)
|
||
|
-- end
|
||
|
|
||
|
|
||
|
this.BoxList=0;
|
||
|
this:InitBox()
|
||
|
end
|
||
|
|
||
|
function this:InitBox()
|
||
|
this.NumText.text = string.format("%d/%d",0,this.BoxList)
|
||
|
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
|
||
|
this.ScrollView:SetData(keys,function (index, go)
|
||
|
local key = keys[index]
|
||
|
this.SingleBoxDataShow(go, this.tab[key])
|
||
|
|
||
|
end)
|
||
|
end
|
||
|
function this.SingleBoxDataShow(go,boxData)
|
||
|
-- body
|
||
|
print("1111111111s")
|
||
|
local mask = Util.GetGameObject(go.transform,"Box/Empty/lock/mask");
|
||
|
local lock=Util.GetGameObject(go.transform,"Box/Empty/lock");
|
||
|
|
||
|
if mask.activeSelf then
|
||
|
if boxData.Id<OpenBox then--拥有格子数
|
||
|
mask:SetActive(false)
|
||
|
if boxData.Id<=Box then
|
||
|
-- body
|
||
|
lock:SetActive(false)
|
||
|
end
|
||
|
Util.AddOnceClick(go,function()
|
||
|
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.RereshNumText);
|
||
|
-- lock:SetActive(false)
|
||
|
end)
|
||
|
else
|
||
|
mask:SetActive(true)
|
||
|
lock:SetActive(true)
|
||
|
end
|
||
|
-- body
|
||
|
else
|
||
|
if boxData.Id<OpenBox then--拥有格子数
|
||
|
mask:SetActive(false)
|
||
|
lock:SetActive(false)
|
||
|
else
|
||
|
mask:SetActive(true)
|
||
|
lock:SetActive(true)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
if boxData.Id<OpenBox then--拥有格子数
|
||
|
mask:SetActive(false)
|
||
|
Util.AddOnceClick(go,function()
|
||
|
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.RereshNumText);
|
||
|
lock:SetActive(false)
|
||
|
end)
|
||
|
else
|
||
|
mask:SetActive(true)
|
||
|
--Box:SetActive(true)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function this:BindEvent()
|
||
|
-- body
|
||
|
|
||
|
|
||
|
end
|
||
|
--刷新显示的方法 已拥有的鸿蒙守卫数 已拥有的格子数 格子总数
|
||
|
function this:UpdataShow(itemList,BoxList,BoxLength)
|
||
|
|
||
|
for i = 1, BoxLength do
|
||
|
if i<=#itemList then
|
||
|
|
||
|
-- this.SingleItemDataShow(this.item , )
|
||
|
elseif i>#itemList and i<=#BoxList then
|
||
|
-- body
|
||
|
|
||
|
else
|
||
|
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
function this.SingleItemDataShow(clone,Itemdata)
|
||
|
-- Util.GetGameObject(clone.transform,"GameObject/icon"):GetComponent("icon").sprite=Util.LoadSprite(GetHeroQuantityImageByquality(heroData.config.Quality,heroData.star))
|
||
|
-- Util.GetGameObject(clone.transform, "lv"):SetActive(false)-- :GetComponent("Text").text = heroData.lv
|
||
|
-- Util.GetGameObject(clone.transform, "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(heroData.config.Icon))
|
||
|
-- Util.GetGameObject(clone.transform, "posIcon"):SetActive(false)--:GetComponent("Image").sprite = Util.LoadSprite(heroData.professionIcon)
|
||
|
-- Util.GetGameObject(clone.transform, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.config.PropertyName))
|
||
|
end
|
||
|
|
||
|
|
||
|
function this:Refesh()
|
||
|
-- body
|
||
|
|
||
|
Box=Box+1
|
||
|
OpenBox = OpenBox+1
|
||
|
this.NumText.text = string.format("%d/%d",0,Box)
|
||
|
|
||
|
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
|
||
|
this.ScrollView:SetData(keys,function (index, go)
|
||
|
local key = keys[index]
|
||
|
this.SingleBoxDataShow(go, this.tab[key])
|
||
|
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function this:AddListener()
|
||
|
-- body
|
||
|
print(" 注册消息成功")
|
||
|
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.RereshNumText,self.Refesh,self)
|
||
|
end
|
||
|
|
||
|
function this:RemoveListener()
|
||
|
-- body
|
||
|
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.RereshNumText,self.Refesh,self)
|
||
|
end
|
||
|
function this:OnShow(...)
|
||
|
-- body
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
function this:SingleHeroDataShow(_go,_HongMengData)
|
||
|
local clone = _go
|
||
|
local HongMeng = _HongMengData
|
||
|
|
||
|
-- body
|
||
|
end
|
||
|
|
||
|
return this
|