105 lines
3.6 KiB
Lua
105 lines
3.6 KiB
Lua
|
require("Base/BasePanel")
|
||
|
local WorldArenaMyTeamPanel = Inherit(BasePanel)
|
||
|
|
||
|
local function OnBeginDrag(self, Pointgo, data)
|
||
|
self.oldGrid = Pointgo.transform.parent.parent
|
||
|
self.tempInfo.transform.localPosition = Pointgo.transform.parent.parent.localPosition
|
||
|
Pointgo.transform.parent:SetParent(self.tempInfo.transform)
|
||
|
Pointgo.transform.parent.localPosition = Vector3.zero
|
||
|
end
|
||
|
local function OnDrag(self, Pointgo, data)
|
||
|
local pos = self.tempInfo.transform.localPosition
|
||
|
local y = pos.y + data.delta.y >= -300 and pos.y + data.delta.y or -300
|
||
|
y = y <= 500 and y or 500
|
||
|
self.tempInfo.transform.localPosition = Vector2.New(pos.x , y)
|
||
|
end
|
||
|
local function OnEndDrag(self, Pointgo, data)
|
||
|
Pointgo.transform.parent.localPosition = Vector3.zero
|
||
|
local num = 99999
|
||
|
local obj = nil
|
||
|
for i = 1, 3 do
|
||
|
local dis = math.abs( self.tempInfo.transform.localPosition.y - self.gridList[i].transform.localPosition.y )
|
||
|
if dis <= num then
|
||
|
num = dis
|
||
|
obj = self.gridList[i]
|
||
|
end
|
||
|
end
|
||
|
if obj.transform.childCount > 0 then
|
||
|
local targetInfo = obj.transform:GetChild(0)
|
||
|
targetInfo:SetParent(self.oldGrid.transform)
|
||
|
targetInfo.localPosition = Vector3.zero
|
||
|
else
|
||
|
obj = self.oldGrid
|
||
|
end
|
||
|
local curInfo = self.tempInfo.transform:GetChild(0)
|
||
|
curInfo:SetParent(obj.transform)
|
||
|
curInfo.localPosition = Vector3.zero
|
||
|
end
|
||
|
|
||
|
function WorldArenaMyTeamPanel:InitComponent()
|
||
|
self.spLoader = SpriteLoader.New()
|
||
|
self.btnBack = Util.GetGameObject(self.gameObject, "Frame/BackBtn")
|
||
|
self.mask = Util.GetGameObject(self.gameObject, "mask")
|
||
|
self.Content = Util.GetGameObject(self.gameObject, "Frame/Content")
|
||
|
self.OnBeginDrag = function(p,d) OnBeginDrag(self,p,d) end
|
||
|
self.OnDrag= function(p,d) OnDrag(self,p,d) end
|
||
|
self.OnEndDrag= function(p,d) OnEndDrag(self,p,d) end
|
||
|
self.tempInfo = Util.GetGameObject(self.Content, "tempInfo")
|
||
|
|
||
|
self.InfoList = {}
|
||
|
self.dragViewList = {}
|
||
|
self.triggerList = {}
|
||
|
self.gridList = {}
|
||
|
for i = 1, 3 do
|
||
|
self.gridList[i] = Util.GetGameObject(self.Content, "Grid ("..i..")")
|
||
|
self.InfoList[i] = Util.GetGameObject(self.Content, "Grid ("..i..")/Info")
|
||
|
self.dragViewList[i] = SubUIManager.Open(SubUIConfig.DragView, self.InfoList[i].transform)
|
||
|
self.dragViewList[i].transform:SetSiblingIndex(1)
|
||
|
self.triggerList[i]=Util.GetEventTriggerListener(self.dragViewList[i].gameObject)
|
||
|
self.triggerList[i].onBeginDrag = self.triggerList[i].onBeginDrag + self.OnBeginDrag
|
||
|
self.triggerList[i].onDrag = self.triggerList[i].onDrag + self.OnDrag
|
||
|
self.triggerList[i].onEndDrag = self.triggerList[i].onEndDrag + self.OnEndDrag
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
--绑定事件(用于子类重写)
|
||
|
function WorldArenaMyTeamPanel:BindEvent()
|
||
|
Util.AddClick(self.mask, function()
|
||
|
self:ClosePanel()
|
||
|
end)
|
||
|
Util.AddClick(self.btnBack, function()
|
||
|
self:ClosePanel()
|
||
|
end)
|
||
|
end
|
||
|
--添加事件监听(用于子类重写)
|
||
|
function WorldArenaMyTeamPanel:AddListener()
|
||
|
end
|
||
|
|
||
|
--移除事件监听(用于子类重写)
|
||
|
function WorldArenaMyTeamPanel:RemoveListener()
|
||
|
end
|
||
|
|
||
|
--界面打开时调用(用于子类重写)
|
||
|
function WorldArenaMyTeamPanel:OnOpen(_playerId)
|
||
|
self.playerId = _playerId
|
||
|
end
|
||
|
|
||
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
|
function WorldArenaMyTeamPanel:OnShow()
|
||
|
WorldArenaMyTeamPanel:Refresh()
|
||
|
end
|
||
|
|
||
|
function WorldArenaMyTeamPanel:Refresh()
|
||
|
end
|
||
|
|
||
|
|
||
|
function WorldArenaMyTeamPanel:OnClose()
|
||
|
end
|
||
|
|
||
|
--界面销毁时调用(用于子类重写)
|
||
|
function WorldArenaMyTeamPanel:OnDestroy()
|
||
|
self.spLoader:Destroy()
|
||
|
end
|
||
|
|
||
|
return WorldArenaMyTeamPanel
|