2020-08-25 15:46:38 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
FormationEditPopup = Inherit(BasePanel)
|
|
|
|
|
local this = FormationEditPopup
|
|
|
|
|
|
|
|
|
|
local chooseIndex=0
|
|
|
|
|
local choosedList={}
|
|
|
|
|
local deleteList={}
|
|
|
|
|
local curFormationIndex
|
|
|
|
|
local order=0
|
|
|
|
|
-- local orderImageTextList={}
|
|
|
|
|
-- 妖灵师等级限制显示
|
|
|
|
|
local _LimitLevel = 0
|
|
|
|
|
local _LimitNum = 0
|
|
|
|
|
local _BloodList = nil
|
|
|
|
|
|
|
|
|
|
-- local curFormation
|
|
|
|
|
local sortType = 1 -- 1:品阶 2:等级
|
2023-05-08 11:21:53 +08:00
|
|
|
|
local proId=0--0 全部 1 火 2风 3 水 4 地 5时空
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local tabs = {}--筛选按钮
|
|
|
|
|
local maxNum =5 --最大上阵人数
|
|
|
|
|
local goList={} --当前英雄对应预设的集合
|
|
|
|
|
local func=nil --回调
|
|
|
|
|
|
2020-08-26 15:14:27 +08:00
|
|
|
|
local healHero = {}--需要忽略的神将id
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function FormationEditPopup:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2021-10-22 14:22:12 +08:00
|
|
|
|
this.mask = Util.GetGameObject(this.gameObject, "BgMask")
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.BtnBack = Util.GetGameObject(this.gameObject, "bg/btnBack")
|
|
|
|
|
this.BtnSure = Util.GetGameObject(this.gameObject, "bg/btnSure")
|
|
|
|
|
this.allBtn=Util.GetGameObject(this.gameObject,"bg/allBtn")
|
|
|
|
|
|
|
|
|
|
this.cardPre = Util.GetGameObject(this.gameObject, "item")
|
|
|
|
|
this.grid = Util.GetGameObject(this.gameObject, "bg/scroll")
|
|
|
|
|
this.desc=Util.GetGameObject(this.gameObject,"bg/desc"):GetComponent("Text")
|
2022-01-20 15:06:04 +08:00
|
|
|
|
local particles=this.cardPre:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--筛选按钮
|
2023-05-08 11:21:53 +08:00
|
|
|
|
for i = 0, 5 do
|
2020-06-03 19:09:01 +08:00
|
|
|
|
tabs[i] = Util.GetGameObject(this.gameObject, "bg/Tabs/Grid/Btn" .. i)
|
|
|
|
|
end
|
|
|
|
|
this.selectBtn = Util.GetGameObject(this.gameObject, "bg/Tabs/SelectBtn")
|
|
|
|
|
|
|
|
|
|
this.ShaiXuanBtn = Util.GetGameObject(self.gameObject, "bg/ShaiXuanBtn")
|
|
|
|
|
this.ShaiXuanBtnLv = Util.GetGameObject(self.gameObject, "bg/ShaiXuanBtn/Lv")
|
|
|
|
|
this.ShaiXuanBtnQu = Util.GetGameObject(self.gameObject, "bg/ShaiXuanBtn/Qu")
|
|
|
|
|
|
|
|
|
|
this.ScrollBar = Util.GetGameObject(self.gameObject, "bg/Scrollbar"):GetComponent("Scrollbar")
|
|
|
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "scroll").transform,
|
|
|
|
|
this.cardPre, this.ScrollBar, Vector2.New(927.5, 927), 1, 5, Vector2.New(19.32, 40))
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
|
|
|
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
this.ScrollView.moveTween.Strength = 1
|
|
|
|
|
-- this.isHaveInTeam = false
|
2020-08-26 15:14:27 +08:00
|
|
|
|
healHero = string.split(ConfigManager.GetConfigDataByKey(ConfigName.SpecialConfig,"Id",86).Value,"|")
|
|
|
|
|
end
|
|
|
|
|
--是否是治疗神将
|
|
|
|
|
function FormationEditPopup:isNotHealHero(hero)
|
|
|
|
|
for i = 1, #healHero do
|
|
|
|
|
if hero.id == tonumber(healHero[i]) then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return true
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FormationEditPopup:BindEvent()
|
|
|
|
|
Util.AddClick(this.BtnBack, function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
2021-10-22 14:22:12 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out,0)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.mask, function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
2020-08-18 16:36:24 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out,0)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--选定按钮
|
|
|
|
|
Util.AddClick(this.BtnSure, function()
|
|
|
|
|
local go=function()
|
2021-04-15 12:26:47 +08:00
|
|
|
|
local heros={}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for i, v in ipairs(choosedList) do
|
2021-04-17 17:12:24 +08:00
|
|
|
|
local hero = {}
|
|
|
|
|
hero.heroId = v.did
|
|
|
|
|
hero.position = #choosedList + 1
|
|
|
|
|
table.insert(heros,hero)
|
|
|
|
|
end
|
|
|
|
|
table.sort(heros,function (a,b)
|
|
|
|
|
return HeroManager.GetSingleHeroData(a.heroId).warPower > HeroManager.GetSingleHeroData(b.heroId).warPower
|
|
|
|
|
end)
|
|
|
|
|
for i = 1, #heros do
|
|
|
|
|
heros[i].position = i
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
2020-07-29 21:08:41 +08:00
|
|
|
|
if #choosedList <= maxNum and #choosedList > 0 then
|
2021-04-15 12:26:47 +08:00
|
|
|
|
NetManager.TrialHeroInfoSaveRequest(heros,function(msg)
|
2021-04-09 12:26:35 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10670])
|
2021-04-17 17:12:24 +08:00
|
|
|
|
local heros = msg.heroes
|
|
|
|
|
if heros and #heros > 1 then
|
|
|
|
|
table.sort(heros,function (a,b)
|
|
|
|
|
return a.position < b.position
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
MapManager.trialHeroInfo = heros
|
2020-12-28 15:19:46 +08:00
|
|
|
|
if func~=nil then --保存完毕后 将英雄did合集传递过去 此时我拥有这些英雄 不用担心英雄已被删除
|
2021-04-15 12:26:47 +08:00
|
|
|
|
func(heros)
|
2020-12-28 15:19:46 +08:00
|
|
|
|
end
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."Trial",1)--设置森罗红点关
|
|
|
|
|
CheckRedPointStatus(RedPointType.Trial)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
else
|
2021-04-09 12:26:35 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10671])
|
2020-12-28 15:19:46 +08:00
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-07-29 21:08:41 +08:00
|
|
|
|
if #choosedList < maxNum and #choosedList > 0 then
|
2021-04-09 12:26:35 +08:00
|
|
|
|
MsgPanel.ShowTwo(Language[10672], nil, function()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
go()
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
go()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--一键选择
|
|
|
|
|
Util.AddClick(this.allBtn,function()
|
|
|
|
|
for i, v in pairs(goList) do --先关闭全部选择项 清空选择列表
|
|
|
|
|
Util.GetGameObject(v, "choosed"):SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
choosedList={}
|
|
|
|
|
--按战力从大到小排序
|
|
|
|
|
local heros = {}
|
|
|
|
|
if proId == ProIdConst.All then
|
|
|
|
|
heros = HeroManager.GetAllHeroDatas(_LimitLevel)
|
|
|
|
|
else
|
|
|
|
|
heros = HeroManager.GetHeroDataByProperty(proId, _LimitLevel)
|
|
|
|
|
end
|
|
|
|
|
table.sort(heros,function(a,b)
|
2021-01-22 16:53:50 +08:00
|
|
|
|
local aWarPower = HeroPowerManager.GetHeroPower(a.dynamicId)
|
|
|
|
|
local bWarPower = HeroPowerManager.GetHeroPower(b.dynamicId)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if aWarPower==bWarPower then
|
|
|
|
|
return a.id>b.id
|
|
|
|
|
else
|
|
|
|
|
return aWarPower>bWarPower
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
--将战力前5英雄选中赋值
|
2020-08-26 15:14:27 +08:00
|
|
|
|
for index, value in ipairs(heros) do
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local go
|
2020-08-26 15:14:27 +08:00
|
|
|
|
local isNotHeal = self:isNotHealHero(heros[index])
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for k, v in pairs(goList) do
|
2020-08-26 15:14:27 +08:00
|
|
|
|
if k and heros[index] and k==heros[index].dynamicId and isNotHeal then --goList的键值是英雄did 若它与当前英雄列表中的did相等
|
2020-06-03 19:09:01 +08:00
|
|
|
|
go=Util.GetGameObject(v, "choosed")
|
|
|
|
|
go.gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
order=order+1
|
2020-08-26 15:14:27 +08:00
|
|
|
|
if heros[index] and isNotHeal then --若存在该索引 就插入数据(当我筛选某一元素时,该元素英雄长度可能不为5)
|
|
|
|
|
table.insert(choosedList,{did = heros[index].dynamicId, choosed = go,position=order})
|
|
|
|
|
end
|
|
|
|
|
if #choosedList == 5 then
|
|
|
|
|
break
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
this.RefreshDesc()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
--筛选按钮
|
2023-05-08 11:21:53 +08:00
|
|
|
|
for i = 0, 5 do
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Util.AddClick(tabs[i], function()
|
|
|
|
|
if i == proId then
|
|
|
|
|
proId=ProIdConst.All
|
|
|
|
|
else
|
|
|
|
|
proId=i
|
|
|
|
|
end
|
|
|
|
|
this.OnClickTabBtn(proId)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
--品阶等级筛选
|
|
|
|
|
Util.AddClick(this.ShaiXuanBtn, function()
|
|
|
|
|
if sortType == SortTypeConst.Lv then
|
|
|
|
|
sortType = SortTypeConst.Natural
|
|
|
|
|
else
|
|
|
|
|
sortType = SortTypeConst.Lv
|
|
|
|
|
end
|
|
|
|
|
this.ShaiXuanBtnLv:SetActive(sortType ~= SortTypeConst.Lv)
|
|
|
|
|
this.ShaiXuanBtnQu:SetActive(sortType ~= SortTypeConst.Natural)
|
|
|
|
|
this.OnClickTabBtn(proId)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FormationEditPopup:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FormationEditPopup:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FormationEditPopup:OnOpen(...)
|
|
|
|
|
local args={...}
|
|
|
|
|
func=args[1]
|
|
|
|
|
choosedList ={}
|
|
|
|
|
order = 0--#curFormation.teamHeroInfos
|
|
|
|
|
sortType = SortTypeConst.Lv
|
|
|
|
|
proId = ProIdConst.All
|
|
|
|
|
this.OnClickTabBtn(proId)
|
|
|
|
|
this.ShaiXuanBtnLv:SetActive(sortType ~= SortTypeConst.Lv)
|
|
|
|
|
this.ShaiXuanBtnQu:SetActive(sortType ~= SortTypeConst.Natural)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function FormationEditPopup:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2021-11-05 10:18:10 +08:00
|
|
|
|
function FormationEditPopup:OnSortingOrderChange()
|
|
|
|
|
this.ScrollView:ForeachItemGO(function(index, go)
|
|
|
|
|
Util.SetParticleSortLayer(go,this.sortingOrder + 1)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
function FormationEditPopup:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.ScrollView = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--点击页签__根据sortType和职业属性/类型进行排序
|
|
|
|
|
function this.OnClickTabBtn(_proId)
|
|
|
|
|
local heros
|
|
|
|
|
this.selectBtn:SetActive(proId ==_proId)
|
|
|
|
|
this.selectBtn.transform:SetParent(tabs[_proId].transform)
|
|
|
|
|
this.selectBtn.transform:DOAnchorPos(Vector3.zero,0)
|
|
|
|
|
this.selectBtn.transform:DOScale(Vector3.one,0)
|
|
|
|
|
if _proId == ProIdConst.All then
|
|
|
|
|
heros = HeroManager.GetAllHeroDatas(_LimitLevel)
|
|
|
|
|
else
|
|
|
|
|
heros = HeroManager.GetHeroDataByProperty(_proId, _LimitLevel)
|
|
|
|
|
end
|
|
|
|
|
this.SetRoleList(heros)
|
|
|
|
|
this.RefreshDesc()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--设置英雄列表数据
|
|
|
|
|
function this.SetRoleList(_roleDatas)
|
|
|
|
|
this:SortHeroDatas(_roleDatas)
|
|
|
|
|
goList={}
|
|
|
|
|
this.ScrollView:SetData(_roleDatas, function(index, go)
|
|
|
|
|
this.SingleHeroDataShow(go, _roleDatas[index])
|
|
|
|
|
end)
|
|
|
|
|
end
|
2021-11-05 10:18:10 +08:00
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
--设置单个英雄数据
|
|
|
|
|
function this.SingleHeroDataShow(_go, _heroData)
|
|
|
|
|
local heroData = _heroData
|
|
|
|
|
local go = _go
|
|
|
|
|
goList[heroData.dynamicId]=go
|
|
|
|
|
local choosed = Util.GetGameObject(go, "choosed")
|
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
for i,v in ipairs(choosedList) do
|
|
|
|
|
if(heroData.dynamicId==v.did) then
|
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-21 13:12:04 +08:00
|
|
|
|
Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
|
|
|
|
|
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.icon)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
Util.GetGameObject(go, "lv/Text"):GetComponent("Text").text = heroData.lv
|
2021-04-21 13:12:04 +08:00
|
|
|
|
Util.GetGameObject(go, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.icon)
|
2022-03-28 18:18:19 +08:00
|
|
|
|
Util.GetGameObject(go, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId))
|
2020-06-03 19:09:01 +08:00
|
|
|
|
|
|
|
|
|
--剩余血量 无尽副本才显示
|
|
|
|
|
local hpExp = Util.GetGameObject(go, "hpExp")
|
|
|
|
|
local heroHp = FormationManager.GetFormationHeroHp(curFormationIndex, heroData.dynamicId)
|
|
|
|
|
local starGrid = Util.GetGameObject(go, "star")
|
|
|
|
|
local starPre = Util.GetGameObject(go, "starPre")
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local star,starType = heroData.GetStar(1)
|
|
|
|
|
SetHeroStars(this.spLoader, starGrid, star,starType)
|
2022-01-20 15:06:04 +08:00
|
|
|
|
local effect=SetHeroFlyEffect(Util.GetGameObject(go, "GameObject"),this.spLoader,heroData.star,this.sortingOrder + 1,1,3)
|
|
|
|
|
if effect then
|
|
|
|
|
local particles=effect:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
|
|
|
|
|
for key, value in pairs(particles:ToTable()) do
|
|
|
|
|
local mat=value:GetComponent(typeof(UnityEngine.Renderer))
|
|
|
|
|
if mat.material.shader.name=="YXZ/Effect/Mix Masking(Without Moving)_alphablend" then
|
|
|
|
|
mat.material.shader=poolManager:LoadAsset("YXZ_MixMaskingWithoutMoving_alphablend_1",poolManager.AssetType.Other)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local meshs1=starGrid:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
|
|
|
|
|
for key, value in pairs(meshs1:ToTable()) do
|
|
|
|
|
local mat=value:GetComponent(typeof(UnityEngine.Renderer))
|
|
|
|
|
if mat.material.shader.name=="UI Particles/Additive" then
|
|
|
|
|
mat.material.shader=poolManager:LoadAsset("UI-Particle-Add_1",poolManager.AssetType.Other)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-05 10:18:10 +08:00
|
|
|
|
Util.SetParticleSortLayer(starGrid,this.sortingOrder + 1)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
this.SetHeroBlood(hpExp, heroHp, go)
|
|
|
|
|
-- Click On
|
|
|
|
|
Util.AddOnceClick(go, function()
|
2023-05-08 11:21:53 +08:00
|
|
|
|
-- if heroData.changeProId==5 then
|
|
|
|
|
-- PopupTipPanel.ShowTip("神系必须转换其他阵营才能上阵")
|
|
|
|
|
-- return
|
|
|
|
|
-- end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
for k, v in ipairs(choosedList) do
|
|
|
|
|
if v.did == heroData.dynamicId then
|
|
|
|
|
--选择的条目已存在,移除选择的item
|
|
|
|
|
choosed:SetActive(false)
|
|
|
|
|
table.remove(choosedList,k)
|
|
|
|
|
order=order-1
|
|
|
|
|
chooseIndex=v.position
|
|
|
|
|
for i,v in ipairs(choosedList) do
|
|
|
|
|
if(choosedList[i].position>chooseIndex) then
|
|
|
|
|
choosedList[i].position=v.position-1
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-11 14:28:44 +08:00
|
|
|
|
this.RefreshDesc()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- 当前可选的最大上阵人数
|
|
|
|
|
if #choosedList >= maxNum then
|
2021-04-09 12:26:35 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[10673])
|
2020-06-03 19:09:01 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 判断是否有血量
|
2021-04-09 12:26:35 +08:00
|
|
|
|
if heroHp and heroHp <= 0 then PopupTipPanel.ShowTip(Language[10674]) return end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
choosed:SetActive(true)
|
|
|
|
|
order=order+1
|
|
|
|
|
table.insert(choosedList, {did = heroData.dynamicId, choosed = choosed, position=order})
|
|
|
|
|
choosedList[heroData.dynamicId] = choosed
|
2021-03-11 14:28:44 +08:00
|
|
|
|
this.RefreshDesc()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddLongPressClick(go, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
|
|
|
|
|
end, 0.5)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新描述信息
|
|
|
|
|
function this.RefreshDesc()
|
2021-04-09 12:26:35 +08:00
|
|
|
|
this.desc.text=string.format(Language[10675],maxNum,#choosedList,maxNum)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 设置妖灵师血量
|
|
|
|
|
function this.SetHeroBlood(hpExp, heroHp, go)
|
|
|
|
|
if heroHp then
|
|
|
|
|
hpExp:SetActive(true)
|
|
|
|
|
hpExp:GetComponent("Slider").value = heroHp
|
|
|
|
|
Util.SetGray(go, heroHp <= 0)
|
|
|
|
|
else
|
|
|
|
|
hpExp:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:SortHeroDatas(_heroDatas)
|
|
|
|
|
local choosed = {}
|
|
|
|
|
local dieHeros = {}
|
|
|
|
|
-- local curFormation = FormationManager.GetFormationByID(curFormationIndex)
|
|
|
|
|
for i = 1, #_heroDatas do
|
|
|
|
|
local heroHp = FormationManager.GetFormationHeroHp(curFormationIndex, _heroDatas[i].dynamicId)
|
|
|
|
|
if heroHp then
|
|
|
|
|
if heroHp <= 0 then
|
|
|
|
|
dieHeros[_heroDatas[i].dynamicId] = _heroDatas[i].dynamicId
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- for j = 1, #curFormation.teamHeroInfos do
|
|
|
|
|
-- local teamInfo = curFormation.teamHeroInfos[j]
|
|
|
|
|
-- choosed[teamInfo.heroId] = j
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
table.sort(_heroDatas, function(a, b)
|
|
|
|
|
if (choosed[a.dynamicId] and choosed[b.dynamicId]) or
|
|
|
|
|
(not choosed[a.dynamicId] and not choosed[b.dynamicId])
|
|
|
|
|
then
|
|
|
|
|
if (dieHeros[a.dynamicId] and dieHeros[b.dynamicId]) or
|
|
|
|
|
(not dieHeros[a.dynamicId] and not dieHeros[b.dynamicId])
|
|
|
|
|
then
|
|
|
|
|
if sortType == SortTypeConst.Natural then
|
|
|
|
|
if a.heroConfig.Natural == b.heroConfig.Natural then
|
|
|
|
|
if a.heroConfig.Quality == b.heroConfig.Quality then
|
|
|
|
|
if a.star == b.star then
|
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
if a.id == b.id then
|
|
|
|
|
return a.sortId > b.sortId
|
|
|
|
|
else
|
|
|
|
|
return a.id > b.id
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.lv > b.lv
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.star > b.star
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.heroConfig.Quality > b.heroConfig.Quality
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.heroConfig.Natural > b.heroConfig.Natural
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if a.lv == b.lv then
|
|
|
|
|
if a.heroConfig.Quality == b.heroConfig.Quality then
|
|
|
|
|
if a.star == b.star then
|
|
|
|
|
if a.heroConfig.Natural == b.heroConfig.Natural then
|
|
|
|
|
if a.id == b.id then
|
|
|
|
|
return a.sortId > b.sortId
|
|
|
|
|
else
|
|
|
|
|
return a.id > b.id
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.heroConfig.Natural > b.heroConfig.Natural
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.star > b.star
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.heroConfig.Quality > b.heroConfig.Quality
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return a.lv > b.lv
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return not dieHeros[a.dynamicId] and dieHeros[b.dynamicId]
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return choosed[a.dynamicId] and not choosed[b.dynamicId]
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.OnClickEnterHeroInfo(_curhero, _heros)
|
|
|
|
|
UIManager.OpenPanel(UIName.RoleInfoPanel, _curhero, _heros)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2021-04-21 13:12:04 +08:00
|
|
|
|
return FormationEditPopup
|
|
|
|
|
|