2021-08-25 20:31:21 +08:00
|
|
|
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
|
2021-08-26 13:42:17 +08:00
|
|
|
|
|
|
|
for i = 1, 3 do
|
|
|
|
self.InfoList[i] = Util.GetGameObject(self.Content, "Grid ("..i..")/Info")
|
|
|
|
WorldArenaMyTeamPanel:Refresh()
|
|
|
|
end
|
2021-08-25 20:31:21 +08:00
|
|
|
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
|
2021-08-26 13:42:17 +08:00
|
|
|
self.Heros = {}
|
|
|
|
for i = 1, 3 do
|
|
|
|
self.Heros[i] = {}
|
|
|
|
for j = 1, 6 do
|
|
|
|
self.Heros[i][j] = Util.GetGameObject(self.Content, "Grid ("..i..")/Info/TeamList/heroPro ("..j..")")
|
|
|
|
end
|
|
|
|
end
|
2021-08-25 20:31:21 +08:00
|
|
|
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()
|
2021-08-26 13:42:17 +08:00
|
|
|
NetManager.RequestPlayerInfo(self.playerId, PLAYER_INFO_VIEW_TYPE.NORMAL,1, function(msg)
|
|
|
|
for i = 1, 3 do
|
|
|
|
WorldArenaMyTeamPanel:SetSingleFormation(self.InfoList[i],msg.teamInfo.team,i)
|
|
|
|
end
|
|
|
|
end)
|
2021-08-25 20:31:21 +08:00
|
|
|
end
|
|
|
|
|
2021-08-26 13:42:17 +08:00
|
|
|
function WorldArenaMyTeamPanel:SetSingleFormation(go,data,index)
|
|
|
|
local title = Util.GetGameObject(go,"Title"):GetComponent("Text")
|
|
|
|
local warPower = Util.GetGameObject(go,"WarPower/Text"):GetComponent("Text")
|
|
|
|
local btnChange = Util.GetGameObject(go,"ChangeTeam")
|
|
|
|
local teamList = Util.GetGameObject(go,"TeamList")
|
|
|
|
title.text = string.format( "第%s队",NumToChinese[index])
|
|
|
|
warPower.text = data.totalForce
|
|
|
|
Util.AddOnceClick(btnChange,function ()
|
|
|
|
PopupTipPanel.ShowTip(string.format( "进入第%s个编队",index))
|
|
|
|
end)
|
|
|
|
|
|
|
|
for i, demon in ipairs(self.Heros[index]) do
|
|
|
|
Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(1))
|
|
|
|
Util.GetGameObject(demon, "hero"):SetActive(false)
|
|
|
|
end
|
|
|
|
--队伍阵容
|
|
|
|
for i, hero in ipairs(data.team) do
|
|
|
|
local heroTid = data.team[i].heroTid
|
|
|
|
if heroTid then
|
|
|
|
local heroGo = Util.GetGameObject(self.Heros[index][hero.position], "hero")
|
|
|
|
heroGo:SetActive(true)
|
|
|
|
SetHeroStars(self.spLoader, Util.GetGameObject(heroGo, "starGrid"), hero.star)
|
|
|
|
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroTid)
|
|
|
|
Util.GetGameObject(heroGo, "proIcon"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
|
|
|
|
Util.GetGameObject(heroGo, "lvbg/levelText"):GetComponent("Text").text = hero.level
|
|
|
|
Util.GetGameObject(self.Heros[index][hero.position], "frame"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality, hero.star))
|
|
|
|
SetHeroIcon(self.spLoader, hero,Util.GetGameObject(heroGo, "icon"):GetComponent("Image"),heroConfig)
|
|
|
|
local frameBtn = Util.GetGameObject(self.Heros[index][hero.position], "frame")
|
|
|
|
local heroData = {}
|
|
|
|
Util.AddOnceClick(frameBtn, function()
|
|
|
|
NetManager.ViewHeroInfoRequest(self.playerId,hero.heroid,1,PLAYER_INFO_VIEW_TYPE.NORMAL,function(msg)
|
|
|
|
if not hero.heroid then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
heroData= GoodFriendManager.GetHeroDatas(msg.hero,msg.force,msg.SpecialEffects,msg.guildSkill)
|
|
|
|
GoodFriendManager.InitEquipData(msg.equip,heroData)
|
|
|
|
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2021-08-25 20:31:21 +08:00
|
|
|
|
|
|
|
function WorldArenaMyTeamPanel:OnClose()
|
|
|
|
end
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
function WorldArenaMyTeamPanel:OnDestroy()
|
|
|
|
self.spLoader:Destroy()
|
2021-08-26 13:42:17 +08:00
|
|
|
self.InfoList = {}
|
|
|
|
self.dragViewList = {}
|
|
|
|
self.triggerList = {}
|
|
|
|
self.gridList = {}
|
|
|
|
self.Heros = {}
|
2021-08-25 20:31:21 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return WorldArenaMyTeamPanel
|