921 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			921 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			Lua
		
	
require("Base/BasePanel")
 | 
						||
FormationPanelV2 = Inherit(BasePanel)
 | 
						||
local this = FormationPanelV2
 | 
						||
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
 | 
						||
local elementalResonanceConfig = ConfigManager.GetConfig(ConfigName.ElementalResonanceConfig)
 | 
						||
 | 
						||
local roleConfig=ConfigManager.GetConfig(ConfigName.RoleConfig)
 | 
						||
local orginLayer
 | 
						||
local curFormation --打开面板编队信息
 | 
						||
this.choosedList={}--选择上阵列表 临时数据
 | 
						||
this.curFormationIndex = 1 --当前编队索引
 | 
						||
this.trigger={}
 | 
						||
 | 
						||
local bgListGo={} --上阵背景预设
 | 
						||
local heroListGo = {}--英雄上阵预设列表
 | 
						||
local maskListGo={} --上阵遮罩
 | 
						||
local dragViewListGo={}--dragView预设列表
 | 
						||
 | 
						||
local effectList = {}--特效列表
 | 
						||
local tabs = {}--筛选按钮
 | 
						||
local proId=0--0 全部  1 火 2风 3 水 4 地
 | 
						||
 | 
						||
local limitLevel = 0--猎妖师等级限制
 | 
						||
local sortType = 1 -- 1:品阶  2:等级
 | 
						||
 | 
						||
this.order=0
 | 
						||
local chooseIndex=0
 | 
						||
local chooseHeroObj --当前选中英雄
 | 
						||
 | 
						||
this.formationPower = 0--战力
 | 
						||
local oldPowerNum = 0 --旧战力
 | 
						||
local tempPowerNum=0 --临时战力
 | 
						||
 | 
						||
-- local liveNodes={}--立绘容器
 | 
						||
-- local liveNames={}--立绘名容器
 | 
						||
 | 
						||
local panelType
 | 
						||
 | 
						||
-- 各个类型编队系统逻辑列表
 | 
						||
this.PanelOptionView = {
 | 
						||
    [FORMATION_TYPE.CARBON] = "Modules/Formation/View/CarbonFormation",
 | 
						||
    [FORMATION_TYPE.STORY] = "Modules/Formation/View/StoryFormation",
 | 
						||
    [FORMATION_TYPE.MAIN] = "Modules/Formation/View/MainFormation",
 | 
						||
    [FORMATION_TYPE.ARENA_DEFEND] = "Modules/Formation/View/ArenaDefendFormation",
 | 
						||
    [FORMATION_TYPE.ARENA_ATTACK] = "Modules/Formation/View/ArenaAttackFormation",
 | 
						||
    [FORMATION_TYPE.ARENA_TOP_MATCH] = "Modules/Formation/View/ArenaTopMatchFormation",
 | 
						||
    [FORMATION_TYPE.ADVENTURE] = "Modules/Formation/View/AdventureFormation",
 | 
						||
    [FORMATION_TYPE.ADVENTURE_BOSS] = "Modules/Formation/View/AdventureBossFormation",
 | 
						||
    [FORMATION_TYPE.ELITE_MONSTER] = "Modules/Formation/View/EliteMonsterFormation",
 | 
						||
    [FORMATION_TYPE.GUILD_DEFEND] = "Modules/Formation/View/GuildFightDefendFormation",
 | 
						||
    [FORMATION_TYPE.GUILD_ATTACK] = "Modules/Formation/View/GuildFightAttackFormation",
 | 
						||
    [FORMATION_TYPE.GUILD_BOSS] = "Modules/Formation/View/GuildBossFormation",
 | 
						||
    [FORMATION_TYPE.MONSTER_CAMP] = "Modules/Formation/View/MonsterCampFormation",
 | 
						||
    [FORMATION_TYPE.BLOODY_BATTLE] = "Modules/Formation/View/FormFightFormation",
 | 
						||
    [FORMATION_TYPE.PLAY] = "Modules/Formation/View/PlayWithSBFormation",
 | 
						||
    [FORMATION_TYPE.EXPEDITION] = "Modules/Formation/View/ExpeditionFormation",
 | 
						||
    [FORMATION_TYPE.SAVE_FORMATION]="Modules/Formation/View/SaveFormation",
 | 
						||
    [FORMATION_TYPE.GUILD_CAR_DELEAY]="Modules/Formation/View/GuildCarDeleayFormation",
 | 
						||
    [FORMATION_TYPE.GUILD_DEATHPOS]="Modules/Formation/View/GuildDeathPosFormation",
 | 
						||
    [FORMATION_TYPE.XUANYUAN_MIRROR]="Modules/Formation/View/XuanYuanMirrorFormation",
 | 
						||
}
 | 
						||
