2020-12-08 17:01:53 +08:00
|
|
|
|
----- 远征怪节点弹窗 -----
|
|
|
|
|
local this = {}
|
|
|
|
|
--传入父脚本模块
|
|
|
|
|
local parent
|
|
|
|
|
--传入特效层级
|
|
|
|
|
local sortingOrder=0
|
2020-12-21 20:24:36 +08:00
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
--item容器
|
|
|
|
|
local itemList = {}
|
|
|
|
|
local heroListGo = {}
|
2020-12-21 20:24:36 +08:00
|
|
|
|
|
2020-12-21 09:51:08 +08:00
|
|
|
|
local waveId = 0 --当前层
|
|
|
|
|
local curType = 1 --当前试炼类型
|
2020-12-21 20:24:36 +08:00
|
|
|
|
local configData = {} --当前层的数据表
|
|
|
|
|
local data = {} --当前试炼的数据
|
|
|
|
|
local rewardData = {} --当前层的奖励
|
|
|
|
|
|
|
|
|
|
local freeTime = 0
|
|
|
|
|
local buyTime = 0
|
|
|
|
|
|
|
|
|
|
local itemId = 0
|
|
|
|
|
local costNum = 0
|
|
|
|
|
local storeDataId = 0
|
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
local roleConfig=ConfigManager.GetConfig(ConfigName.RoleConfig)
|
2020-12-21 20:24:36 +08:00
|
|
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
2020-12-08 17:01:53 +08:00
|
|
|
|
function this:InitComponent(gameObject)
|
2021-08-27 18:39:45 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-12-08 17:01:53 +08:00
|
|
|
|
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
|
|
|
|
|
this.power = Util.GetGameObject(gameObject, "Power/Value"):GetComponent("Text")
|
2020-12-10 16:23:13 +08:00
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
--滚动条根节点
|
|
|
|
|
this.root = Util.GetGameObject(gameObject, "Root")
|
|
|
|
|
for i = 1, 6 do
|
2021-11-05 11:06:10 +08:00
|
|
|
|
heroListGo[i] = Util.GetGameObject(gameObject, "RoleGrid/Bg"..i.."/Hero")
|
2021-08-27 18:39:45 +08:00
|
|
|
|
Util.GetGameObject(gameObject, "RoleGrid/Bg"..i):GetComponent("Image").sprite = this.spLoader:LoadSprite(CardPosImageName[i])
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
|
|
|
|
this.backBtn=Util.GetGameObject(gameObject,"BackBtn")
|
2021-02-22 20:25:58 +08:00
|
|
|
|
this.sureBtn=Util.GetGameObject(gameObject,"sureBtn")
|
|
|
|
|
this.fightBtn=Util.GetGameObject(gameObject,"sureBtn/fightBtn")
|
2020-12-10 16:23:13 +08:00
|
|
|
|
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(true)
|
2021-03-01 19:53:28 +08:00
|
|
|
|
this.tip = Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
|
2021-08-27 18:39:45 +08:00
|
|
|
|
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")
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:BindEvent()
|
2021-02-22 20:25:58 +08:00
|
|
|
|
Util.AddClick(this.sureBtn, function()
|
2020-12-08 17:01:53 +08:00
|
|
|
|
this:BtnClickEvent()
|
2020-12-10 16:23:13 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.returnLook, function()
|
2021-01-04 11:39:58 +08:00
|
|
|
|
--faxieyi
|
|
|
|
|
local tempData = {}
|
2021-02-03 18:40:26 +08:00
|
|
|
|
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)
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.backBtn, function()
|
|
|
|
|
parent:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
function this:BtnClickEvent()
|
2021-02-03 18:40:26 +08:00
|
|
|
|
local x = function()
|
|
|
|
|
MonsterCampManager.ExecuteFightBattle(waveId,1,function()
|
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(data.freeTimeId, 1)
|
2021-02-26 17:44:13 +08:00
|
|
|
|
this:SetIcon()
|
2021-02-03 18:40:26 +08:00
|
|
|
|
end,curType)
|
|
|
|
|
end
|
2020-12-21 20:24:36 +08:00
|
|
|
|
if waveId == data.monsterWave then
|
2021-02-03 18:40:26 +08:00
|
|
|
|
LogGreen(freeTime..buyTime)
|
2020-12-21 20:24:36 +08:00
|
|
|
|
if freeTime <=0 and buyTime <= 0 then
|
|
|
|
|
PopupTipPanel.ShowTip("今日已无扫荡次数!")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if freeTime <= 0 then
|
|
|
|
|
if BagManager.GetItemCountById(itemId) < costNum then
|
2021-08-31 20:22:59 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[itemId].Name))
|
2020-12-21 20:24:36 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
MsgPanel.ShowTwo(string.format("是否花费%s%s购买一次扫荡次数?",costNum,itemConfig[itemId].Name),function() end,function()
|
|
|
|
|
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,storeDataId,1,function()
|
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(data.buyTimeId, 1)
|
2021-02-03 18:40:26 +08:00
|
|
|
|
x()
|
2020-12-21 20:24:36 +08:00
|
|
|
|
end)
|
|
|
|
|
end,"取消","确定")
|
2021-02-03 18:40:26 +08:00
|
|
|
|
else
|
|
|
|
|
x()
|
2020-12-21 20:24:36 +08:00
|
|
|
|
end
|
|
|
|
|
elseif (waveId == data.monsterWave + 1) then
|
|
|
|
|
if data.canFightTime > 0 then
|
|
|
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.FOUR_ELEMENT, curType,waveId)
|
2020-12-22 20:33:35 +08:00
|
|
|
|
parent:ClosePanel()
|
2020-12-21 20:24:36 +08:00
|
|
|
|
else
|
|
|
|
|
PopupTipPanel.ShowTip("今日已无可挑战层数!")
|
|
|
|
|
end
|
|
|
|
|
else
|
2020-12-08 17:01:53 +08:00
|
|
|
|
parent:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:RemoveListener()
|
2020-12-10 16:23:13 +08:00
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
2020-12-21 20:24:36 +08:00
|
|
|
|
|
2021-02-26 17:44:13 +08:00
|
|
|
|
function this:SetIcon()
|
2020-12-21 20:24:36 +08:00
|
|
|
|
freeTime,buyTime = MonsterCampManager.GetTimeTip(curType)
|
|
|
|
|
storeDataId,itemId,costNum = MonsterCampManager.GetCost(curType)
|
|
|
|
|
Util.SetGray(this.fightBtn,false)
|
|
|
|
|
this.fightBtnIcon.gameObject:SetActive(false)
|
|
|
|
|
this.fightBtnNum.gameObject:SetActive(false)
|
2021-08-27 18:39:45 +08:00
|
|
|
|
this.sureBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_button_002")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
if waveId == data.monsterWave then
|
2021-03-01 19:53:28 +08:00
|
|
|
|
this.tip.text = "扫荡奖励"
|
2020-12-21 20:24:36 +08:00
|
|
|
|
if freeTime > 0 then
|
2021-02-26 17:44:13 +08:00
|
|
|
|
this.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","免费扫荡")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
else
|
|
|
|
|
this.fightBtnIcon.gameObject:SetActive(true)
|
|
|
|
|
this.fightBtnNum.gameObject:SetActive(true)
|
2021-08-27 18:39:45 +08:00
|
|
|
|
this.fightBtnIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[itemId].ResourceID))
|
2020-12-21 20:24:36 +08:00
|
|
|
|
local color = 0
|
|
|
|
|
if BagManager.GetItemCountById(itemId) < costNum then
|
|
|
|
|
color = "E71515"
|
|
|
|
|
else
|
|
|
|
|
color = "17232A"
|
|
|
|
|
end
|
|
|
|
|
this.fightBtnNum.text =string.format("<color=#%s>%s</color>",color,costNum)
|
2021-02-07 17:54:48 +08:00
|
|
|
|
this.fightBtnText.text = string.format("<color=#%s>%s</color>",color,"扫荡")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
if buyTime < 1 then
|
|
|
|
|
Util.SetGray(this.fightBtn,true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif (waveId == data.monsterWave + 1) then
|
2021-03-01 19:53:28 +08:00
|
|
|
|
this.tip.text = "战斗奖励"
|
2021-08-27 18:39:45 +08:00
|
|
|
|
this.sureBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_button_001")
|
2021-02-22 20:25:58 +08:00
|
|
|
|
this.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","挑 战")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
else
|
2021-03-01 19:53:28 +08:00
|
|
|
|
this.tip.text = "战斗奖励"
|
2020-12-22 20:33:35 +08:00
|
|
|
|
this.fightBtnText.text =string.format("<color=#%s>%s</color>","17232A","确定")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
end
|
2021-02-26 17:44:13 +08:00
|
|
|
|
end
|
2020-12-21 20:24:36 +08:00
|
|
|
|
|
2021-02-26 17:44:13 +08:00
|
|
|
|
function this:OnShow(_parent,...)
|
|
|
|
|
parent=_parent
|
|
|
|
|
sortingOrder = _parent.sortingOrder
|
|
|
|
|
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
|
|
|
|
|
local args = {...}
|
|
|
|
|
curType = args[1]
|
|
|
|
|
waveId = args[2]
|
|
|
|
|
|
|
|
|
|
configData = MonsterCampManager.GetFourElementMonsterInfoByWave(curType,waveId)
|
|
|
|
|
data = MonsterCampManager.GetCurFourElementMonsterInfo(curType)
|
|
|
|
|
this:SetIcon()
|
2020-12-21 20:24:36 +08:00
|
|
|
|
local rewardIds = {}
|
|
|
|
|
if waveId == data.monsterWave then
|
|
|
|
|
--扫荡
|
|
|
|
|
rewardIds = configData.commonReward
|
|
|
|
|
else
|
|
|
|
|
rewardIds = configData.firstReward
|
|
|
|
|
end
|
2020-12-21 09:51:08 +08:00
|
|
|
|
|
2020-12-21 20:24:36 +08:00
|
|
|
|
if rewardIds and #rewardIds > 0 then
|
|
|
|
|
for i, v in pairs(rewardIds) do
|
|
|
|
|
table.insert(rewardData,{v.id,v.num})
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-12-08 17:01:53 +08:00
|
|
|
|
this:FormationAdapter()
|
|
|
|
|
end
|
|
|
|
|
-- 编队数据匹配
|
|
|
|
|
function this:FormationAdapter()
|
2020-12-21 09:51:08 +08:00
|
|
|
|
this.titleText.text = string.format("%s层",configData.wave)
|
|
|
|
|
this.power.text = configData.power
|
2020-12-22 20:33:35 +08:00
|
|
|
|
local bossTeaminfo = configData.monster
|
2020-12-08 17:01:53 +08:00
|
|
|
|
for i = 1, #heroListGo do
|
2020-12-22 20:33:35 +08:00
|
|
|
|
if (bossTeaminfo[i]) and bossTeaminfo[i] > 0 then
|
2021-08-27 18:39:45 +08:00
|
|
|
|
heroListGo[i].transform.parent:GetComponent("Image").sprite=this.spLoader:LoadSprite("t_chengyuankuang_kuang")
|
2020-12-22 20:33:35 +08:00
|
|
|
|
this.SetCardSingleData(heroListGo[i],bossTeaminfo[i],i)
|
2020-12-21 20:24:36 +08:00
|
|
|
|
heroListGo[i]:SetActive(true)
|
2020-12-10 16:23:13 +08:00
|
|
|
|
else
|
|
|
|
|
heroListGo[i]:SetActive(false)
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-26 14:27:24 +08:00
|
|
|
|
ResetItemView(this.root,this.root.transform,itemList,5,1,sortingOrder,false,rewardData)
|
2020-12-08 17:01:53 +08:00
|
|
|
|
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)
|
2020-12-21 20:24:36 +08:00
|
|
|
|
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)
|
|
|
|
|
|
2020-12-10 16:23:13 +08:00
|
|
|
|
local monsterconfig = ConfigManager.GetConfigData(ConfigName.MonsterConfig, monsterId)
|
|
|
|
|
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, monsterconfig.MonsterId)
|
2020-12-21 20:24:36 +08:00
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
local bg=Util.GetGameObject(o,"Bg1"):GetComponent("Image")
|
2021-08-27 18:39:45 +08:00
|
|
|
|
bg.sprite = this.spLoader:LoadSprite(GetHeroCardStarBg[heroConfig.Star])
|
2020-12-08 17:01:53 +08:00
|
|
|
|
local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image")
|
2021-08-27 18:39:45 +08:00
|
|
|
|
fg.sprite = this.spLoader:LoadSprite(GetHeroCardStarFg[heroConfig.Star])
|
2020-12-21 20:24:36 +08:00
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
-- local live=Util.GetGameObject(o,"Mask/Live")
|
|
|
|
|
local lv=Util.GetGameObject(o,"lv/Text"):GetComponent("Text")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
lv.text=monsterconfig.Level
|
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
local pro=Util.GetGameObject(o,"Pro/Image"):GetComponent("Image")
|
2021-08-27 18:39:45 +08:00
|
|
|
|
pro.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName))
|
2020-12-08 17:01:53 +08:00
|
|
|
|
local starGrid=Util.GetGameObject(o,"StarGrid")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
SetCardStars(starGrid,heroConfig.Star)
|
2020-12-08 17:01:53 +08:00
|
|
|
|
local name=Util.GetGameObject(o,"Name/Text"):GetComponent("Text")
|
2020-12-21 20:24:36 +08:00
|
|
|
|
name.text=heroConfig.ReadingName
|
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
local zs = Util.GetGameObject(o, "zs")
|
|
|
|
|
local zsName = GetHeroCardStarZs[heroConfig.Star]
|
|
|
|
|
if zsName == "" then
|
|
|
|
|
zs:SetActive(false)
|
|
|
|
|
else
|
|
|
|
|
zs:SetActive(true)
|
2021-08-27 18:39:45 +08:00
|
|
|
|
zs:GetComponent("Image").sprite = this.spLoader:LoadSprite(zsName)
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if heroConfig.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
|
2022-01-05 18:17:44 +08:00
|
|
|
|
SetHeroFormationFlyEffect(o,this.spLoader,Util.GetGameObject(o,"UI_Effect_jinkuang_KaPai"),heroConfig.Star,sortingOrder)
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
2020-12-21 20:24:36 +08:00
|
|
|
|
|
2020-12-08 17:01:53 +08:00
|
|
|
|
function this:OnClose()
|
2020-12-22 20:33:35 +08:00
|
|
|
|
rewardData = {}
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnDestroy()
|
2021-08-27 18:39:45 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-12-08 17:01:53 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|