255 lines
12 KiB
Lua
255 lines
12 KiB
Lua
----- 献祭 -----
|
||
local this = {}
|
||
local sortingOrder=0
|
||
local tabSortType = 0
|
||
local tarHero
|
||
local selectHeroData={}--选择的英雄list did = data
|
||
local maxSelectNum = 30--最大选择数量
|
||
function this:InitComponent(gameObject)
|
||
--上部内容
|
||
this.helpBtn=Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/HelpBtn")
|
||
this.helpPos=this.helpBtn:GetComponent("RectTransform").localPosition
|
||
--回溯按钮
|
||
this.confirmBtn=Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/ConfirmBtn")
|
||
Util.GetGameObject(this.confirmBtn,"Image"):GetComponent("Image").sprite = Util.LoadSprite("gongsonganniu_zh")
|
||
this.shopBtn=Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/shopBtn")
|
||
this.shopBtn:GetComponent("Image").sprite = Util.LoadSprite("r_shangdian_zh")
|
||
this.selectText = Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/selectNumText"):GetComponent("Text")
|
||
this.selectBtn = Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/btns/selectBtn")
|
||
this.noSelectBtn = Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/btns/noSelectBtn")
|
||
this.cardPre = Util.GetGameObject(gameObject,"item")
|
||
this.scrollbar = Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/Scrollbar"):GetComponent("Scrollbar")
|
||
this.Empty = Util.GetGameObject(gameObject,"Content/Resolve_Dismantle/Empty")
|
||
|
||
local v21 = Util.GetGameObject(gameObject, "Content/Resolve_Dismantle/ItemListRoot"):GetComponent("RectTransform").rect
|
||
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "Content/Resolve_Dismantle/ItemListRoot").transform,
|
||
this.cardPre, this.scrollbar, Vector2.New(v21.width, v21.height), 1, 5, Vector2.New(43,15))
|
||
this.ScrollView.moveTween.MomentumAmount = 1
|
||
this.ScrollView.moveTween.Strength = 1
|
||
maxSelectNum = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,54).Value)
|
||
end
|
||
|
||
function this:BindEvent()
|
||
Util.AddClick(this.helpBtn,function()
|
||
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Resolve_Dismantle,this.helpPos.x,this.helpPos.y)
|
||
end)
|
||
Util.AddClick(this.confirmBtn,function()
|
||
if tonumber(LengthOfTable(selectHeroData))==0 then
|
||
PopupTipPanel.ShowTip(Language[11736])
|
||
|
||
else
|
||
|
||
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.ResolveDismantle,
|
||
HeroManager.GetHeroReturnItems(selectHeroData,GENERAL_POPUP_TYPE.ResolveDismantle),selectHeroData)
|
||
end
|
||
end)
|
||
Util.AddClick(this.selectBtn, function()
|
||
this.QuickSelectListData(1)
|
||
if LengthOfTable(selectHeroData) > 0 then
|
||
this.noSelectBtn.gameObject:SetActive(true)
|
||
end
|
||
end)
|
||
Util.AddClick(this.noSelectBtn, function()
|
||
this.QuickSelectListData(2)
|
||
this.noSelectBtn.gameObject:SetActive(false)
|
||
end)
|
||
Util.AddClick(this.shopBtn, function()
|
||
local isActive, errorTip = ShopManager.IsActive(SHOP_TYPE.SOUL_CONTRACT_SHOP)
|
||
if not isActive then
|
||
PopupTipPanel.ShowTip(errorTip or Language[10574])
|
||
return
|
||
end
|
||
UIManager.OpenPanel(UIName.MainShopPanel, SHOP_TYPE.SOUL_CONTRACT_SHOP)
|
||
end)
|
||
end
|
||
|
||
function this:AddListener()
|
||
end
|
||
|
||
function this:RemoveListener()
|
||
end
|
||
|
||
function this:OnShow(...)
|
||
local args={...}
|
||
sortingOrder = PlayerManager.now_index or 0
|
||
this.SortTypeClick(sortingOrder,args[3],args[4])
|
||
|
||
end
|
||
|
||
--展示数据
|
||
function this.SortTypeClick(_sortType,isTop,isAni)
|
||
LogRed("isTop "..tostring(isTop).." isAni "..tostring(isAni))
|
||
tabSortType=_sortType
|
||
selectHeroData={}
|
||
tarHero=HeroManager.GetAllHeroDataMsinusUpWar(_sortType,2)
|
||
this.selectText.text = Language[11728].."0/"..maxSelectNum
|
||
this.noSelectBtn.gameObject:SetActive(false)
|
||
this.SortHeroDatas(tarHero)
|
||
this.Empty:SetActive(#tarHero <= 0)
|
||
this.ScrollView:SetData(tarHero, function (index, go)
|
||
this.SingleHeroDataShow(go, tarHero[index])
|
||
end,isTop,isAni)
|
||
-- this.ScrollView:ForeachItemGO(function(index, go)
|
||
-- Timer.New(function()
|
||
-- go.gameObject:SetActive(true)
|
||
-- PlayUIAnim(go.gameObject)
|
||
-- end, 0.001 * (index - 1)):Start()
|
||
-- end)
|
||
end
|
||
|
||
--英雄单个数据展示
|
||
function this.SingleHeroDataShow(go,_heroData)
|
||
local heroData = _heroData
|
||
local _go = go
|
||
Util.GetGameObject(_go.transform, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
|
||
Util.GetGameObject(_go.transform, "Text"):GetComponent("Text").text = SubString2(GetLanguageStrById(heroData.heroConfig.ReadingName),8)
|
||
Util.GetGameObject(_go.transform, "icon"):GetComponent("Image").sprite = Util.LoadSprite(heroData.icon)
|
||
Util.GetGameObject(_go.transform, "posIcon"):SetActive(false)--:GetComponent("Image").sprite = Util.LoadSprite(heroData.professionIcon)
|
||
Util.GetGameObject(_go.transform, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
|
||
--Util.GetGameObject(_go.transform, "heroStage"):GetComponent("Image").sprite = Util.LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage])
|
||
local starGrid = Util.GetGameObject(_go.transform, "star")
|
||
SetHeroStars(starGrid, heroData.star,1,Vector2.New(32.5,32.5),-15)
|
||
local choosed =Util.GetGameObject(_go.transform, "choosed")
|
||
local formationMask =Util.GetGameObject(_go.transform, "formationMask")
|
||
Util.GetGameObject(_go.transform, "formationMask/formationImage/upImage"):GetComponent("Image").sprite = Util.LoadSprite("t_tongyong-yishangzheng_zh")
|
||
formationMask:SetActive(heroData.isFormation ~= "" and heroData.isFormations[1] ~= FormationTypeDef.EXPEDITION)
|
||
local lockMask =Util.GetGameObject(_go.transform, "lockMask")
|
||
lockMask:SetActive(heroData.lockState == 1)
|
||
choosed:SetActive(selectHeroData[heroData.dynamicId] ~= nil)
|
||
local cardclickBtn = Util.GetGameObject(_go.transform, "icon")
|
||
this.selectText.text = Language[11728]..LengthOfTable(selectHeroData).."/"..maxSelectNum
|
||
local GongMingMask = Util.GetGameObject(_go.transform, "GongMingMask")
|
||
GongMingMask:SetActive(false)--最后检测是否共鸣
|
||
Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = "<color=#FFFFFF>"..heroData.lv.."</color>"
|
||
|
||
if heroData.lockState == 1 or (heroData.isFormation ~= "" and heroData.isFormations[1] ~= FormationTypeDef.EXPEDITION) then
|
||
else
|
||
if HarmonyManager.IsChangeColor(_heroData.dynamicId) then
|
||
Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = "<color=#0f0>"..heroData.lv.."</color>"
|
||
GongMingMask:SetActive(true)
|
||
|
||
elseif HarmonyManager:IsEnvoy(_heroData.dynamicId) and HarmonyManager:HongMengTowerUpLimit() ~= 0 then
|
||
if HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).heroTid == 0 then
|
||
-- body
|
||
Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = "<color=#ffbe22>"..heroData.lv.."</color>"
|
||
GongMingMask:SetActive(true)
|
||
end
|
||
|
||
end
|
||
end
|
||
Util.AddOnceClick(GongMingMask, function()
|
||
PopupTipPanel.ShowTip(Language[12184])
|
||
end)
|
||
Util.AddOnceClick(cardclickBtn, function()
|
||
if selectHeroData[heroData.dynamicId] then
|
||
choosed:SetActive(false)
|
||
selectHeroData[heroData.dynamicId] = nil
|
||
this.selectText.text = Language[11728]..LengthOfTable(selectHeroData).."/"..maxSelectNum
|
||
this.noSelectBtn.gameObject:SetActive(LengthOfTable(selectHeroData)>0)
|
||
return
|
||
end
|
||
if LengthOfTable(selectHeroData) >= maxSelectNum then
|
||
PopupTipPanel.ShowTip(string.format(Language[11737],maxSelectNum))
|
||
return
|
||
end
|
||
selectHeroData[heroData.dynamicId]=heroData
|
||
choosed:SetActive(true)
|
||
this.selectText.text = Language[11728]..LengthOfTable(selectHeroData).."/"..maxSelectNum
|
||
this.noSelectBtn.gameObject:SetActive(LengthOfTable(selectHeroData)>0)
|
||
end)
|
||
|
||
Util.AddOnceClick(formationMask, function()
|
||
if heroData.isFormation ~= "" then
|
||
-- 复位角色的状态
|
||
MsgPanel.ShowTwo(Language[11738]..heroData.isFormation..Language[11739], nil, function()
|
||
if heroData.isFormations[1] then
|
||
if heroData.isFormations[1] == FormationTypeDef.FORMATION_NORMAL then
|
||
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.SAVE_FORMATION)
|
||
elseif heroData.isFormations[1] == FormationTypeDef.FORMATION_ARENA_DEFEND then
|
||
JumpManager.GoJump(8001)
|
||
-- elseif heroData.isFormations[1] == FormationTypeDef.FORMATION_ENDLESS_MAP then
|
||
-- JumpManager.GoJump(57001)
|
||
elseif heroData.isFormations[1] == FormationTypeDef.ARENA_TOM_MATCH then
|
||
-- JumpManager.GoJump(57001)
|
||
UIManager.OpenPanel(UIName.ArenaTopMatchPanel)
|
||
end
|
||
end
|
||
end)
|
||
return
|
||
end
|
||
end)
|
||
Util.AddOnceClick(lockMask, function()
|
||
if heroData.lockState == 1 then
|
||
MsgPanel.ShowTwo(Language[11740], nil, function()
|
||
NetManager.HeroLockEvent(heroData.dynamicId,0,function ()
|
||
PopupTipPanel.ShowTip(Language[11741])
|
||
HeroManager.UpdateSingleHeroLockState(heroData.dynamicId,0)
|
||
lockMask:SetActive(false)
|
||
end)
|
||
end)
|
||
return
|
||
end
|
||
end)
|
||
end
|
||
--英雄排序
|
||
function this.SortHeroDatas(_heroDatas)
|
||
--上阵最优先,星级优先,同星级等级优先,同星级同等级按sortId排序。排序时降序排序。
|
||
table.sort(_heroDatas, function(a, b)
|
||
if a ==nil or b == nil then
|
||
return
|
||
end
|
||
if (a.isFormation == "" or (a.isFormation ~= "" and a.isFormations[1] == FormationTypeDef.EXPEDITION)) and (b.isFormation == "" or (b.isFormation ~= "" and b.isFormations[1] == FormationTypeDef.EXPEDITION)) then
|
||
if a.lockState == b.lockState then
|
||
if a.isHarmonyGongMing == b.isHarmonyGongMing then
|
||
if a.heroConfig.Natural ==b.heroConfig.Natural then
|
||
if a.star == b.star then
|
||
if a.lv == b.lv then
|
||
return a.heroConfig.Id > b.heroConfig.Id
|
||
else
|
||
return a.lv < b.lv
|
||
end
|
||
else
|
||
return a.star < b.star
|
||
end
|
||
else
|
||
return a.heroConfig.Natural < b.heroConfig.Natural
|
||
end
|
||
else
|
||
return a.isHarmonyGongMing < b.isHarmonyGongMing
|
||
end
|
||
else
|
||
return a.lockState < b.lockState
|
||
end
|
||
else
|
||
return (a.isFormation == "" or (a.isFormation ~= "" and a.isFormations[1] == FormationTypeDef.EXPEDITION)) and (not b.isFormation ~= "" and b.isFormations[1] ~= FormationTypeDef.EXPEDITION)
|
||
end
|
||
end)
|
||
end
|
||
--快速选择英雄 或者 装备
|
||
function this.QuickSelectListData(type)
|
||
if type == 1 then
|
||
selectHeroData={}
|
||
for k, v in pairs(tarHero) do
|
||
if LengthOfTable(selectHeroData)<maxSelectNum and (v.isFormation == "" or (v.isFormation ~= "" and v.isFormations[1] == FormationTypeDef.EXPEDITION)) and v.lockState == 0 and v.star < 4 then
|
||
selectHeroData[v.dynamicId]=v
|
||
else
|
||
break
|
||
end
|
||
end
|
||
this.ScrollView:SetData(tarHero, function (index, go)
|
||
this.SingleHeroDataShow(go, tarHero[index])
|
||
end,true,true)
|
||
else
|
||
selectHeroData={}
|
||
this.ScrollView:SetData(tarHero, function (index, go)
|
||
this.SingleHeroDataShow(go, tarHero[index])
|
||
end,true,true)
|
||
end
|
||
end
|
||
function this:OnClose()
|
||
end
|
||
|
||
function this:OnDestroy()
|
||
end
|
||
|
||
return this |