function this:InitComponent()
 | 
						||
    orginLayer=0
 | 
						||
    this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
 | 
						||
    this.bg = Util.GetGameObject(this.gameObject, "Bg")
 | 
						||
    this.backBtn = Util.GetGameObject(this.gameObject, "BackBtn")
 | 
						||
    this.exampleBtn=Util.GetGameObject(this.gameObject,"ExampleBtn")
 | 
						||
    this.effect = Util.GetGameObject(this.gameObject, "effect")
 | 
						||
    this.power = Util.GetGameObject(this.gameObject, "Power/Value"):GetComponent("Text")
 | 
						||
    this.root=Util.GetGameObject(this.gameObject,"Root")
 | 
						||
 | 
						||
    this.roleGrid=Util.GetGameObject(this.gameObject,"RoleGrid")
 | 
						||
    this.line=Util.GetGameObject(this.gameObject,"RoleGrid/Line")
 | 
						||
    for i = 1, 6 do
 | 
						||
        bgListGo[i]=Util.GetGameObject(this.gameObject,"RoleGrid/Bg"..i)
 | 
						||
        heroListGo[i] = Util.GetGameObject(this.gameObject,"RoleGrid/Bg"..i.."/Hero"..i)
 | 
						||
        maskListGo[i]=Util.GetGameObject(this.gameObject,"RoleGrid/Mask"..i)
 | 
						||
        if not dragViewListGo[i] then
 | 
						||
            dragViewListGo[i] = SubUIManager.Open(SubUIConfig.DragView, bgListGo[i].transform)
 | 
						||
        end
 | 
						||
        dragViewListGo[i].gameObject.name="DragView"..i
 | 
						||
        dragViewListGo[i].gameObject:SetActive(false)
 | 
						||
        dragViewListGo[i]:SetScrollMouse(false)
 | 
						||
        this.trigger[i]=Util.GetEventTriggerListener(dragViewListGo[i].gameObject)
 | 
						||
        this.trigger[i].onPointerDown= this.trigger[i].onPointerDown+this.OnPointerDown
 | 
						||
        this.trigger[i].onPointerUp= this.trigger[i].onPointerUp+this.OnPointerUp
 | 
						||
        this.trigger[i].onEndDrag= this.trigger[i].onEndDrag+this.OnEndDrag
 | 
						||
        this.trigger[i].onDrag=this.trigger[i].onDrag+this.OnDrag
 | 
						||
        dragViewListGo[i]:SetDragGO(heroListGo[i])
 | 
						||
    end
 | 
						||
 | 
						||
    --滚动条
 | 
						||
    this.heroPre = Util.GetGameObject(this.gameObject, "Scroll/HeroPre")
 | 
						||
    this.empty=Util.GetGameObject(this.gameObject,"Scroll/Empty")
 | 
						||
    this.scroll = Util.GetGameObject(this.gameObject, "Scroll")
 | 
						||
    this.scrollBar = Util.GetGameObject(this.gameObject, "Scrollbar"):GetComponent("Scrollbar")
 | 
						||
    this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,
 | 
						||
            this.heroPre, this.scrollBar, Vector2.New(1010, 490), 1, 5, Vector2.New(40, 30))
 | 
						||
    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 = 2
 | 
						||
 | 
						||
    --筛选按钮
 | 
						||
    for i = 0, 4 do
 | 
						||
        tabs[i] = Util.GetGameObject(this.gameObject, "Tabs/Grid/Btn" .. i)
 | 
						||
    end
 | 
						||
    this.selectBtn = Util.GetGameObject(this.gameObject, "Tabs/SelectBtn")
 | 
						||
 | 
						||
    --副本扫荡
 | 
						||
    this.mopUpGo = Util.GetGameObject(self.transform, "root/showMopUp")
 | 
						||
    this.btnMpoUpBack = Util.GetGameObject(self.transform, "showMopUp/bg/btnBack")
 | 
						||
    this.Slider = Util.GetGameObject(self.transform, "showMopUp/bg/Slider")
 | 
						||
    this.numText = Util.GetGameObject(self.transform, "showMopUp/bg/Slider/numText"):GetComponent("Text")
 | 
						||
    this.btnMpoUpSure = Util.GetGameObject(self.transform, "showMopUp/bg/btnSure")
 | 
						||
    this.buyGoNumTex = Util.GetGameObject(self.transform, "showMopUp/bg/buyGo/numText"):GetComponent("Text")
 | 
						||
    -- 购买次数
 | 
						||
    this.btnBuyCount = Util.GetGameObject(self.transform, "showMopUp/bg/buyGo/addBtn/GameObject")
 | 
						||
 | 
						||
    -- 底部panel
 | 
						||
    this.bottom = Util.GetGameObject(self.gameObject, "bottom")
 | 
						||
    -- 获取按钮
 | 
						||
    this.btn_1 = Util.GetGameObject(self.gameObject, "bottom/btnbox/btn_1")
 | 
						||
    this.btn_1_lab = Util.GetGameObject(self.gameObject, "bottom/btnbox/btn_1/btnLab"):GetComponent("Text")
 | 
						||
    this.btn_2 = Util.GetGameObject(self.gameObject, "bottom/btnbox/btn_2")
 | 
						||
    this.btn_2_lab = Util.GetGameObject(self.gameObject, "bottom/btnbox/btn_2/btnLab"):GetComponent("Text")
 | 
						||
    -- tip
 | 
						||
    this.mobTip = Util.GetGameObject(self.gameObject, "bottom/mobtip")
 | 
						||
    this.costTip = Util.GetGameObject(self.gameObject, "bottom/costtip")
 | 
						||
    this.failText = Util.GetGameObject(self.gameObject, "bottom/costtip/fail")
 | 
						||
    -- 精英副本扫荡提示
 | 
						||
    this.eliteTip = Util.GetGameObject(self.gameObject, "bottom/eliTip")
 | 
						||
    this.eliteNumNeed = Util.GetGameObject(this.eliteTip, "condition"):GetComponent("Text")
 | 
						||
    -- 跳过战斗
 | 
						||
    this.passBattle0 = Util.GetGameObject(self.transform, "bottom/passBattle0")
 | 
						||
    this.passBattle1 = Util.GetGameObject(self.transform, "bottom/passBattle1")
 | 
						||
 | 
						||
    -- 上阵等级提示
 | 
						||
    this.formTip = Util.GetGameObject(self.transform, "bottom/formTip")
 | 
						||
    -- 上阵元素提示
 | 
						||
    this.tip = Util.GetGameObject(self.transform, "bottom/tip")
 | 
						||
    this.tip.gameObject:SetActive(false)
 | 
						||
 | 
						||
    this.mopUpGo.transform:SetParent(self.gameObject.transform)
 | 
						||
    this.mopUpGo:SetActive(false)
 | 
						||
 | 
						||
    --元素共鸣
 | 
						||
    this.ElementalResonanceView = SubUIManager.Open(SubUIConfig.ElementalResonanceView, this.gameObject.transform)
 | 
						||
end
 | 
						||
 | 
						||
