miduo_client/Assets/ManagedResources/~Lua/Modules/Expedition/View/MonsterFormationInfo.lua

269 lines
10 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

----- 远征怪节点弹窗 -----
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(true)
this.tip = Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
Util.GetGameObject(gameObject, "RoleGrid/FrontImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_hz_RankList_RankBg")
Util.GetGameObject(gameObject, "RoleGrid/BehindImage"):GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_hz_RankList_RankBg")
this.returnLook:GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_hz_zhonghe05_104")
Util.GetGameObject(gameObject, "Power"):GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_hz_shenjiang_15_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()
end)
end
function this:BtnClickEvent()
local x = function()
MonsterCampManager.ExecuteFightBattle(waveId,1,function()
PrivilegeManager.RefreshPrivilegeUsedTimes(data.freeTimeId, 1)
this:SetIcon()
end,curType)
end
if waveId == data.monsterWave then
LogGreen(freeTime..buyTime)
if freeTime <=0 and buyTime <= 0 then
PopupTipPanel.ShowTip("今日已无扫荡次数!")
return
end
if freeTime <= 0 then
if BagManager.GetItemCountById(itemId) < costNum then
PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[itemId].Name))
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)
x()
end)
end,"取消","确定")
else
x()
end
elseif (waveId == data.monsterWave + 1) then
if data.canFightTime > 0 then
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.FOUR_ELEMENT, curType,waveId)
parent:ClosePanel()
else
PopupTipPanel.ShowTip("今日已无可挑战层数!")
end
else
parent:ClosePanel()
end
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:SetIcon()
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)
this.sureBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("Btn_hz_cheng_01")
if waveId == data.monsterWave then
this.tip.text = "扫荡奖励"
if freeTime > 0 then
this.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","免费扫荡")
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("<color=#%s>%s</color>",color,costNum)
this.fightBtnText.text = string.format("<color=#%s>%s</color>",color,"扫荡")
if buyTime < 1 then
Util.SetGray(this.fightBtn,true)
end
end
elseif (waveId == data.monsterWave + 1) then
this.tip.text = "战斗奖励"
this.sureBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("Btn_hz_cheng_01")
this.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","挑 战")
else
this.tip.text = "战斗奖励"
this.fightBtnText.text =string.format("<color=#%s>%s</color>","17232A","确定")
end
end
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()
local rewardIds = {}
if waveId == data.monsterWave then
--扫荡
rewardIds = configData.commonReward
else
rewardIds = configData.firstReward
end
if rewardIds and #rewardIds > 0 then
for i, v in pairs(rewardIds) do
table.insert(rewardData,{v.id,v.num})
end
end
this:FormationAdapter()
end
-- 编队数据匹配
function this:FormationAdapter()
this.titleText.text = string.format("%s层",configData.wave)
this.power.text = configData.power
local bossTeaminfo = configData.monster
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[heroConfig.Star])
local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image")
fg.sprite = this.spLoader:LoadSprite(GetHeroCardStarFg[heroConfig.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,heroConfig.Star)
local name=Util.GetGameObject(o,"Name/Text"):GetComponent("Text")
name.text=heroConfig.ReadingName
local live = Util.GetGameObject(o, "Mask/icon"):GetComponent("RawImage")
local liveName = GetResourcePath(heroConfig.Painting)
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)
zs:GetComponent("Image").sprite = this.spLoader:LoadSprite(zsName)
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
SetHeroFormationFlyEffect(o,this.spLoader,Util.GetGameObject(o,"UI_Effect_jinkuang_KaPai"),heroConfig.Star,sortingOrder)
end
function this:OnClose()
rewardData = {}
end
function this:OnDestroy()
this.spLoader:Destroy()
end
return this