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

242 lines
8.9 KiB
Lua
Raw Normal View History

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)
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
heroListGo[i] = Util.GetGameObject(gameObject, "RoleGrid/Bg"..i.."/Hero"..i)
end
this.backBtn=Util.GetGameObject(gameObject,"BackBtn")
2020-12-10 16:23:13 +08:00
this.fightBtn=Util.GetGameObject(gameObject,"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)
Util.GetGameObject(gameObject,"sureBtn"):SetActive(false)
2020-12-08 17:01:53 +08:00
end
function this:BindEvent()
2020-12-10 16:23:13 +08:00
Util.AddClick(this.fightBtn, 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()
2020-12-08 17:01:53 +08:00
end)
Util.AddClick(this.backBtn, function()
parent:ClosePanel()
end)
end
function this:BtnClickEvent()
2020-12-21 20:24:36 +08:00
if waveId == data.monsterWave then
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[10343], 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)
MonsterCampManager.ExecuteFightBattle(waveId,2,function()
PrivilegeManager.RefreshPrivilegeUsedTimes(data.freeTimeId, 1)
this:OnShow()
end)
end)
end,"取消","确定")
end
elseif (waveId == data.monsterWave + 1) then
if data.canFightTime > 0 then
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.FOUR_ELEMENT, curType,waveId)
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
2020-12-08 17:01:53 +08:00
function this:OnShow(_parent,...)
parent=_parent
sortingOrder = _parent.sortingOrder
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
2020-12-21 09:51:08 +08:00
local args = {...}
curType = args[1]
waveId = args[2]
2020-12-21 20:24:36 +08:00
freeTime,buyTime = MonsterCampManager.GetTimeTip(curType)
storeDataId,itemId,costNum = MonsterCampManager.GetCost(curType)
2020-12-21 09:51:08 +08:00
configData = MonsterCampManager.GetFourElementMonsterInfoByWave(curType,waveId)
2020-12-21 20:24:36 +08:00
data = MonsterCampManager.GetCurFourElementMonsterInfo(curType)
this.root.gameObject:SetActive(waveId < data.monsterWave)
Util.SetGray(this.fightBtn,false)
this.fightBtnIcon.gameObject:SetActive(false)
this.fightBtnNum.gameObject:SetActive(false)
if waveId == data.monsterWave then
Util.GetGameObject(this.fightBtn,"mask"):GetComponent("Image").sprite = Util.LoadSprite("r_chouka_button_002")
if freeTime > 0 then
this.fightBtnText.text = "免费扫荡"
else
this.fightBtnIcon.gameObject:SetActive(true)
this.fightBtnNum.gameObject:SetActive(true)
this.fightBtnIcon.sprite = Util.LoadSprite(GetResourcePath(itemConfig[itemId]))
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 = "扫荡"
if buyTime < 1 then
Util.SetGray(this.fightBtn,true)
end
end
elseif (waveId == data.monsterWave + 1) then
Util.GetGameObject(this.fightBtn,"mask"):GetComponent("Image").sprite = Util.LoadSprite("r_chouka_button_001")
this.fightBtnText.text = "挑战"
else
this.fightBtnText.text = "确定"
end
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-08 17:01:53 +08:00
2020-12-10 16:23:13 +08:00
local bossTeaminfo = ConfigManager.GetConfigData(ConfigName.MonsterGroup,configData.Monster)
2020-12-08 17:01:53 +08:00
for i = 1, #heroListGo do
2020-12-10 16:23:13 +08:00
if (bossTeaminfo.Contents[1][i]) and bossTeaminfo.Contents[1][i] > 0 then
2020-12-21 20:24:36 +08:00
heroListGo[i].transform.parent:GetComponent("Image").sprite=Util.LoadSprite("t_chengyuankuang_kuang")
this.SetCardSingleData(heroListGo[i],bossTeaminfo.Contents[1][i],i)
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
FindFairyManager.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)
2020-12-21 20:24:36 +08:00
local pos=Util.GetGameObject(o,"Pos"):GetComponent("Image")
pos:SetActive(false)
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")
2020-12-21 20:24:36 +08:00
bg.sprite = Util.LoadSprite(GetHeroCardStarBg[heroConfig.Star])
2020-12-08 17:01:53 +08:00
local fg=Util.GetGameObject(o,"Bg2"):GetComponent("Image")
2020-12-21 20:24:36 +08:00
fg.sprite = Util.LoadSprite(GetHeroCardStarFg[heroConfig.Star])
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")
2020-12-21 20:24:36 +08:00
pro.sprite=Util.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)
zs:GetComponent("Image").sprite = Util.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
end
2020-12-21 20:24:36 +08:00
2020-12-08 17:01:53 +08:00
function this:OnClose()
2020-12-21 20:24:36 +08:00
2020-12-08 17:01:53 +08:00
end
function this:OnDestroy()
end
return this