function this:BindEvent()
 | 
						||
    --返回按钮
 | 
						||
    Util.AddClick(this.backBtn, function()
 | 
						||
        this:ClosePanel()
 | 
						||
    end)
 | 
						||
    --筛选按钮
 | 
						||
    for i = 0, 4 do
 | 
						||
        Util.AddClick(tabs[i], function()
 | 
						||
            if i == proId then
 | 
						||
                proId=ProIdConst.All
 | 
						||
            else
 | 
						||
                proId=i
 | 
						||
            end
 | 
						||
            this.OnClickTabBtn(proId)
 | 
						||
        end)
 | 
						||
    end
 | 
						||
    --推荐阵容
 | 
						||
    Util.AddClick(this.exampleBtn,function()
 | 
						||
        UIManager.OpenPanel(UIName.FormationExamplePopup)
 | 
						||
    end)
 | 
						||
 | 
						||
    --通用逻辑调用
 | 
						||
    Util.AddClick(this.btn_1, function()
 | 
						||
        if this.opView and this.opView.On_Btn1_Click then
 | 
						||
            this.opView.On_Btn1_Click(this.curFormationIndex)
 | 
						||
        end
 | 
						||
    end)
 | 
						||
    Util.AddClick(this.btn_2, function()
 | 
						||
        if this.opView and this.opView.On_Btn2_Click then
 | 
						||
            this.opView.On_Btn2_Click(this.curFormationIndex)
 | 
						||
        end
 | 
						||
    end)
 | 
						||
end
 | 
						||
 | 
						||
function this:AddListener()
 | 
						||
    Game.GlobalEvent:AddEvent(GameEvent.Formation.OnFormationChange, this.RefreshPower)
 | 
						||
end
 | 
						||
 | 
						||
function this:RemoveListener()
 | 
						||
    Game.GlobalEvent:RemoveEvent(GameEvent.Formation.OnFormationChange, this.RefreshPower)
 | 
						||
end
 | 
						||
 | 
						||
function this:OnSortingOrderChange()
 | 
						||
    -- 设置特效
 | 
						||
    Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer)
 | 
						||
    for _,o in pairs(heroListGo) do
 | 
						||
        Util.AddParticleSortLayer(o, self.sortingOrder - orginLayer)
 | 
						||
    end
 | 
						||
    orginLayer = self.sortingOrder
 | 
						||
end
 | 
						||
 | 
						||
function this:OnOpen(_panelType,...)
 | 
						||
    panelType = _panelType
 | 
						||
    if panelType == FORMATION_TYPE.EXPEDITION then
 | 
						||
        for k,v in pairs(bgListGo) do
 | 
						||
            v:GetComponent("Image").sprite = Util.LoadSprite("t_biandui.xuanzhongkuang")
 | 
						||
            this.line:GetComponent("RectTransform").sizeDelta = Vector2.New(294.2,439.48)
 | 
						||
        end
 | 
						||
    else
 | 
						||
        for k,v in pairs(bgListGo) do
 | 
						||
            v:GetComponent("Image").sprite = Util.LoadSprite("t_chengyuankuang_kuang")
 | 
						||
            this.line:GetComponent("RectTransform").sizeDelta = Vector2.New(294.2,414.87)
 | 
						||
        end
 | 
						||
    end
 | 
						||
    -- tempPowerNum=0
 | 
						||
    this.selectBtn:SetActive(false)
 | 
						||
    this.passBattle0:SetActive(false)
 | 
						||
    this.passBattle1:SetActive(false)
 | 
						||
    this.btn_1:SetActive(false)
 | 
						||
    this.btn_1:GetComponent("Button").enabled = true
 | 
						||
    Util.SetColor(this.btn_1, Color.New(1, 1, 1, 1))
 | 
						||
    this.btn_2:SetActive(false)
 | 
						||
    this.mobTip:SetActive(false)
 | 
						||
    this.costTip:SetActive(false)
 | 
						||
    this.eliteTip:SetActive(false)
 | 
						||
    this.failText:SetActive(false)
 | 
						||
    this.formTip:SetActive(false)
 | 
						||
    this.empty:SetActive(false)
 | 
						||
    LogPink("_panelType        ".._panelType)
 | 
						||
    this.opView = require(this.PanelOptionView[_panelType])
 | 
						||
    this.opView.Init(this, ...)
 | 
						||
    this.curFormationIndex = this.opView.GetFormationIndex()
 | 
						||
    FormationManager.currentFormationIndex = this.opView.GetFormationIndex()
 | 
						||
    SoundManager.PlaySound(SoundConfig.Sound_BattleStart_01)
 | 
						||
end
 | 
						||
 | 
						||
function this:OnShow()
 | 
						||
    this.ElementalResonanceView:OnOpen({sortOrder=self.sortingOrder})
 | 
						||
    this.SetDrawLevel()
 | 
						||
    this.RefreshFormation()
 | 
						||
end
 | 
						||
 | 
						||
function this:OnClose()
 | 
						||
    tempPowerNum = 0
 | 
						||
    this.formationPower = 0
 | 
						||
    oldPowerNum = 0 
 | 
						||
    proId=0--面板关闭时 重置筛选按钮为全部
 | 
						||
    for i = 1, #this.choosedList do
 | 
						||
        local pos=this.choosedList[i].position
 | 
						||
        local o=heroListGo[pos]
 | 
						||
        -- if liveNodes[o] then
 | 
						||
        --     poolManager:UnLoadLive(liveNames[o], liveNodes[o])
 | 
						||
        --     liveNames[o] = nil
 | 
						||
        -- end
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
function this:OnDestroy()
 | 
						||
    SubUIManager.Close(this.UpView)
 | 
						||
    SubUIManager.Close(this.ElementalResonanceView)
 | 
						||
    dragViewListGo={}
 | 
						||
    this.scrollView = nil
 | 
						||
end
 | 
						||
 | 
						||
--刷新编队
 | 
						||
function this.RefreshFormation()
 | 
						||
    proId=0
 | 
						||
    EndLessMapManager.RrefreshFormation()
 | 
						||
    --获取当前编队数据
 | 
						||
    if this.curFormationIndex == FormationTypeDef.EXPEDITION then
 | 
						||
        ExpeditionManager.ExpeditionRrefreshFormation()--刷新编队
 | 
						||
    end
 | 
						||
    curFormation = FormationManager.GetFormationByID(this.curFormationIndex)
 | 
						||
    --上阵列表赋值
 | 
						||
    this.choosedList ={}
 | 
						||
    for j = 1, #curFormation.teamHeroInfos do
 | 
						||
        local teamInfo = curFormation.teamHeroInfos[j]
 | 
						||
        -- 加空判断避免不知名错误
 | 
						||
        if teamInfo then
 | 
						||
            table.insert(this.choosedList, {heroId =teamInfo.heroId,position=teamInfo.position})
 | 
						||
        end
 | 
						||
    end
 | 
						||
    this.order = #this.choosedList
 | 
						||
 | 
						||
    -- 妖灵师等级限制
 | 
						||
    limitLevel = 0
 | 
						||
    limitLevel = CarbonManager.difficulty == 4 and EndLessMapManager.limiteLevel or 0
 | 
						||
    if this.curFormationIndex == FormationTypeDef.EXPEDITION then
 | 
						||
        limitLevel = 20
 | 
						||
    end
 | 
						||
 | 
						||
    --设置上阵英雄信息
 | 
						||
    this.SetCardsData()
 | 
						||
    --显示英雄列表
 | 
						||
    this.OnClickTabBtn(proId)
 | 
						||
 | 
						||
    --战力
 | 
						||
    this.RefreshPower()
 | 
						||
