249 lines
11 KiB
Lua
249 lines
11 KiB
Lua
require("Base/BasePanel")
|
|
local GodsWayMyTeamPanel = Inherit(BasePanel)
|
|
local endLessConfig = ConfigManager.GetConfig(ConfigName.EndlessHeroProp)
|
|
local teamIds = {
|
|
[1] = { 3206, 3207 },
|
|
[2] = { 3203, 3204, 3205 },
|
|
[3] = { 3301, 3302, 3303 },
|
|
}
|
|
local curIds = nil
|
|
local function OnBeginDrag(self, Pointgo, data, index)
|
|
self.chooseIndex = index
|
|
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, index)
|
|
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, index)
|
|
Pointgo.transform.parent.localPosition = Vector3.zero
|
|
local num = 99999
|
|
local obj = nil
|
|
local finalIndex = nil
|
|
for i = 1, #curIds 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]
|
|
finalIndex = i
|
|
end
|
|
end
|
|
obj = self.oldGrid
|
|
local curInfo = self.tempInfo.transform:GetChild(0)
|
|
curInfo:SetParent(obj.transform)
|
|
curInfo.localPosition = Vector3.zero
|
|
|
|
if self.chooseIndex ~= finalIndex then
|
|
-- 交换编队数据
|
|
local tempFormation = self.curFormation[curIds[self.chooseIndex]]
|
|
self.curFormation[curIds[self.chooseIndex]] = self.curFormation[curIds[finalIndex]]
|
|
self.curFormation[curIds[finalIndex]] = tempFormation
|
|
-- 保存
|
|
for i = 1, #curIds do
|
|
local heros = {}
|
|
for _, hero in ipairs(self.curFormation[curIds[i]].teamHeroInfos) do
|
|
table.insert(heros, { heroId = hero.heroId, position = hero.position })
|
|
end
|
|
FormationManager.SaveFormation(curIds[i], heros,
|
|
FormationManager.formationList[curIds[1]].teamPokemonInfos)
|
|
end
|
|
-- 刷新显示
|
|
GodsWayMyTeamPanel:Refresh(false)
|
|
end
|
|
end
|
|
|
|
function GodsWayMyTeamPanel:InitComponent()
|
|
LogError("222222222222222")
|
|
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")
|
|
Util.GetGameObject(self.gameObject, "Frame/title"):GetComponent("Text").text = Language[12996]
|
|
self.tempInfo = Util.GetGameObject(self.Content, "tempInfo")
|
|
self.tipTxt = Util.GetGameObject(self.gameObject, "Frame/Text"):GetComponent("Text")
|
|
self.tipTxt.text = Language[12997]
|
|
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 + function(p, d) OnBeginDrag(self, p, d, i) end
|
|
self.triggerList[i].onDrag = self.triggerList[i].onDrag + function(p, d) OnDrag(self, p, d, i) end
|
|
self.triggerList[i].onEndDrag = self.triggerList[i].onEndDrag + function(p, d) OnEndDrag(self, p, d, i) end
|
|
self.gridList[i]:SetActive(false)
|
|
end
|
|
self.Heros = {}
|
|
for i = 1, 3 do
|
|
self.Heros[i] = {}
|
|
for j = 1, 6 do
|
|
self.Heros[i][j] = {}
|
|
self.Heros[i][j].go = Util.GetGameObject(self.Content, "Grid (" .. i .. ")/Info/TeamList/heroPro (" .. j ..
|
|
")")
|
|
|
|
self.Heros[i][j].frame = Util.GetGameObject(self.Heros[i][j].go, "frame"):GetComponent("Image")
|
|
self.Heros[i][j].pos = Util.GetGameObject(self.Heros[i][j].go, "pos"):GetComponent("Image")
|
|
self.Heros[i][j].hero = Util.GetGameObject(self.Heros[i][j].go, "hero")
|
|
self.Heros[i][j].starGrid = Util.GetGameObject(self.Heros[i][j].hero, "starGrid")
|
|
self.Heros[i][j].proIcon = Util.GetGameObject(self.Heros[i][j].hero, "proIcon"):GetComponent("Image")
|
|
self.Heros[i][j].levelText = Util.GetGameObject(self.Heros[i][j].hero, "lvbg/levelText"):GetComponent("Text")
|
|
self.Heros[i][j].icon = Util.GetGameObject(self.Heros[i][j].hero, "icon"):GetComponent("Image")
|
|
end
|
|
end
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function GodsWayMyTeamPanel:BindEvent()
|
|
Util.AddClick(self.mask, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(self.btnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function GodsWayMyTeamPanel:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function GodsWayMyTeamPanel:RemoveListener()
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function GodsWayMyTeamPanel:OnOpen(_type)
|
|
LogError("11111111111111111" .. _type)
|
|
if _type == 3 then
|
|
Util.GetGameObject(self.gameObject, "Frame/title"):GetComponent("Text").text = "主角神塔"
|
|
else
|
|
Util.GetGameObject(self.gameObject, "Frame/title"):GetComponent("Text").text = Language[12996]
|
|
end
|
|
self.type = _type
|
|
curIds = teamIds[_type]
|
|
for i = 1, #curIds do
|
|
self.gridList[i]:SetActive(true)
|
|
end
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function GodsWayMyTeamPanel:OnShow()
|
|
GodsWayMyTeamPanel:Refresh(true)
|
|
end
|
|
|
|
function GodsWayMyTeamPanel:Refresh(isReGet)
|
|
-- NetManager.GetPlayerCrossYxldOneTeamInfoRequest(PlayerManager.uid,0,function(msg)
|
|
-- for i = 1, 3 do
|
|
-- WorldArenaMyTeamPanel:SetSingleFormation(self.InfoList[i],msg.teamInfo.crossTeam[1],i)
|
|
-- end
|
|
-- end
|
|
if isReGet then
|
|
self.curFormation = {}
|
|
for i = 1, #curIds do
|
|
LogError("curids id=====" .. curIds[i])
|
|
local team = FormationManager.GetFormationByID(curIds[i])
|
|
local cTeam = FormationManager.MakeAEmptyTeam(curIds[i])
|
|
for j = 1, #team.teamHeroInfos do
|
|
table.insert(cTeam.teamHeroInfos, team.teamHeroInfos[j])
|
|
end
|
|
self.curFormation[curIds[i]] = cTeam
|
|
GodsWayMyTeamPanel:SetSingleFormation(self.InfoList[i], cTeam.teamHeroInfos, i)
|
|
end
|
|
else
|
|
for i = 1, #curIds do
|
|
GodsWayMyTeamPanel:SetSingleFormation(self.InfoList[i], self.curFormation[curIds[i]].teamHeroInfos, i)
|
|
end
|
|
end
|
|
end
|
|
|
|
function GodsWayMyTeamPanel: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(Language[12998], NumToChinese[index])
|
|
--
|
|
Util.AddOnceClick(btnChange, function()
|
|
local formation = 0
|
|
if self.type == 1 then
|
|
formation = FORMATION_TYPE.GodsWayTower_two
|
|
elseif self.type == 2 then
|
|
formation = FORMATION_TYPE.GodsWayTower_three
|
|
else
|
|
formation = FORMATION_TYPE.BecomeAGod
|
|
end
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, formation, index, curIds, formation)
|
|
end)
|
|
|
|
for i, demon in ipairs(self.Heros[index]) do
|
|
demon.frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(1))
|
|
demon.pos.sprite = self.spLoader:LoadSprite("bd_xinkapaifan" .. i)
|
|
demon.hero:SetActive(false)
|
|
end
|
|
local allPower = 0
|
|
--队伍阵容
|
|
for i, hero in pairs(data) do
|
|
local heroTid = data[i].heroId
|
|
if heroTid then
|
|
local heroData = HeroManager.GetSingleHeroData(heroTid)
|
|
self.Heros[index][hero.position].hero:SetActive(true)
|
|
local star, starType = heroData.GetStar(1)
|
|
|
|
local starScale = -15
|
|
local starSize = Vector2.New(32, 32)
|
|
if starType == 3 then
|
|
starScale = -16
|
|
starSize = Vector2.New(0.8, -15)
|
|
elseif starType == 2 then
|
|
starSize = Vector2.New(48, 48)
|
|
end
|
|
SetHeroStars(self.spLoader, self.Heros[index][hero.position].starGrid, star, nil, nil, -10)
|
|
Util.SetParticleSortLayer(self.Heros[index][hero.position].starGrid, self.sortingOrder + 1)
|
|
SetHeroFlyEffect(self.Heros[index][hero.position].hero, self.spLoader, star, self.sortingOrder + 1, 0.9, 2)
|
|
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroData.id)
|
|
allPower = allPower + heroData.warPower
|
|
self.Heros[index][hero.position].proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData
|
|
.changeProId))
|
|
self.Heros[index][hero.position].levelText.text = heroData.lv
|
|
self.Heros[index][hero.position].frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(
|
|
heroConfig.Quality, star))
|
|
SetHeroIcon(self.spLoader, heroData, self.Heros[index][hero.position].icon, heroConfig)
|
|
local heroData = {}
|
|
Util.AddOnceClick(self.Heros[index][hero.position].icon.gameObject, function()
|
|
local heroData = HeroManager.GetSingleHeroData(hero.heroId)
|
|
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData, false)
|
|
-- NetManager.ViewHeroInfoRequest(PlayerManager.uid,heroTid,PlayerManager.serverInfo.name,2000+index,function(msg)
|
|
|
|
-- heroData= GoodFriendManager.GetHeroDatas(msg.hero,msg.force,msg.SpecialEffects,msg.guildSkill)
|
|
-- GoodFriendManager.InitEquipData(msg.equip,heroData)--HeroManager.GetSingleHeroData(heroData.dynamicId)
|
|
-- UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true)
|
|
-- end)
|
|
end)
|
|
end
|
|
end
|
|
warPower.text = FormationManager.GetFormationPower(curIds[index])
|
|
end
|
|
|
|
function GodsWayMyTeamPanel:OnClose()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function GodsWayMyTeamPanel:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
self.InfoList = {}
|
|
self.dragViewList = {}
|
|
self.triggerList = {}
|
|
self.gridList = {}
|
|
self.Heros = {}
|
|
end
|
|
|
|
return GodsWayMyTeamPanel
|