From fabd517c04f56d7445fe112c2020189886e08e8e Mon Sep 17 00:00:00 2001 From: jiaoyangna <3046463818@qq.com> Date: Tue, 3 Aug 2021 12:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90ID1017608=E3=80=91=20=E3=80=90?= =?UTF-8?q?=E7=82=B9=E5=B0=86=E5=8F=B0=E3=80=91=E7=82=B9=E5=87=BB=E7=AE=AD?= =?UTF-8?q?=E5=A4=B4=EF=BC=8C=E5=BD=93=E5=88=87=E6=8D=A2=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A4=A7=E4=BA=8E2=E4=B8=AA=E6=97=B6=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=98=8E=E6=98=BE=E6=9C=AA=E5=AF=B9=E5=87=86?= =?UTF-8?q?=E5=90=8E=E6=A0=A1=E5=87=86=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Recruit/ElementDrawCardPanelNew.lua | 2 +- .../~Lua/Modules/Recruit/RecruitMainPanel.lua | 123 +++++++++++------- 2 files changed, 76 insertions(+), 49 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Recruit/ElementDrawCardPanelNew.lua b/Assets/ManagedResources/~Lua/Modules/Recruit/ElementDrawCardPanelNew.lua index c75e493205..5dca36e558 100644 --- a/Assets/ManagedResources/~Lua/Modules/Recruit/ElementDrawCardPanelNew.lua +++ b/Assets/ManagedResources/~Lua/Modules/Recruit/ElementDrawCardPanelNew.lua @@ -110,7 +110,7 @@ function ElementDrawCardPanelNew:BindEvent() end function ElementDrawCardPanelNew:BtnAction(index) - LogGreen("index:"..index) + --LogGreen("index:"..index) if not index or index < 1 or index > 4 then return end diff --git a/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitMainPanel.lua b/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitMainPanel.lua index ce70b94469..bb3a0f4e0c 100644 --- a/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitMainPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Recruit/RecruitMainPanel.lua @@ -7,7 +7,7 @@ local _CurPageIndex = 0 local orginLayer local redPointTypeList = {} local subViewList = {} -local isEnter = 0 +local isEnter = 0 --是否开始拖动 local lastIndex = 0 --初始化组件(用于子类重写) function RecruitMainPanel:InitComponent() @@ -35,29 +35,9 @@ function RecruitMainPanel:InitComponent() this.moveWidth = this.grid:GetComponent("RectTransform").rect.width this.itemWidth = this.item:GetComponent("RectTransform").rect.width this.off = 51 - -- for i = 1,this.count do - -- if not this.itemList[i] then - -- this.itemList[i] = {} - -- this.itemList[i].go = newObjToParent(this.item,this.grid) - -- this.itemList[i].go.name = "tab_"..i - -- this.itemList[i].tran = this.itemList[i].go:GetComponent("RectTransform") - -- local vec = this.itemList[i].tran.anchoredPosition - -- vec.x = this.off * (i - 1) + i * this.itemWidth - -- vec.y = 0 - -- this.itemList[i].tran.anchoredPosition = vec - -- this.itemList[i].pos = this.itemList[i].tran.anchoredPosition - -- this.itemList[i].index = i - -- this.itemList[i].img = Util.GetGameObject(this.itemList[i].go, "img"):GetComponent("Image") - -- this.itemList[i].redpot = Util.GetGameObject(this.itemList[i].go, "redpot") - -- end - -- end - this.pos0 = Vector3.New(this.off * (0 - 2) + (0 - 1) * this.itemWidth - 30,50,0) - --LogGreen("this.pos0:"..tostring(this.pos0)) - --this.pos4 = Vector3.New(this.off * (4 - 1) + 4 * this.itemWidth,0,0) self.lastPage,self.curPage,self.nextPage = 0,0,0 this.trigger = Util.GetEventTriggerListener(this.gameObject) --触摸事件 - this.AddTrigger() end function this.RemoveTrigger() @@ -78,7 +58,7 @@ function this.SortItemList() end) end ----设置位置 +---设置拖动左右方向 function this.SetPos(v2) if isEnter == 1 then if v2.x > 2 then @@ -96,6 +76,7 @@ function this.MoveTo(LOR,func) end this.select.gameObject:SetActive(false) for i = 1,#this.itemList do + this.itemList[i].move = true local targetPos = "" if LOR == 2 then if i + 1 > #this.itemList then @@ -112,13 +93,15 @@ function this.MoveTo(LOR,func) targetPos = i - 1 end end - local targetPos1 = this.itemList[targetPos].pos + local targetPos1 = this.itemList[targetPos].pos this.itemList[i].go.transform:DOAnchorPos(targetPos1, 0.2, false) - :OnStart(function() end) + :OnStart(function() + end) :OnUpdate(function()end) :OnComplete(function () this.itemList[i].index = targetPos this.itemList[i].pos = targetPos1 + this.itemList[i].move = false if func then func() end @@ -143,23 +126,33 @@ function this.OnEndDrag(Pointgo, data) local ro = isEnter isEnter = 1 this.mask:SetActive(true) + local localIsenter = false + this.RemoveTrigger() this.thread1 = coroutine.start(function() - this.RemoveTrigger() - coroutine.wait(0.01) - this.MoveTo(ro) - coroutine.wait(0.25) - this.SortItemList() - coroutine.wait(0.01) + this.MoveTo(ro) + --coroutine.wait(0.2/(this.itemWidth + this.off)) + while(not localIsenter) do + local isfinish = true + for j = 1,#this.itemList do + if this.itemList[j].move then + isfinish = false + break + end + end + if isfinish then + localIsenter = true + end + coroutine.wait(0.2/(this.itemWidth + this.off)) + end + this.SortItemList() if ro == 2 then this:RightAction() elseif ro == 3 then this:LeftAction() end - coroutine.wait(0.01) this.mask:SetActive(false) this.AddTrigger() isEnter = 0 - coroutine.yield() end) end @@ -170,31 +163,56 @@ function RecruitMainPanel:BindEvent() this:ClosePanel() end) Util.AddClick(this.leftBtn, function() + local localIsenter = false this.mask:SetActive(true) this.RemoveTrigger() self.thread = coroutine.start(function() - coroutine.wait(0.01) this.MoveTo(3) - coroutine.wait(0.25) + --coroutine.wait(0.2/(this.itemWidth + this.off)) + while(not localIsenter) do + local isfinish = true + for j = 1,#this.itemList do + if this.itemList[j].move then + isfinish = false + break + end + end + if isfinish then + localIsenter = true + end + coroutine.wait(0.2/(this.itemWidth + this.off)) + end this.SortItemList() - coroutine.wait(0.01) this:LeftAction() this.mask:SetActive(false) - this.AddTrigger() + this.AddTrigger() end) end) Util.AddClick(this.rightBtn, function() + local localIsenter = false this.mask:SetActive(true) this.RemoveTrigger() self.thread = coroutine.start(function() - coroutine.wait(0.01) this.MoveTo(2) - coroutine.wait(0.25) + --coroutine.wait(0.2/(this.itemWidth + this.off)) + while(not localIsenter) do + local isfinish = true + for j = 1,#this.itemList do + if this.itemList[j].move then + isfinish = false + break + end + end + if isfinish then + localIsenter = true + end + coroutine.wait(0.2/(this.itemWidth + this.off)) + end this.SortItemList() - coroutine.wait(0.01) this:RightAction() this.mask:SetActive(false) this.AddTrigger() + coroutine.yield() end) end) @@ -361,6 +379,7 @@ function this:RefreshTabData() else if not this.itemList[i] then this.itemList[i] = {} + this.itemList[i].move = false this.itemList[i].go = newObjToParent(this.item,this.grid) this.itemList[i].go.name = "tab_"..i this.itemList[i].tran = this.itemList[i].go:GetComponent("RectTransform") @@ -368,7 +387,6 @@ function this:RefreshTabData() vec.x = this.off * (i - 2) + (i - 1) * this.itemWidth - 30 vec.y = 50 this.itemList[i].tran.anchoredPosition = vec - --LogGreen("vec:"..i.." "..tostring(vec)) this.itemList[i].pos = this.itemList[i].tran.anchoredPosition this.itemList[i].index = i this.itemList[i].img = Util.GetGameObject(this.itemList[i].go, "img"):GetComponent("Image") @@ -382,7 +400,6 @@ function this:RefreshTabData() end end this.pos4 = Vector3.New(this.off * (#this.itemList - 1) + (#this.itemList) * this.itemWidth - 30,50,0) - --LogGreen("this.pos4:"..tostring(this.pos4)) end function this:SetIndex() @@ -408,14 +425,24 @@ function this:SetIndex() if localIsenter then localIsenter = false this.MoveTo(LOY) - coroutine.wait(0.25) - offSet = offSet - 1 - this.SortItemList() - coroutine.wait(0.01) - localIsenter = true + --coroutine.wait(0.2/(this.itemWidth + this.off)) + while(not localIsenter) do + local isfinish = true + for j = 1,#this.itemList do + if this.itemList[j].move then + isfinish = false + break + end + end + if isfinish then + offSet = offSet - 1 + this.SortItemList() + localIsenter = true + end + coroutine.wait(0.2/(this.itemWidth + this.off)) + end end - coroutine.wait(0.01) - end + end this:RefreshJianTou() this.AddTrigger() this:PageOnChange(true)