end
 | 
						||
 | 
						||
--设置编队上阵英雄信息
 | 
						||
function this.SetCardsData()
 | 
						||
    this.formationPower = 0--战力
 | 
						||
    --元素共鸣
 | 
						||
    this.ElementalResonanceView:GetElementalType(this.choosedList,1)
 | 
						||
    this.ElementalResonanceView:SetPosition(1)
 | 
						||
 | 
						||
    this.InitArmPos()
 | 
						||
    this.InitArmData()
 | 
						||
 | 
						||
    --编队为0显示0战力
 | 
						||
    if #this.choosedList<=0 then
 | 
						||
        this.formationPower=0
 | 
						||
    end
 | 
						||
    this.power.text=this.formationPower
 | 
						||
 | 
						||
    --飘战力
 | 
						||
    local newPowerNum = this.formationPower
 | 
						||
    if tempPowerNum ~= newPowerNum and tempPowerNum ~= 0 then
 | 
						||
        UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = tempPowerNum,newValue = newPowerNum,pos=Vector3.New(-467,837.2),duration=0.7,isShowBg=false,isShowOldNum=false,pivot=Vector2.New(0,0.5)})
 | 
						||
    end
 | 
						||
    tempPowerNum = this.formationPower
 | 
						||
end
 | 
						||
-- 设置编队上阵位置显隐
 | 
						||
function this.InitArmPos()
 | 
						||
    for i = 1, 6 do
 | 
						||
        local mask =maskListGo[i]
 | 
						||
        local info= heroListGo[i]
 | 
						||
        local limitStr = Util.GetGameObject(mask, "lvLimit"):GetComponent("Text")
 | 
						||
        local armNum = ActTimeCtrlManager.MaxArmyNum()--最大上阵人数
 | 
						||
        local canOn = i<= armNum--能上阵
 | 
						||
        limitStr.text = ActTimeCtrlManager.UnLockCondition(i)
 | 
						||
 | 
						||
        -- 显示解锁条件
 | 
						||
        mask:SetActive(not canOn)
 | 
						||
        if #this.choosedList==0 then
 | 
						||
            info:SetActive(false)
 | 
						||
            dragViewListGo[i].gameObject:SetActive(false)
 | 
						||
        end
 | 
						||
        -- 显示上阵的英雄
 | 
						||
        local heroData
 | 
						||
        for j = 1, #this.choosedList do
 | 
						||
            if i== this.choosedList[j].position then
 | 
						||
                heroData = HeroManager.GetSingleHeroData(this.choosedList[j].heroId)
 | 
						||
                if not heroData then
 | 
						||
                    LogError("heroData is not exist! error Did:" .. this.choosedList[j].heroId)
 | 
						||
                    return
 | 
						||
                end
 | 
						||
                info:SetActive(true)
 | 
						||
                dragViewListGo[i].gameObject:SetActive(true)
 | 
						||
                break
 | 
						||
            else
 | 
						||
                info:SetActive(false)
 | 
						||
                dragViewListGo[i].gameObject:SetActive(false)
 | 
						||
            end
 | 
						||
        end
 | 
						||
    end
 | 
						||
end
 | 
						||
-- 设置编队上阵数据
 | 
						||
function this.InitArmData()
 | 
						||
    --为每个英雄添加拖动组件
 | 
						||
    for n = 1, #this.choosedList do
 | 
						||
        local allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal(this.choosedList,this.choosedList[n].heroId)
 | 
						||
        --已上阵操作
 | 
						||
        local pos=this.choosedList[n].position
 | 
						||
 | 
						||
        -- LogBlue("源数据位置信息"..pos.."  "..HeroManager.GetSingleHeroData(this.choosedList[n].heroId).id.."  "..this.choosedList[n].position)
 | 
						||
        local heroId = this.choosedList[n].heroId
 | 
						||
        local heroData = HeroManager.GetSingleHeroData(heroId)
 | 
						||
 | 
						||
        --设置单个上阵英雄信息
 | 
						||
        this.SetCardSingleData(heroListGo[pos],heroId,tonumber(pos), heroData)
 | 
						||
        --战力计算
 | 
						||
        this.CalculateAllHeroPower(heroData,allHeroTeamAddProVal)
 | 
						||
 | 
						||
        --英雄长按
 | 
						||
        local heroClick=Util.GetGameObject(bgListGo[pos],"DragView"..pos)
 | 
						||
        Util.AddLongPressClick(heroClick, function()
 | 
						||
            UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
 | 
						||
        end, 0.5)
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
--设置单个上阵英雄信息
 | 
						||
