parent
30ab410f00
commit
55b4379c47
|
@ -35,81 +35,116 @@ function RecruitMainPanel:InitComponent()
|
||||||
if not this.itemList[i] then
|
if not this.itemList[i] then
|
||||||
this.itemList[i] = {}
|
this.itemList[i] = {}
|
||||||
this.itemList[i].go = newObjToParent(this.item,this.grid)
|
this.itemList[i].go = newObjToParent(this.item,this.grid)
|
||||||
local tran = this.itemList[i].go:GetComponent("RectTransform")
|
this.itemList[i].go.name = "tab_"..i
|
||||||
local vec = tran.anchoredPosition
|
this.itemList[i].tran = this.itemList[i].go:GetComponent("RectTransform")
|
||||||
|
local vec = this.itemList[i].tran.anchoredPosition
|
||||||
vec.x = off * (i - 1) + i * this.itemWidth
|
vec.x = off * (i - 1) + i * this.itemWidth
|
||||||
vec.y = 0
|
vec.y = 0
|
||||||
tran.anchoredPosition = vec
|
this.itemList[i].tran.anchoredPosition = vec
|
||||||
this.itemList[i].pos = tran.anchoredPosition
|
this.itemList[i].pos = this.itemList[i].tran.anchoredPosition
|
||||||
this.itemList[i].off = 0
|
this.itemList[i].index = i
|
||||||
this.itemList[i].img = Util.GetGameObject(this.itemList[i].go, "img"):GetComponent("Image")
|
this.itemList[i].img = Util.GetGameObject(this.itemList[i].go, "img"):GetComponent("Image")
|
||||||
this.itemList[i].redpot = Util.GetGameObject(this.itemList[i].go, "redpot")
|
this.itemList[i].redpot = Util.GetGameObject(this.itemList[i].go, "redpot")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
this.pos0 = Vector3.New(off * (0 - 1) + 0 * this.itemWidth,0,0)
|
||||||
|
this.pos4 = Vector3.New(off * (4 - 1) + 4 * this.itemWidth,0,0)
|
||||||
self.lastPage,self.curPage,self.nextPage = 0,0,0
|
self.lastPage,self.curPage,self.nextPage = 0,0,0
|
||||||
|
|
||||||
|
|
||||||
this.trigger = Util.GetEventTriggerListener(self.gameObject) --触摸事件
|
this.trigger = Util.GetEventTriggerListener(self.gameObject) --触摸事件
|
||||||
this.trigger.onBeginDrag = this.trigger.onBeginDrag + this.OnBeginDrag
|
this.trigger.onBeginDrag = this.trigger.onBeginDrag + this.OnBeginDrag
|
||||||
this.trigger.onDrag = this.trigger.onDrag + this.OnDrag
|
this.trigger.onDrag = this.trigger.onDrag + this.OnDrag
|
||||||
this.trigger.onEndDrag = this.trigger.onEndDrag + this.OnEndDrag
|
this.trigger.onEndDrag = this.trigger.onEndDrag + this.OnEndDrag
|
||||||
|
|
||||||
this.moveTween = this.grid:GetComponent(typeof(UITweenSpring))
|
-- this.moveTween = this.grid:GetComponent(typeof(UITweenSpring))
|
||||||
if not this.moveTween then
|
-- if not this.moveTween then
|
||||||
this.moveTween = this.grid:AddComponent(typeof(UITweenSpring))
|
-- this.moveTween = this.grid:AddComponent(typeof(UITweenSpring))
|
||||||
end
|
-- end
|
||||||
this.moveTween.enabled = false
|
-- this.moveTween.enabled = false
|
||||||
this.moveTween.OnUpdate = this.SetPos
|
-- this.moveTween.OnUpdate = this.SetPos
|
||||||
this.moveTween.OnMoveEnd = this.MoveTo
|
-- this.moveTween.OnMoveEnd = this.MoveTo
|
||||||
this.moveTween.MomentumAmount = 0.5
|
-- this.moveTween.MomentumAmount = 0.5
|
||||||
this.moveTween.Strength = 1
|
-- this.moveTween.Strength = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.SortItemList()
|
||||||
|
table.sort(this.itemList,function(a,b)
|
||||||
|
return a.index < b.index
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---设置位置
|
---设置位置
|
||||||
function this.SetPos(v2)
|
function this.SetPos(v2)
|
||||||
if isEnter == 1 then
|
if isEnter == 1 then
|
||||||
if v2.x > 2 then
|
if v2.x > 2 then
|
||||||
isEnter = 0
|
isEnter = 0 --右
|
||||||
this:RightAction()
|
this.MoveTo(2,function()
|
||||||
|
isEnter = 2
|
||||||
|
end)
|
||||||
elseif v2.x < -2 then
|
elseif v2.x < -2 then
|
||||||
isEnter = 0
|
isEnter = 0 --左
|
||||||
this:LeftAction()
|
this.MoveTo(3,function()
|
||||||
|
isEnter = 3
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---手指拖动结束 ui归位
|
---手指拖动结束 ui归位
|
||||||
function this.MoveTo()
|
function this.MoveTo(LOR,func)
|
||||||
-- local d = 1
|
this.select.gameObject:SetActive(false)
|
||||||
-- local targetIdx
|
for i = 1,#this.itemList do
|
||||||
-- for i=1, this.count do
|
local targetPos = ""
|
||||||
-- local item = this.ItemList[i]
|
if LOR == 2 then
|
||||||
|
if i + 1 > #this.itemList then
|
||||||
-- local dd = math.abs(this.ItemList[i].off)
|
targetPos = 1
|
||||||
-- if dd < d then
|
this.itemList[i].tran.anchoredPosition = this.pos0
|
||||||
-- targetIdx = i
|
else
|
||||||
-- d = dd
|
targetPos = i + 1
|
||||||
-- end
|
end
|
||||||
-- end
|
elseif LOR == 3 then
|
||||||
-- curIndex=targetIdx
|
if i - 1 < 1 then
|
||||||
-- this.MoveTween(-this.ItemList[targetIdx].off)
|
targetPos = #this.itemList
|
||||||
-- this.SetInfo(targetIdx)
|
this.itemList[i].tran.anchoredPosition = this.pos4
|
||||||
|
else
|
||||||
|
targetPos = i - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local targetPos1 = this.itemList[targetPos].pos
|
||||||
|
this.itemList[i].go.transform:DOAnchorPos(targetPos1, 0.2, false)
|
||||||
|
:OnStart(function() end)
|
||||||
|
:OnUpdate(function()end)
|
||||||
|
:OnComplete(function ()
|
||||||
|
this.itemList[i].index = targetPos
|
||||||
|
this.itemList[i].pos = targetPos1
|
||||||
|
if func then
|
||||||
|
func()
|
||||||
|
end
|
||||||
|
end):SetEase(Ease.Linear)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.OnBeginDrag(Pointgo, data)
|
function this.OnBeginDrag(Pointgo, data)
|
||||||
isEnter = 1
|
if isEnter == 0 then
|
||||||
this.moveTween.enabled = true
|
isEnter = 1
|
||||||
this.moveTween.Momentum = Vector3.zero
|
end
|
||||||
this.moveTween.IsUseCallBack = false
|
|
||||||
end
|
end
|
||||||
function this.OnDrag(Pointgo, data)
|
function this.OnDrag(Pointgo, data)
|
||||||
this.moveTween:LerpMomentum(data.delta)
|
|
||||||
this.SetPos(data.delta)
|
this.SetPos(data.delta)
|
||||||
end
|
end
|
||||||
function this.OnEndDrag(Pointgo, data)
|
function this.OnEndDrag(Pointgo, data)
|
||||||
--this.SetPos(data.delta)
|
Timer.New(function()
|
||||||
isEnter = 0
|
if isEnter == 2 or isEnter == 3 then
|
||||||
this.moveTween.IsUseCallBack = true
|
--this.SetPos(data.delta)
|
||||||
|
this.SortItemList()
|
||||||
|
if isEnter == 2 then
|
||||||
|
this:RightAction()
|
||||||
|
elseif isEnter == 3 then
|
||||||
|
this:LeftAction()
|
||||||
|
end
|
||||||
|
isEnter = 0
|
||||||
|
end
|
||||||
|
end,0.3):Start()
|
||||||
end
|
end
|
||||||
|
|
||||||
--绑定事件(用于子类重写)
|
--绑定事件(用于子类重写)
|
||||||
|
@ -119,10 +154,22 @@ function RecruitMainPanel:BindEvent()
|
||||||
this:ClosePanel()
|
this:ClosePanel()
|
||||||
end)
|
end)
|
||||||
Util.AddClick(this.leftBtn, function()
|
Util.AddClick(this.leftBtn, function()
|
||||||
this:LeftAction()
|
this.mask:SetActive(true)
|
||||||
|
this.MoveTo(3)
|
||||||
|
Timer.New(function()
|
||||||
|
this.SortItemList()
|
||||||
|
this:LeftAction()
|
||||||
|
this.mask:SetActive(false)
|
||||||
|
end,0.3):Start()
|
||||||
end)
|
end)
|
||||||
Util.AddClick(this.rightBtn, function()
|
Util.AddClick(this.rightBtn, function()
|
||||||
this:RightAction()
|
this.mask:SetActive(true)
|
||||||
|
this.MoveTo(2)
|
||||||
|
Timer.New(function()
|
||||||
|
this.SortItemList()
|
||||||
|
this:RightAction()
|
||||||
|
this.mask:SetActive(false)
|
||||||
|
end,0.3):Start()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -164,15 +211,14 @@ end
|
||||||
|
|
||||||
function this:RefreshTabData()
|
function this:RefreshTabData()
|
||||||
local curIndex = 0
|
local curIndex = 0
|
||||||
for i = 1,#this.itemList do
|
for i = 1,#this.itemList do
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
curIndex = self.lastPage
|
curIndex = self.lastPage
|
||||||
elseif i == 2 then
|
elseif i == 2 then
|
||||||
curIndex = self.curPage
|
curIndex = self.curPage
|
||||||
else
|
else
|
||||||
curIndex = self.nextPage
|
curIndex = self.nextPage
|
||||||
end
|
end
|
||||||
|
|
||||||
this.itemList[i].img.sprite = this.spLoader:LoadSprite(self.dicData[curIndex].Icon[1])
|
this.itemList[i].img.sprite = this.spLoader:LoadSprite(self.dicData[curIndex].Icon[1])
|
||||||
this.itemList[i].redpot.gameObject:SetActive(false)
|
this.itemList[i].redpot.gameObject:SetActive(false)
|
||||||
end
|
end
|
||||||
|
@ -204,8 +250,7 @@ function this:PageOnChange()
|
||||||
end
|
end
|
||||||
|
|
||||||
function this:LeftAction()
|
function this:LeftAction()
|
||||||
lastIndex = self.curPage
|
lastIndex = self.curPage
|
||||||
this.select.gameObject:SetActive(false)
|
|
||||||
self.CurRecruitId = self.dicData[self.nextPage].ShopData[1][1]
|
self.CurRecruitId = self.dicData[self.nextPage].ShopData[1][1]
|
||||||
self.lastPage = self.curPage
|
self.lastPage = self.curPage
|
||||||
self.curPage = self.nextPage
|
self.curPage = self.nextPage
|
||||||
|
@ -214,7 +259,6 @@ function this:LeftAction()
|
||||||
end
|
end
|
||||||
function this:RightAction()
|
function this:RightAction()
|
||||||
lastIndex = self.curPage
|
lastIndex = self.curPage
|
||||||
this.select.gameObject:SetActive(false)
|
|
||||||
self.CurRecruitId = self.dicData[self.lastPage].ShopData[1][1]
|
self.CurRecruitId = self.dicData[self.lastPage].ShopData[1][1]
|
||||||
self.nextPage = self.curPage
|
self.nextPage = self.curPage
|
||||||
self.curPage = self.lastPage
|
self.curPage = self.lastPage
|
||||||
|
|
|
@ -187,7 +187,6 @@ function RecruitPanelNew:UpdataWishPanel()
|
||||||
self.wishNoOpen.gameObject:SetActive(false)
|
self.wishNoOpen.gameObject:SetActive(false)
|
||||||
self.wishOpen.gameObject:SetActive(true)
|
self.wishOpen.gameObject:SetActive(true)
|
||||||
NetManager.ChoiceWishHeroRequest(nil,function ()
|
NetManager.ChoiceWishHeroRequest(nil,function ()
|
||||||
LogGreen("#self.upHeroPreList:"..#self.upHeroPreList)
|
|
||||||
for i = 1,3 do
|
for i = 1,3 do
|
||||||
local data = RecruitManager.WishCardData[i]
|
local data = RecruitManager.WishCardData[i]
|
||||||
local id = data.heroTid
|
local id = data.heroTid
|
||||||
|
|
Loading…
Reference in New Issue