252 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			252 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Lua
		
	
 | 
						||
----- 回溯 -----
 | 
						||
local this = {}
 | 
						||
local sortType=0
 | 
						||
local sortingOrder=0
 | 
						||
local tarHero={}--当前筛选后显示英雄列表
 | 
						||
local selectHeroData={}--选择的英雄list did = data
 | 
						||
local oldChoosed=nil--上一个选中英雄
 | 
						||
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
 | 
						||
local heroRankupConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
 | 
						||
function this:InitComponent(gameObject)
 | 
						||
    this.spLoader = SpriteLoader.New()
 | 
						||
    this.helpBtn=Util.GetGameObject(gameObject,"Content/Resolve_Talisman/HelpBtn")
 | 
						||
    this.helpPos=this.helpBtn:GetComponent("RectTransform").localPosition
 | 
						||
    this.confirmBtn=Util.GetGameObject(gameObject,"Content/Resolve_Talisman/ConfirmBtn")
 | 
						||
    --道具数量信息
 | 
						||
    this.info1 = Util.GetGameObject(gameObject,"Content/Resolve_Talisman/UseProps/Info")
 | 
						||
    this.info1:GetComponent("Text").text = Language[11751]
 | 
						||
    this.info2 = Util.GetGameObject(gameObject,"Content/Resolve_Talisman/UseProps/Info (1)")
 | 
						||
    this.info2:GetComponent("Text").text = Language[11752]
 | 
						||
    Util.GetGameObject(gameObject,"Content/Resolve_Talisman/Empty/Bg/Text"):GetComponent("Text").text = Language[11753]
 | 
						||
    this.empty=Util.GetGameObject(gameObject,"Content/Resolve_Talisman/Empty")
 | 
						||
 | 
						||
 | 
						||
    this.cardPre = Util.GetGameObject(gameObject,"item")
 | 
						||
    this.scrollbar = Util.GetGameObject(gameObject,"Content/Resolve_Talisman/Scrollbar"):GetComponent("Scrollbar")
 | 
						||
    local v21 = Util.GetGameObject(gameObject, "Content/Resolve_Talisman/ItemListRoot"):GetComponent("RectTransform").rect
 | 
						||
    this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "Content/Resolve_Talisman/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
 | 
						||
    Util.GetGameObject(this.confirmBtn,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite("h_guiyuan_anniu_zh")
 | 
						||
end
 | 
						||
 | 
						||
function this:BindEvent()
 | 
						||
    Util.AddClick(this.helpBtn,function()
 | 
						||
        UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.TalismanResolve,this.helpPos.x,this.helpPos.y)
 | 
						||
    end)
 | 
						||
    Util.AddClick(this.confirmBtn,function()
 | 
						||
        if tonumber(LengthOfTable(selectHeroData))==0 then
 | 
						||
            PopupTipPanel.ShowTip(Language[11754])
 | 
						||
       
 | 
						||
        else
 | 
						||
            UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TalismanResolve,
 | 
						||
            HeroManager.GetHeroReturnItems(selectHeroData,GENERAL_POPUP_TYPE.TalismanResolve),selectHeroData)
 | 
						||
        end
 | 
						||
    end)
 | 
						||
end
 | 
						||
 | 
						||
function this:AddListener()
 | 
						||
end
 | 
						||
 | 
						||
function this:RemoveListener()
 | 
						||
end
 | 
						||
 | 
						||
function this:OnShow(...)
 | 
						||
    local args={...}
 | 
						||
    sortingOrder =args[1]
 | 
						||
    
 | 
						||
    sortType = PlayerManager.now_index or 0
 | 
						||
 | 
						||
    --LogGreen(PlayerManager.now_index)
 | 
						||
 | 
						||
    this.SortTypeClick(sortType,args[3],args[4])
 | 
						||
end
 | 
						||
 | 
						||
function this:OnClose()
 | 
						||
    selectHeroData={}
 | 
						||
    oldChoosed=nil
 | 
						||
end
 | 
						||
 | 
						||
function this:OnDestroy()
 | 
						||
    this.spLoader:Destroy()
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
 | 
						||
--展示数据
 | 
						||
