----- 远征怪节点弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder = 0 --item容器 local itemList = {} local heroListGo = {} local waveId = 0 --当前层 local curType = 1 --当前试炼类型 local configData = {} --当前层的数据表 local data = {} --当前试炼的数据 local rewardData = {} --当前层的奖励 local freeTime = 0 local buyTime = 0 local itemId = 0 local costNum = 0 local storeDataId = 0 local roleConfig = ConfigManager.GetConfig(ConfigName.RoleConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) 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") --滚动条根节点 this.root = Util.GetGameObject(gameObject, "Root") for i = 1, 6 do heroListGo[i] = Util.GetGameObject(gameObject, "RoleGrid/Bg" .. i .. "/Hero" .. i) Util.GetGameObject(gameObject, "RoleGrid/Bg" .. i):GetComponent("Image").sprite = this.spLoader:LoadSprite( CardPosImageName[i]) end this.backBtn = Util.GetGameObject(gameObject, "BackBtn") this.sureBtn = Util.GetGameObject(gameObject, "sureBtn") this.fightBtn = Util.GetGameObject(gameObject, "sureBtn/fightBtn") this.fightBtnText = Util.GetGameObject(this.fightBtn, "Text"):GetComponent("Text") this.fightBtnIcon = Util.GetGameObject(this.fightBtn, "Icon"):GetComponent("Image") this.fightBtnNum = Util.GetGameObject(this.fightBtn, "IconNum"):GetComponent("Text") this.fightBtn.gameObject:SetActive(true) this.returnLook = Util.GetGameObject(gameObject, "returnLook") this.returnLook.gameObject:SetActive(false) this.tip = Util.GetGameObject(gameObject, "tip"):GetComponent("Text") Util.GetGameObject(gameObject, "RoleGrid/FrontImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite( "bd_xinqianpai_zh") Util.GetGameObject(gameObject, "RoleGrid/BehindImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite( "bd_xinhoupai_zh") this.returnLook:GetComponent("Image").sprite = this.spLoader:LoadSprite("s_silingshilian_huifanganniu_zh") Util.GetGameObject(gameObject, "Power"):GetComponent("Image").sprite = this.spLoader:LoadSprite( "t_tongyong-zhanli_zh") end function this:BindEvent() Util.AddClick(this.sureBtn, function() this:BtnClickEvent() end) -- Util.AddClick(this.returnLook, function() -- --faxieyi -- local tempData = {} -- NetManager.GetRePlayData(curType,waveId,function(msg) -- tempData = msg.userRank -- if not tempData or #tempData < 1 then -- PopupTipPanel.ShowTip("无通关记录!") -- else -- UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.FourElementReturnLook,waveId,curType,tempData) -- end -- end) -- end) Util.AddClick(this.backBtn, function() parent:ClosePanel() Game.GlobalEvent:DispatchEvent(GameEvent.MonsterCamp.UpdatePanel) end) end function this:BtnClickEvent() local x = function() NetManager.SweepDemonRequest(waveId, false, function(msg) UIManager.OpenPanel(UIName.RewardItemPopup, msg.Drop, 1, function() PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.MONSTERCAMP_BATTLENUM, 1) Game.GlobalEvent:DispatchEvent(GameEvent.MonsterCamp.UpdatePri) this:SetIcon() CheckRedPointStatus(RedPointType.EpicExplore_MoppingUp) end) end) end if waveId == MonsterCampManager.monsterWave - 1 then LogGreen(freeTime .. buyTime) if freeTime <= 0 and buyTime <= 0 then PopupTipPanel.ShowTip(Language[10683]) return end if freeTime <= 0 then if BagManager.GetItemCountById(itemId) < costNum then PopupTipPanel.ShowTip(string.format(Language[10320], GetLanguageStrById(itemConfig[itemId].Name))) return end MsgPanel.ShowTwo(string.format(Language[10684], costNum, itemConfig[itemId].Name), function() end, function() ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP, storeDataId, 1, function() PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.MONSTERCAMP_BUY_BATTLENUM, 1) x() end) end, Language[10685], Language[10686]) else x() end elseif (waveId == MonsterCampManager.monsterWave) then -- if data.canFightTime > 0 then UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.MONSTER_CAMP) parent:ClosePanel() -- else -- PopupTipPanel.ShowTip("今日已无可挑战层数!") -- end else parent:ClosePanel() end end function this:AddListener() end function this:RemoveListener() end function this:SetIcon() freeTime = MonsterCampManager.GetCanBattleCount() buyTime = MonsterCampManager.GetCanBuyBattleCount() storeDataId, itemId, costNum = MonsterCampManager.MonsterCampGetCost() Util.SetGray(this.sureBtn, false) this.fightBtnIcon.gameObject:SetActive(false) this.fightBtnNum.gameObject:SetActive(false) this.sureBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_button_002") this.tip.text = Language[10073] if waveId == MonsterCampManager.monsterWave - 1 then if freeTime > 0 then this.fightBtnText.text = string.format("%s", "17232A", Language[10687]) else this.fightBtnIcon.gameObject:SetActive(true) this.fightBtnNum.gameObject:SetActive(true) this.fightBtnIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[itemId].ResourceID)) local color = 0 if BagManager.GetItemCountById(itemId) < costNum then color = "E71515" else color = "17232A" end this.fightBtnNum.text = string.format("%s", color, costNum) this.fightBtnText.text = string.format("%s", color, Language[10386]) if buyTime < 1 then Util.SetGray(this.sureBtn, true) end end elseif (waveId == MonsterCampManager.monsterWave) then this.sureBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_button_001") this.fightBtnText.text = string.format("%s", "17232A", Language[10311]) else this.fightBtnText.text = string.format("%s", "17232A", Language[10686]) end end function this:OnShow(_parent, ...) parent = _parent sortingOrder = _parent.sortingOrder --不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参 local args = { ... } waveId = args[1] configData = ConfigManager.GetConfigData(ConfigName.FloodConfig, waveId) this:SetIcon() rewardData = configData.RewardShow this:FormationAdapter() end -- 编队数据匹配 function this:FormationAdapter() this.titleText.text = string.format(Language[10507], configData.Id) this.power.text = configData.Force local bossTeaminfo = ConfigManager.GetConfigData(ConfigName.MonsterGroup, configData.Monster).Contents[1] for i = 1, #heroListGo do if (bossTeaminfo[i]) and bossTeaminfo[i] > 0 then heroListGo[i].transform.parent:GetComponent("Image").sprite = this.spLoader:LoadSprite( "t_chengyuankuang_kuang") this.SetCardSingleData(heroListGo[i], bossTeaminfo[i], i) heroListGo[i]:SetActive(true) else heroListGo[i]:SetActive(false) 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) local yuanImage = Util.GetGameObject(o, "yuanImage") yuanImage:SetActive(false) local hp = Util.GetGameObject(o, "hpProgress") hp:SetActive(false) local rage = Util.GetGameObject(o, "rageProgress") rage:SetActive(false) local monsterconfig = ConfigManager.GetConfigData(ConfigName.MonsterConfig, monsterId) local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, monsterconfig.MonsterId) local bg = Util.GetGameObject(o, "Bg1"):GetComponent("Image") bg.sprite = this.spLoader:LoadSprite(GetHeroCardStarBg[monsterconfig.Star]) local fg = Util.GetGameObject(o, "Bg2"):GetComponent("Image") fg.sprite = this.spLoader:LoadSprite(GetHeroCardStarFg[monsterconfig.Star]) -- local live=Util.GetGameObject(o,"Mask/Live") local lv = Util.GetGameObject(o, "lv/Text"):GetComponent("Text") lv.text = monsterconfig.Level local pro = Util.GetGameObject(o, "Pro/Image"):GetComponent("Image") pro.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName)) local starGrid = Util.GetGameObject(o, "StarGrid") SetCardStars(starGrid, monsterconfig.Star) local name = Util.GetGameObject(o, "Name/Text"):GetComponent("Text") name.text = GetLanguageStrById(heroConfig.ReadingName) 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) live.transform.localScale = Vector3.one live.transform.localPosition = Vector3.zero if heroConfig.Toward == 2 then SetHEeroLiveToward(live, 1) end local zs = Util.GetGameObject(o, "zs") local zsName = GetHeroCardStarZs[monsterconfig.Star] if zsName == "" then zs:SetActive(false) else zs:SetActive(true) zs:GetComponent("Image").sprite = this.spLoader:LoadSprite(zsName) end local effect = Util.GetGameObject(o, "UI_Effect_jinkuang_KaPai") effect.gameObject:SetActive(monsterconfig.Star > 9) SetHeroFormationFlyEffect(o, this.spLoader, effect, monsterconfig.Star, sortingOrder + 1) Util.SetParticleSortLayer(effect.gameObject, sortingOrder + 1) end function this:OnClose() sortingOrder = 0 rewardData = {} end function this:OnDestroy() sortingOrder = 0 this.spLoader:Destroy() end return this