function this.SetCardSingleData(o, heroId, _pos, _heroData)
 | 
						||
    local bg=Util.GetGameObject(o,"Bg1"):GetComponent("Image")
 | 
						||
    local lv=Util.GetGameObject(o,"lv/Text"):GetComponent("Text")
 | 
						||
    local hp = Util.GetGameObject(o,"hpProgress/hp"):GetComponent("Image")
 | 
						||
    local hpPass = Util.GetGameObject(o,"hpProgress/hpPass"):GetComponent("Image")
 | 
						||
    local rage = Util.GetGameObject(o,"rageProgress/rage"):GetComponent("Image")
 | 
						||
 | 
						||
    if panelType == FORMATION_TYPE.EXPEDITION then
 | 
						||
        bg.sprite = Util.LoadSprite(GetFormationHeroCardStarBg[_heroData.star])
 | 
						||
        Util.GetGameObject(o,"hpProgress").gameObject:SetActive(true)
 | 
						||
        Util.GetGameObject(o,"rageProgress").gameObject:SetActive(false)
 | 
						||
        
 | 
						||
    else
 | 
						||
        bg.sprite = Util.LoadSprite(GetHeroCardStarBg[_heroData.star])
 | 
						||
        Util.GetGameObject(o,"hpProgress").gameObject:SetActive(false)
 | 
						||
        Util.GetGameObject(o,"rageProgress").gameObject:SetActive(false)
 | 
						||
       
 | 
						||
    end
 | 
						||
    
 | 
						||
    local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image")
 | 
						||
    -- local live=Util.GetGameObject(o,"Mask/Live")
 | 
						||
    
 | 
						||
    local pro=Util.GetGameObject(o,"Pro/Image"):GetComponent("Image")
 | 
						||
    local starGrid=Util.GetGameObject(o,"StarGrid")
 | 
						||
    local name=Util.GetGameObject(o,"Name/Text"):GetComponent("Text")
 | 
						||
    -- local pos=Util.GetGameObject(o,"Pos"):GetComponent("Image")
 | 
						||
    local yuanImage=Util.GetGameObject(o,"yuanImage")
 | 
						||
   
 | 
						||
    local heroData=HeroManager.GetSingleHeroData(heroId)
 | 
						||
 | 
						||
    local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
 | 
						||
    local liveName = GetResourcePath(heroData.heroConfig.Live)
 | 
						||
    local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroData.heroConfig.Id)
 | 
						||
    local scale = roleConfig.play_liveScale
 | 
						||
    local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0) 
 | 
						||
    live.texture = CardRendererManager.GetSpineTexture(_pos, liveName, Vector3.one * scale, livePos, true) 
 | 
						||
    live.transform.localScale = Vector3.one
 | 
						||
    live.transform.localPosition = Vector3.zero
 | 
						||
 | 
						||
    local zs = Util.GetGameObject(o, "zs")
 | 
						||
    local zsName = GetHeroCardStarZs[heroData.star]
 | 
						||
    if zsName == "" then
 | 
						||
        zs:SetActive(false)
 | 
						||
    else
 | 
						||
        zs:SetActive(true)
 | 
						||
        zs:GetComponent("Image").sprite = Util.LoadSprite(zsName)
 | 
						||
    end
 | 
						||
 | 
						||
    yuanImage:SetActive(heroData.createtype == 1)
 | 
						||
    lv.text=heroData.lv
 | 
						||
    
 | 
						||
    fg.sprite = Util.LoadSprite(GetHeroCardStarFg[heroData.star])
 | 
						||
 | 
						||
    pro.sprite=Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
 | 
						||
    SetCardStars(starGrid,heroData.star)
 | 
						||
    if heroData.star > 9 then
 | 
						||
        Util.GetGameObject(o,"UI_Effect_jinkuang_KaPai").gameObject:SetActive(true)
 | 
						||
    else
 | 
						||
        Util.GetGameObject(o,"UI_Effect_jinkuang_KaPai").gameObject:SetActive(false)
 | 
						||
    end
 | 
						||
    name.text=heroData.heroConfig.ReadingName
 | 
						||
 | 
						||
 | 
						||
    local curHeroHpVal = FormationManager.GetFormationHeroHp(this.curFormationIndex,_heroData.dynamicId)
 | 
						||
    hp.fillAmount = curHeroHpVal or 1
 | 
						||
    hpPass.fillAmount = curHeroHpVal or 1
 | 
						||
    rage.fillAmount = 0.5
 | 
						||
end
 | 
						||
--战力计算
 | 
						||