function this.SortTypeClick(_sortType,isTop,isAni)
 | 
						||
    selectHeroData={}
 | 
						||
 | 
						||
    tarHero={}
 | 
						||
    tarHero=this.GetHeroData(_sortType)
 | 
						||
    --设置empty
 | 
						||
    this.empty:SetActive(#tarHero==0)
 | 
						||
    --设置英雄显示
 | 
						||
    this.SortHeroDatas(tarHero)
 | 
						||
    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.GetHeroData(_sortType)
 | 
						||
    local tempHeros={}
 | 
						||
        local data=HeroManager.GetAllHeroDataMsinusUpWar(_sortType,3)
 | 
						||
        for n=1,#data do
 | 
						||
            tempHeros[#tempHeros+1]=data[n]
 | 
						||
        end
 | 
						||
    --根据元素筛选
 | 
						||
    local heros={}
 | 
						||
    if tempHeros and LengthOfTable(tempHeros)>0 then
 | 
						||
        for i, v in pairs(tempHeros) do
 | 
						||
            if _sortType ==0 then
 | 
						||
                table.insert(heros,v)
 | 
						||
            else
 | 
						||
                if v.property==_sortType then   
 | 
						||
                    table.insert(heros,v)
 | 
						||
                end
 | 
						||
            end
 | 
						||
        end
 | 
						||
    end
 | 
						||
    --end
 | 
						||
    return heros
 | 
						||
end
 | 
						||
 | 
						||
--英雄单个数据展示
 | 
						||
function this.SingleHeroDataShow(go,_heroData)
 | 
						||
    local heroData = _heroData
 | 
						||
    local _go = go
 | 
						||
    Util.GetGameObject(_go.transform, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
 | 
						||
    
 | 
						||
    Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = "+"..heroData.talismanList--heroData.lv
 | 
						||
    Util.GetGameObject(_go.transform, "Text"):GetComponent("Text").text =SubString2(GetLanguageStrById(heroData.heroConfig.ReadingName),8) 
 | 
						||
    Util.GetGameObject(_go.transform, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.icon)
 | 
						||
    Util.GetGameObject(_go.transform, "posIcon"):SetActive(false)
 | 
						||
    Util.GetGameObject(_go.transform, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
 | 
						||
    local starGrid = Util.GetGameObject(_go.transform, "star")
 | 
						||
    SetHeroStars(this.spLoader, starGrid, heroData.star,1,nil,-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 = this.spLoader:LoadSprite("t_tongyong-yishangzheng_zh")
 | 
						||
    formationMask:SetActive(heroData.isFormation ~= "" )
 | 
						||
    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")
 | 
						||
    local GongMingMask = Util.GetGameObject(_go.transform, "GongMingMask") 
 | 
						||
    GongMingMask:SetActive(false)--最后检测是否共鸣
 | 
						||
    if heroData.lockState == 1 or heroData.isFormation ~= "" 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) then
 | 
						||
        --     Util.GetGameObject(_go.transform, "lv/Text"):GetComponent("Text").text = "<color=#ffbe22>"..heroData.lv.."</color>"
 | 
						||
        --     GongMingMask:SetActive(true)
 | 
						||
        end
 | 
						||
    end
 | 
						||
    Util.AddOnceClick(GongMingMask, function()
 | 
						||
        PopupTipPanel.ShowTip(Language[12184])
 | 
						||
    end)
 | 
						||
 | 
						||
    Util.AddOnceClick(cardclickBtn, function()
 | 
						||
        if oldChoosed then
 | 
						||
            oldChoosed:SetActive(false)
 | 
						||
        end
 | 
						||
        if oldChoosed==choosed then
 | 
						||
            oldChoosed:SetActive(LengthOfTable(selectHeroData)==0)
 | 
						||
            oldChoosed=nil
 | 
						||
            selectHeroData={}
 | 
						||
        else
 | 
						||
            HarmonyManager.IsGongMing(heroData.dynamicId)
 | 
						||
            choosed:SetActive(true)
 | 
						||
            oldChoosed=choosed
 | 
						||
            selectHeroData = {}
 | 
						||
            selectHeroData[heroData.dynamicId]=heroData
 | 
						||
        end
 | 
						||
        -- this.info1:SetActive( not (LengthOfTable(selectHeroData) > 0))
 | 
						||
        -- this.info2:SetActive( not (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.EXPEDITION then
 | 
						||
                        UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.SAVE_FORMATION,FormationTypeDef.EXPEDITION)
 | 
						||
                    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 == "" and b.isFormation == "" then
 | 
						||
            if a.lockState == b.lockState then
 | 
						||
                if a.isHarmonyGongMing == b.isHarmonyGongMing then
 | 
						||
                    if a.talismanList == b.talismanList 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.talismanList < b.talismanList
 | 
						||
                    end
 | 
						||
                else
 | 
						||
                    return a.isHarmonyGongMing < b.isHarmonyGongMing
 | 
						||
                end
 | 
						||
            else
 | 
						||
                return a.lockState < b.lockState
 | 
						||
            end
 | 
						||
        else
 | 
						||
            return a.isFormation == ""  and not b.dynamicId ~= ""
 | 
						||
        end
 | 
						||
    end)
 | 
						||
end
 | 
						||
 | 
						||
return this
 | 
						||
 |