----- 远征怪节点弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local fun --item容器 local itemList = {} local heroListGo = {} local monsterData = {} local rewardData = {} local type = 1 --1 前往 2 放弃 local liveNodes = {} local liveNames = {} local curNodeConFig local roleConfig=ConfigManager.GetConfig(ConfigName.RoleConfig) function this:InitComponent(gameObject) this.spLoader = SpriteLoader.New() this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text") this.power = Util.GetGameObject(gameObject, "Power/Value"):GetComponent("Text") Util.GetGameObject(gameObject, "Power"):GetComponent("Image").sprite = this.spLoader:LoadSprite("t_tongyong-zhanli_zh") this.sureBtn=Util.GetGameObject(gameObject,"sureBtn") this.sureBtn.gameObject:SetActive(true) this.sureBtnText=Util.GetGameObject(gameObject,"sureBtn/Text"):GetComponent("Text") --滚动条根节点 this.root = Util.GetGameObject(gameObject, "Root") heroListGo = {} for i = 1, 6 do heroListGo[i] = Util.GetGameObject(gameObject, "RoleGrid/Bg"..i.."/Hero"..i) end this.backBtn=Util.GetGameObject(gameObject,"BackBtn") end function this:BindEvent() Util.AddClick(this.sureBtn, function() this:BtnClickEvent() end) Util.AddClick(this.backBtn, function() parent:ClosePanel() end) end function this:BtnClickEvent() if type == 1 then parent:ClosePanel() elseif type == 2 then parent:ClosePanel() UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.EXPEDITION, monsterData) end end function this:AddListener() end function this:RemoveListener() end function this:OnShow(_parent,...) parent=_parent sortingOrder = _parent.sortingOrder --不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参 local args = {...} monsterData = args[1] type = args[2] fun = args[3] --组数据 rewardData = {} local curRewardData = {} --curNodeConFig = ConfigManager.TryGetConfigData(ConfigName.ExpeditionNodeConfig,monsterData.type) curNodeConFig = ConfigManager.TryGetConfigData(ConfigName.ExpeditionNodeConfig,monsterData.type) local Reward = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.ExpeditionFloorConfig,"Floor",ExpeditionManager.expeditionLeve,"FloorLay",monsterData.lay - 1) if Reward and Reward.Reward and #Reward.Reward > 0 then for i = 1, #Reward.Reward do local rewardGroupConfig = ConfigManager.TryGetConfigData(ConfigName.RewardGroup,Reward.Reward[i]) if rewardGroupConfig and #rewardGroupConfig.ShowItem > 0 then for j = 1, #rewardGroupConfig.ShowItem do local v = rewardGroupConfig.ShowItem[j] if curRewardData[v[1]] then curRewardData[v[1]] = {v[1],curRewardData[v[1]][2] + v[2]} else curRewardData[v[1]] = {v[1],v[2]} end end end end end for i, v in pairs(curRewardData) do if curNodeConFig and curNodeConFig.Reward and curNodeConFig.Reward > 0 then v = {v[1],math.floor(v[2] * curNodeConFig.Reward)} end table.insert(rewardData,v) end this:FormationAdapter() end -- 编队数据匹配 function this:FormationAdapter() if type == 1 then this.sureBtnText.text = Language[10555] elseif type == 2 then this.sureBtnText.text = Language[10559] end if curNodeConFig then if curNodeConFig.type == ExpeditionNodeType.Common then this.titleText.text=Language[10560] elseif curNodeConFig.type == ExpeditionNodeType.Jy then this.titleText.text=Language[10561] elseif curNodeConFig.type == ExpeditionNodeType.Boss then this.titleText.text=Language[10562] end end if monsterData == nil then LogError(Language[10558]) return end this.power.text = monsterData.bossTeaminfo.totalForce for i = 1, #heroListGo do heroListGo[i]:SetActive(false) end for i = 1, #heroListGo do if(monsterData.bossTeaminfo.hero[i]) then local pos = monsterData.bossTeaminfo.hero[i].position if monsterData.bossTeaminfo.hero[i].remainHp > 0 then this.SetCardSingleData(heroListGo[pos],monsterData.bossTeaminfo.hero[i],pos) heroListGo[pos]:SetActive(true) end end end ResetItemView(this.root,this.root.transform,itemList,5,1,sortingOrder,false,rewardData) end function this.OnSortingOrderChange() for i = 1, #heroListGo do Util.AddParticleSortLayer(heroListGo[i], self.sortingOrder - sortingOrder) end sortingOrder = self.sortingOrder end --设置单个上阵英雄信息 function this.SetCardSingleData(o,monsterId, _pos) o.transform.parent:GetComponent("Image").sprite=this.spLoader:LoadSprite("bd_xinkapaifan") local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, monsterId.heroTid) local bg=Util.GetGameObject(o,"Bg1"):GetComponent("Image") local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image") -- local live=Util.GetGameObject(o,"Mask/Live") local lv=Util.GetGameObject(o,"lv/Text"):GetComponent("Text") local pro=Util.GetGameObject(o,"Pro/Image"):GetComponent("Image") local starGrid=Util.GetGameObject(o,"StarGrid") local nameParent = Util.GetGameObject(o,"Name") -- 用于解决本地化问题 local name=Util.GetGameObject(nameParent,"Text"):GetComponent("Text") -- local pos=Util.GetGameObject(o,"Pos"):GetComponent("Image") local yuanImage=Util.GetGameObject(o,"yuanImage") 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") local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage") live.transform.rotation=Vector3.New(0,0,0) local liveName = GetResourcePath(heroConfig.Live) local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, 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) if heroConfig.Toward==2 then SetHEeroLiveToward(live,1) end live.transform.localScale = Vector3.one live.transform.localPosition = Vector3.zero local zs = Util.GetGameObject(o, "zs") local zsName = GetHeroCardStarZs[monsterId.star] if zsName == "" then zs:SetActive(false) else zs:SetActive(true) zs:GetComponent("Image").sprite = this.spLoader:LoadSprite(zsName) end yuanImage:SetActive(false) lv.text=monsterId.level bg.sprite = this.spLoader:LoadSprite(GetFormationHeroCardStarBg[monsterId.star]) fg.sprite = this.spLoader:LoadSprite(GetHeroCardStarFg[monsterId.star]) pro.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName)) local star,starType = GetStarOrGodSoulLv(1,monsterId) if starType == 3 then if monsterId.star>11 then fg.sprite = this.spLoader:LoadSprite("t_zhandoukuang_lanjin02") else fg.sprite = this.spLoader:LoadSprite("t_zhandoukuang_zhuangshi006") end end SetCardStars(starGrid,star,starType) Util.SetParticleSortLayer(starGrid, sortingOrder + 1) if monsterId.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 --local flyImg=Util.GetGameObject(o,"flyImg"):GetComponent("Image") SetHeroFormationFlyEffect(o,this.spLoader,Util.GetGameObject(o,"UI_Effect_jinkuang_KaPai"),monsterId.star,sortingOrder + 1) name.text=GetLanguageStrById(heroConfig.ReadingName) SetTextVerTial(name.gameObject,Vector3.New(35,-7.45,0),nil,nil,8) local curHeroHpVal = monsterId.remainHp hp.fillAmount = curHeroHpVal hpPass.fillAmount = curHeroHpVal rage.fillAmount = 0.5 end function this:OnClose() if fun then fun() fun = nil end for i, v in pairs(liveNodes) do if v then poolManager:UnLoadLive(liveNames[i],v) liveNames[i]= nil end end end function this:OnDestroy() this.spLoader:Destroy() heroListGo = {} end return this