105 lines
3.4 KiB
Lua
105 lines
3.4 KiB
Lua
|
----- 命格选择命石 -----
|
||
|
local GemCompound = {}
|
||
|
--传入父脚本模块
|
||
|
local parent
|
||
|
--传入特效层级
|
||
|
local sortingOrder=0
|
||
|
local args=nil
|
||
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
|
local gemConfig=ConfigManager.GetConfig(ConfigName.GemConfig)
|
||
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
||
|
function GemCompound:InitComponent(gameObject)
|
||
|
self.spLoader = SpriteLoader.New()
|
||
|
|
||
|
self.curGem = Util.GetGameObject(gameObject,"Gems/curGem")
|
||
|
self.targetGem = Util.GetGameObject(gameObject,"Gems/targetGem")
|
||
|
|
||
|
self.proGrid = Util.GetGameObject(gameObject,"Property")
|
||
|
self.proPre = Util.GetGameObject(self.proGrid,"propertyPre")
|
||
|
self.proPre:SetActive(false)
|
||
|
--滚动条根节点
|
||
|
self.root = Util.GetGameObject(gameObject, "Cost/Scroll")
|
||
|
self.itemPre = Util.GetGameObject(self.root,"itemPre")
|
||
|
|
||
|
self.proList={}
|
||
|
self.itemList={}
|
||
|
|
||
|
local rootHight = self.root.transform.rect.height
|
||
|
local width = self.root.transform.rect.width
|
||
|
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.root.transform,
|
||
|
self.itemPre,nil, Vector2.New(width, rootHight), 1, 1,Vector2.New(0,10))
|
||
|
self.ScrollView.moveTween.MomentumAmount = 1
|
||
|
self.ScrollView.moveTween.Strength = 2
|
||
|
self.ScrollView.elastic = false
|
||
|
|
||
|
end
|
||
|
|
||
|
function GemCompound:BindEvent()
|
||
|
end
|
||
|
|
||
|
function GemCompound:AddListener()
|
||
|
end
|
||
|
|
||
|
function GemCompound:RemoveListener()
|
||
|
end
|
||
|
|
||
|
function GemCompound:OnShow(_parent,_args)
|
||
|
args = _args
|
||
|
parent=_parent
|
||
|
sortingOrder =_parent.sortingOrder
|
||
|
GemCompound:Refresh(args[1])
|
||
|
end
|
||
|
function GemCompound:Refresh(Id)
|
||
|
-- local dataList = GemManager.GetGemsFromBagByType(Id)
|
||
|
-- self.ScrollView:SetData(dataList, function(index, go)
|
||
|
-- self:SingleDataShow(go,dataList[index],index)
|
||
|
-- go:SetActive(true)
|
||
|
-- end)
|
||
|
--设置当前和目标命石
|
||
|
if not self.curGemObj then
|
||
|
self.curGemObj = SubUIManager.Open(SubUIConfig.ItemView,self.curGem.transform)
|
||
|
self.targetGemObj = SubUIManager.Open(SubUIConfig.ItemView,self.targetGem.transform)
|
||
|
end
|
||
|
self.curGemObj:OnOpen(false, {Id,0}, 1.1, true,false,false,sortingOrder + 1)
|
||
|
self.targetGemObj:OnOpen(false, {Id + 1,0}, 1.1, true,false,false,sortingOrder + 1)
|
||
|
--设置属性
|
||
|
local data1,data2 = gemConfig[Id].Property,gemConfig[Id+1].Property
|
||
|
for i = 1, #data1 do
|
||
|
local go = self.proList[i]
|
||
|
if not go then
|
||
|
go = newObjToParent(self.proPre,self.proGrid.transform)
|
||
|
self.proList[i] = go
|
||
|
end
|
||
|
go:SetActive(true)
|
||
|
local proText = Util.GetGameObject(go,"proText"):GetComponent("Text")
|
||
|
local nextProText = Util.GetGameObject(go,"nextProText"):GetComponent("Text")
|
||
|
local upProText = Util.GetGameObject(go,"upProText"):GetComponent("Text")
|
||
|
proText.text = string.format("全体%s+%s",PropertyConfig[data1[i][1]].Info,data1[i][2]/100).."%"
|
||
|
nextProText.text = string.format("%s",data2[i][2]/100).."%"
|
||
|
upProText.text = string.format("%s",(data2[i][2]-data1[i][2])/100).."%"
|
||
|
end
|
||
|
--设置消耗
|
||
|
self:SetCost(1)
|
||
|
end
|
||
|
|
||
|
function GemCompound:SetCost(type)
|
||
|
|
||
|
end
|
||
|
|
||
|
function GemCompound:SingleDataShow(go,data,index)
|
||
|
|
||
|
end
|
||
|
|
||
|
function GemCompound:OnClose()
|
||
|
args=nil
|
||
|
end
|
||
|
|
||
|
function GemCompound:OnDestroy()
|
||
|
self.spLoader:Destroy()
|
||
|
self.itemList={}
|
||
|
self.proList={}
|
||
|
self.curGemObj = nil
|
||
|
self.targetGemObj = nil
|
||
|
end
|
||
|
|
||
|
return GemCompound
|