function this.CalculateAllHeroPower(curHeroData,allHeroTeamAddProVal)
 | 
						||
    local allEquipAddProVal = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false,nil,nil,true,allHeroTeamAddProVal)
 | 
						||
    this.formationPower = this.formationPower + allEquipAddProVal[HeroProType.WarPower]
 | 
						||
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
--点击筛选
 | 
						||
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 this.curFormationIndex == FormationTypeDef.EXPEDITION then
 | 
						||
        if _proId == ProIdConst.All then
 | 
						||
            heros = HeroManager.GetAllHeroDatas(limitLevel)
 | 
						||
            heros = ExpeditionManager.GetAllHeroDatas(heros,limitLevel)
 | 
						||
        else
 | 
						||
            heros = HeroManager.GetHeroDataByProperty(_proId, limitLevel)
 | 
						||
            heros = ExpeditionManager.GetHeroDataByProperty(heros,_proId, limitLevel)
 | 
						||
        end
 | 
						||
    else
 | 
						||
        if _proId == ProIdConst.All then
 | 
						||
            heros = HeroManager.GetAllHeroDatas(limitLevel)
 | 
						||
        else
 | 
						||
            heros = HeroManager.GetHeroDataByProperty(_proId, limitLevel)
 | 
						||
        end
 | 
						||
    end
 | 
						||
    this.empty:SetActive(#heros<=0)
 | 
						||
    this.SetRoleList(heros)
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
 | 
						||
--设置英雄列表数据
 | 
						||
function this.SetRoleList(_roleDatas)
 | 
						||
    this.SortHeroDatas(_roleDatas)
 | 
						||
    -- local curFormation = FormationManager.formationList[this.curFormationIndex]
 | 
						||
    this.scrollView:SetData(_roleDatas, function(index, go)
 | 
						||
        this.SingleHeroDataShow(go, _roleDatas[index])
 | 
						||
    end)
 | 
						||
end
 | 
						||
--排序英雄数据
 | 
						||
function this.SortHeroDatas(_heroDatas)
 | 
						||
    local choosed = {}
 | 
						||
    local dieHeros = {}
 | 
						||
    local curFormation = FormationManager.GetFormationByID(this.curFormationIndex)
 | 
						||
    for i = 1, #_heroDatas do
 | 
						||
        local heroHp = FormationManager.GetFormationHeroHp(this.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.warPower == b.warPower then
 | 
						||
                                        if a.id == b.id then
 | 
						||
                                            return a.sortId > b.sortId
 | 
						||
                                        else
 | 
						||
                                            return a.id > b.id
 | 
						||
                                        end
 | 
						||
                                    else
 | 
						||
                                        return a.warPower > b.warPower
 | 
						||
                                    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.warPower == b.warPower then
 | 
						||
                                        if a.id == b.id then
 | 
						||
                                            return a.sortId > b.sortId
 | 
						||
                                        else
 | 
						||
                                            return a.id > b.id
 | 
						||
                                        end
 | 
						||
                                    else
 | 
						||
                                        return a.warPower > b.warPower
 | 
						||
                                    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.SingleHeroDataShow(_go, _heroData)
 | 
						||
    local go=_go
 | 
						||
    local heroData=_heroData
 | 
						||
    local frame=Util.GetGameObject(go,"frame"):GetComponent("Image")
 | 
						||
    local icon=Util.GetGameObject(go, "icon"):GetComponent("Image")
 | 
						||
    local lv= Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
 | 
						||
    local pro= Util.GetGameObject(go, "proIcon"):GetComponent("Image")
 | 
						||
    local starGrid = Util.GetGameObject(go, "star")
 | 
						||
    local yuanImage = Util.GetGameObject(go, "yuanImage")
 | 
						||
    local choosedObj = Util.GetGameObject(go, "choosed")
 | 
						||
    local hpExp = Util.GetGameObject(go, "hpExp")
 | 
						||
    frame.sprite=Util.LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
 | 
						||
    icon.sprite=Util.LoadSprite(heroData.icon)
 | 
						||
    lv.text=heroData.lv
 | 
						||
    pro.sprite= Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
 | 
						||
    SetHeroStars(starGrid, heroData.star,1,Vector2.New(30,30),-8)
 | 
						||
    --血量显示
 | 
						||
    local curHeroHpVal = FormationManager.GetFormationHeroHp(this.curFormationIndex,_heroData.dynamicId)
 | 
						||
    yuanImage:SetActive(heroData.createtype == 1)
 | 
						||
    if not curHeroHpVal then
 | 
						||
        Util.SetGray(go,false)
 | 
						||
        hpExp:SetActive(false)
 | 
						||
    else
 | 
						||
        hpExp:SetActive(true)
 | 
						||
        hpExp:GetComponent("Slider").value = curHeroHpVal
 | 
						||
        if curHeroHpVal <= 0 then
 | 
						||
            Util.SetGray(go,true)
 | 
						||
        else
 | 
						||
            Util.SetGray(go,false)
 | 
						||
        end
 | 
						||
    end
 | 
						||
    choosedObj:SetActive(false)
 | 
						||
    for i,v in pairs(this.choosedList) do
 | 
						||
        if(heroData.dynamicId==v.heroId) then
 | 
						||
            choosedObj:SetActive(true)
 | 
						||
        end
 | 
						||
    end
 | 
						||
    Util.AddOnceClick(go, function()
 | 
						||
        --已上阵取消勾选
 | 
						||
        if not this.opView.NoUpOrDownFormation then
 | 
						||
            if curHeroHpVal and curHeroHpVal <= 0 then
 | 
						||
                PopupTipPanel.ShowTip(Language[10691])
 | 
						||
                return
 | 
						||
            end
 | 
						||
            for k, v in ipairs(this.choosedList) do
 | 
						||
                if v.heroId == heroData.dynamicId then
 | 
						||
                    choosedObj:SetActive(false)
 | 
						||
                    this.order=this.order-1
 | 
						||
                    -- LogGreen("当前下阵位置 "..v.position)
 | 
						||
                    chooseIndex=v.position
 | 
						||
                    table.remove(this.choosedList,k)
 | 
						||
                    this.SetCardsData(this.choosedList)
 | 
						||
                    return
 | 
						||
                end
 | 
						||
            end
 | 
						||
 | 
						||
            -- 当前可选的最大上阵人数
 | 
						||
            local maxNum = ActTimeCtrlManager.MaxArmyNum()
 | 
						||
            if LengthOfTable(this.choosedList) >= maxNum then
 | 
						||
                PopupTipPanel.ShowTip(Language[10692])
 | 
						||
                return
 | 
						||
            end
 | 
						||
 | 
						||
            --判断是否上阵相同猎妖师
 | 
						||
            for k, v in pairs(this.choosedList) do
 | 
						||
                if HeroManager.GetSingleHeroData(v.heroId).id == heroData.id then
 | 
						||
                    PopupTipPanel.ShowTip(Language[10693])
 | 
						||
                    return
 | 
						||
                end
 | 
						||
            end
 | 
						||
            -- 判断是否有血量
 | 
						||
            -- if heroHp and heroHp <= 0 then PopupTipPanel.ShowTip("猎妖师重伤,不可上阵!") return end
 | 
						||
            choosedObj:SetActive(true)
 | 
						||
            this.order=this.order+1
 | 
						||
 | 
						||
            --自动计算位置 并赋值pos
 | 
						||
            if this.GetPos()==0 then
 | 
						||
                PopupTipPanel.ShowTip(Language[10692])
 | 
						||
                return
 | 
						||
            end
 | 
						||
            table.insert(this.choosedList, {heroId = heroData.dynamicId, position=this.GetPos()})
 | 
						||
            this.SetCardsData(this.choosedList)
 | 
						||
        else
 | 
						||
            PopupTipPanel.ShowTip(Language[12206])
 | 
						||
        end
 | 
						||
    end)
 | 
						||
 | 
						||
    Util.AddLongPressClick(go, function()
 | 
						||
        UIManager.OpenPanel(UIName.RoleInfoPopup, heroData)
 | 
						||
    end, 0.5)
 | 
						||
end
 | 
						||
 | 
						||
--计算上阵空余位置 返回最小位置
 | 
						||
function this.GetPos()
 | 
						||
    local data={}
 | 
						||
    for i = 1, 6 do
 | 
						||
        if heroListGo[i].gameObject.activeSelf then
 | 
						||
            table.insert(data,i,i)
 | 
						||
        end
 | 
						||
    end
 | 
						||
    for j = 1, 6 do
 | 
						||
        if data[j]==nil then
 | 
						||
            return j
 | 
						||
        end
 | 
						||
        if LengthOfTable(data) ==6 then
 | 
						||
            return 0
 | 
						||
        end
 | 
						||
    end
 | 
						||
end
 | 
						||
--计算上阵空余位置 返回所有位置列表
 | 
						||
function this.GetPosList()
 | 
						||
    local data={}
 | 
						||
    -- for i = 1, 6 do
 | 
						||
    --     if heroListGo[i].gameObject.activeSelf then
 | 
						||
    --         table.insert(data,i,i)
 | 
						||
    --     end
 | 
						||
    -- end
 | 
						||
    local list={}
 | 
						||
    for j = 1, 6 do
 | 
						||
        if not list[j] then
 | 
						||
            table.insert(list,j)
 | 
						||
        end
 | 
						||
    end
 | 
						||
    return list
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
--拖拽
 | 
						||
function this.OnPointerDown(Pointgo,data)--按下
 | 
						||
    local _j=tonumber(string.sub(Pointgo.transform.name,-1))
 | 
						||
    local heroObj=Util.GetTransform(Pointgo.transform.parent,"Hero".._j)
 | 
						||
    heroObj:DOScale(Vector3.one * 1.2, 0.15)
 | 
						||
    heroObj.transform:SetParent(this.root.transform)
 | 
						||
    heroObj:GetComponent("Image").raycastTarget = false
 | 
						||
end
 | 
						||
function this.OnPointerUp(Pointgo,data)--抬起
 | 
						||
    local _j=tonumber(string.sub(Pointgo.transform.name,-1))
 | 
						||
    Util.Peer(Pointgo.transform,"Pos").transform:SetAsFirstSibling()
 | 
						||
    local heroObj=Util.GetTransform(this.gameObject,"Hero".._j)
 | 
						||
    heroObj:DOScale(Vector3.one * 1, 0.15)
 | 
						||
    heroObj.transform:SetParent(bgListGo[_j].transform)
 | 
						||
    heroObj.transform:SetSiblingIndex(1)--SetAsFirstSibling()
 | 
						||
    heroObj:GetComponent("Image").raycastTarget = false
 | 
						||
end
 | 
						||
function this.OnEndDrag(Pointgo,data)--结束拖动
 | 
						||
    local _j=tonumber(string.sub(Pointgo.transform.name,-1))
 | 
						||
    local heroObj=Util.GetGameObject(this.gameObject,"Hero".._j)
 | 
						||
    if data.pointerEnter==nil then--防止拖到屏幕外
 | 
						||
        heroObj.transform:DOAnchorPos(Vector3.one,0)
 | 
						||
        heroObj.transform:SetParent(bgListGo[_j].transform)
 | 
						||
        heroObj.transform:SetSiblingIndex(1)
 | 
						||
        return
 | 
						||
    end
 | 
						||
    -- Log("<color=blue>被拖动名。。。</color><color=red>"..Pointgo.transform.name.."</color>  ".."  <color=blue>进入的UI名。。。</color><color=red>"..data.pointerEnter.gameObject.name.."</color>")
 | 
						||
    local _i=tonumber(string.sub(data.pointerEnter.gameObject.name,-1))
 | 
						||
    local nameIn=data.pointerEnter.gameObject.name --进入的UI名
 | 
						||
    local _num=string.sub(nameIn,5,-1)
 | 
						||
    local itemName="item".._num
 | 
						||
 | 
						||
    local heroObj=Util.GetGameObject(this.gameObject,"Hero".._j)
 | 
						||
    heroObj:GetComponent("Image").raycastTarget = true
 | 
						||
    heroObj.transform:DOScale(Vector3.one * 1, 0.15)
 | 
						||
    heroObj.transform:DOAnchorPos(Vector3.one,0)
 | 
						||
    heroObj.transform:SetParent(bgListGo[_j].transform)
 | 
						||
    heroObj.transform:SetSiblingIndex(1)
 | 
						||
 | 
						||
    if _i==nil then
 | 
						||
        _i=tonumber(string.sub(Pointgo.transform.name,-1))
 | 
						||
    end
 | 
						||
    if nameIn=="DragView".._i then --有人
 | 
						||
        -- Log("有人")
 | 
						||
        local curData
 | 
						||
        local tarData
 | 
						||
        for i, v in ipairs(this.choosedList) do
 | 
						||
            if _j==v.position then
 | 
						||
                curData=v.heroId
 | 
						||
            end
 | 
						||
            if _i==v.position then
 | 
						||
                tarData=v.heroId
 | 
						||
            end
 | 
						||
        end
 | 
						||
        for i, v in ipairs(this.choosedList) do
 | 
						||
            if _j==v.position then
 | 
						||
                this.choosedList[i].heroId=tarData
 | 
						||
            end
 | 
						||
            if _i==v.position then
 | 
						||
                this.choosedList[i].heroId=curData
 | 
						||
            end
 | 
						||
        end
 | 
						||
    elseif nameIn=="Bg".._i then --没人
 | 
						||
        -- Log("没人")
 | 
						||
        local did
 | 
						||
        for i, v in ipairs(this.choosedList) do
 | 
						||
            if _j==v.position then
 | 
						||
                did=v.heroId
 | 
						||
                table.remove(this.choosedList,i)
 | 
						||
            end
 | 
						||
        end
 | 
						||
        table.insert(this.choosedList, {heroId = did, position=_i})
 | 
						||
    elseif nameIn=="ScrollCycleView" or nameIn==itemName then
 | 
						||
        if not this.opView.NoUpOrDownFormation then
 | 
						||
            this.order=this.order-1
 | 
						||
            for i, v in ipairs(this.choosedList) do
 | 
						||
                if _j==v.position then
 | 
						||
                    table.remove(this.choosedList,i)
 | 
						||
                    dragViewListGo[_j].gameObject:SetActive(false)
 | 
						||
                    break
 | 
						||
                end
 | 
						||
            end
 | 
						||
        else
 | 
						||
            PopupTipPanel.ShowTip(Language[12206])
 | 
						||
        end
 | 
						||
    end
 | 
						||
    this.line.gameObject:SetActive(false)
 | 
						||
    this.SetCardsData()
 | 
						||
    this.OnClickTabBtn(proId)
 | 
						||
end
 | 
						||
function this.OnDrag(Pointgo,data)--拖动中
 | 
						||
    if data.pointerEnter==nil then--拖到屏幕外
 | 
						||
        this.line.transform:SetParent(this.roleGrid.transform)
 | 
						||
        this.line.gameObject:SetActive(false)
 | 
						||
        return
 | 
						||
    end
 | 
						||
    local _i=tonumber(string.sub(data.pointerEnter.gameObject.name,-1))
 | 
						||
    if _i==nil then _i=0 end
 | 
						||
    local nameIn=data.pointerEnter.gameObject.name --进入的UI名
 | 
						||
    this.line:SetActive(nameIn=="DragView".._i or nameIn=="Bg".._i)
 | 
						||
    if nameIn=="DragView".._i then
 | 
						||
        this.line.transform:SetParent(bgListGo[_i].transform)
 | 
						||
    elseif nameIn=="Bg".._i then
 | 
						||
        this.line.transform:SetParent(bgListGo[_i].transform)
 | 
						||
    else
 | 
						||
        this.line.transform:SetParent(this.roleGrid.transform)
 | 
						||
        this.line.gameObject:SetActive(false)
 | 
						||
    end
 | 
						||
    this.line.transform:SetAsFirstSibling()
 | 
						||
    if panelType == FORMATION_TYPE.EXPEDITION then
 | 
						||
    this.line.transform:DOAnchorPos(Vector3.New(0,15,0),0)
 | 
						||
    else
 | 
						||
        this.line.transform:DOAnchorPos(Vector3.New(0,30,0),0)
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
--战力刷新
 | 
						||
function this.RefreshPower()
 | 
						||
    local newPowerNum = this.formationPower
 | 
						||
    if oldPowerNum ~= newPowerNum and oldPowerNum ~= 0 then
 | 
						||
        UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPowerNum,newValue = newPowerNum})
 | 
						||
    end
 | 
						||
    oldPowerNum = this.formationPower
 | 
						||
    -- this.power.text =this.formationPower
 | 
						||
    -- this.RefreshFormation()
 | 
						||
end
 | 
						||
 | 
						||
-- 设置扫荡显示的层级
 | 
						||
function this.SetDrawLevel()
 | 
						||
    local go = this.ElementalResonanceView.gameObject
 | 
						||
    local canvas = go:GetComponent("Canvas")
 | 
						||
    canvas.overrideSorting = false
 | 
						||
end
 | 
						||
 | 
						||
--设置一键上阵
 | 
						||
function this.SetOneKeyGo()
 | 
						||
    --获取需要上阵的位置
 | 
						||
    local posArr=this.GetPosList()
 | 
						||
    -- for i = 1, #posArr do
 | 
						||
    --     Log("可上阵位置索引"..posArr[i])
 | 
						||
    -- end
 | 
						||
    if #posArr==0 then
 | 
						||
        PopupTipPanel.ShowTip(Language[10692])
 | 
						||
        return
 | 
						||
    end
 | 
						||
 | 
						||
    local heros = HeroManager.GetAllHeroDatas(limitLevel)
 | 
						||
    --按战力从大到小排序
 | 
						||
    table.sort(heros,function(a,b)
 | 
						||
        -- local aWarPower = HeroManager.CalculateHeroAllProValList(1,a.dynamicId,false)[HeroProType.WarPower]
 | 
						||
        -- local bWarPower = HeroManager.CalculateHeroAllProValList(1,b.dynamicId,false)[HeroProType.WarPower]
 | 
						||
        -- if aWarPower==bWarPower then
 | 
						||
        --     return a.id>b.id
 | 
						||
        -- else
 | 
						||
        --     return aWarPower>bWarPower
 | 
						||
        -- end
 | 
						||
        if a.warPower == b.warPower then
 | 
						||
            return a.id>b.id
 | 
						||
        else
 | 
						||
            return a.warPower > b.warPower
 | 
						||
        end
 | 
						||
    end)
 | 
						||
    --遍历英雄 去除已上阵英雄
 | 
						||
    -- for j = 1, #this.choosedList do
 | 
						||
    --     for k, v in ipairs(heros) do
 | 
						||
    --         if HeroManager.GetSingleHeroData(v.dynamicId).id== HeroManager.GetSingleHeroData(this.choosedList[j].heroId).id then
 | 
						||
 | 
						||
    --             table.remove(heros,k)
 | 
						||
    --             break
 | 
						||
    --         end
 | 
						||
    --     end
 | 
						||
    -- end
 | 
						||
    -- if #heros == 0 then
 | 
						||
    --     return 
 | 
						||
    -- end
 | 
						||
    --修改 upHeroSidTable 静态id 存储  有则跳过
 | 
						||
    local upHeroSidTable = {}
 | 
						||
    this.order = 0
 | 
						||
    this.choosedList = {}
 | 
						||
    for j = 1, #this.choosedList do
 | 
						||
        local curSingleherodata = HeroManager.GetSingleHeroData(this.choosedList[j].heroId)
 | 
						||
        upHeroSidTable[curSingleherodata.id] = curSingleherodata.id
 | 
						||
    end
 | 
						||
    for k, v in ipairs(heros) do
 | 
						||
        local curSingleherodata = HeroManager.GetSingleHeroData(v.dynamicId)
 | 
						||
        if not upHeroSidTable[curSingleherodata.id] then
 | 
						||
            LogGreen("this.choosedList          "..#this.choosedList)
 | 
						||
            if #this.choosedList < 6 then
 | 
						||
                for n = 1, #posArr do
 | 
						||
                    upHeroSidTable[curSingleherodata.id] = curSingleherodata.id
 | 
						||
                    table.insert(this.choosedList, {heroId = v.dynamicId, position=posArr[n]})
 | 
						||
                    table.remove(posArr,n)
 | 
						||
                    this.order = this.order + 1
 | 
						||
                    break
 | 
						||
                end
 | 
						||
            end
 | 
						||
        end
 | 
						||
    end
 | 
						||
 | 
						||
    --缺几个空位 就上几个空位
 | 
						||
    -- for n = 1, #posArr do
 | 
						||
    --     table.insert(this.choosedList, {heroId = heros[n].dynamicId, position=posArr[n]})
 | 
						||
    -- end
 | 
						||
    -- this.order=this.order+#posArr
 | 
						||
    this.SetCardsData()
 | 
						||
    this.OnClickTabBtn(proId)
 | 
						||
end
 | 
						||
 | 
						||
return FormationPanelV2 |