miduo_client/Assets/ManagedResources/~Lua/Modules/Expedition/View/ExpeditionMonsterInfo_Greed...

144 lines
5.8 KiB
Lua
Raw Normal View History

2020-05-25 19:16:23 +08:00
----- 远征贪婪节点弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local fun
--item容器
local itemList = {}
this.Demons = nil
local monsterData = {}
local rewardData = {}
local type = 1 --1 前往 2 放弃
function this:InitComponent(gameObject)
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
this.power = Util.GetGameObject(gameObject, "power"):GetComponent("Text")
this.sureBtn=Util.GetGameObject(gameObject,"sureBtn")
this.sureBtnText=Util.GetGameObject(gameObject,"sureBtn/Text"):GetComponent("Text")
--滚动条根节点
this.root = Util.GetGameObject(gameObject, "Root/Viewport/Content")
this.Demons = Util.GetGameObject(gameObject, "demons/item"..1)
this.backBtn=Util.GetGameObject(gameObject,"BackBtn")
end
function this:BindEvent()
Util.AddClick(this.sureBtn, function()
this:BtnClickEvent()
end)
Util.AddClick(this.backBtn, function()
this:BtnClickEvent()
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]
LogError("monsterData "..monsterData.type.." "..monsterData.sortId)
--组数据
rewardData = {}
local curRewardData = {}
local curNodeConFig = ConfigManager.TryGetConfigData(ConfigName.ExpeditionNodeConfig,monsterData.type)
if curNodeConFig and curNodeConFig.reward and #curNodeConFig.reward > 0 then
for i = 1, #curNodeConFig.reward do
local rewardGroupConfig = ConfigManager.TryGetConfigData(ConfigName.RewardGroup,curNodeConFig.reward[i])
if rewardGroupConfig and #rewardGroupConfig.ShowItem > 0 then
for j = 1, #rewardGroupConfig.ShowItem do
local v = rewardGroupConfig.ShowItem[j]
--table.insert(rewardData,{v[1],v[2]})
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
table.insert(rewardData,v)
end
this:FormationAdapter()
end
-- 编队数据匹配
function this:FormationAdapter()
if type == 1 then
this.sureBtnText.text = "确 定"
elseif type == 2 then
this.sureBtnText.text = "前 往"
end
this.titleText.text="瑶池魔妖"
if monsterData == nil then LogError("远征数据为nil") return end
LogError("monsterData.bossTeaminfo.hero "..#monsterData.bossTeaminfo.hero)
this.power.text = monsterData.bossTeaminfo.totalForce
local monsterCongig = {}
if monsterData.bossTeaminfo.teamInfo and monsterData.bossTeaminfo.teamInfo > 0 then
local monsterGroup = ConfigManager.TryGetConfigData(ConfigName.MonsterGroup,monsterData.bossTeaminfo.teamInfo)
if monsterGroup and monsterGroup.Contents and #monsterGroup.Contents > 0 then
if monsterGroup.Contents[1] and monsterGroup.Contents[1][1] then
monsterCongig = ConfigManager.TryGetConfigData(ConfigName.MonsterConfig,monsterGroup.Contents[1][1])
end
end
if not monsterCongig then LogError("无 monsterCongig") return end
local demon = this.Demons
local demonId = monsterCongig.MonsterId
local starGrid=Util.GetGameObject(demon, "starGrid")
local proImage=Util.GetGameObject(demon, "heroShow/proIcon"):GetComponent("Image")
local posImage=Util.GetGameObject(demon, "heroShow/posIcon"):GetComponent("Image")
local heroStage = Util.GetGameObject(demon, "heroShow/heroStage"):GetComponent("Image")
local roleLevel=Util.GetGameObject(demon, "lvbg/levelText"):GetComponent("Text")
local frameBtn=Util.GetGameObject(demon, "frame")
local hpSlider = Util.GetGameObject(demon, "Slider")
--hpSlider:SetActive(false)
if demonId then
demon:SetActive(true)
local demonData = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId)
Util.GetGameObject(demon, "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(demonData.Icon))
Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(ConfigManager.GetConfigData(ConfigName.HeroConfig,demonId).Star))
SetHeroStars(starGrid, monsterCongig.Quality)
proImage.sprite = Util.LoadSprite(GetProStrImageByProNum(demonData.PropertyName))
posImage.sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(demonData.Profession))
heroStage.sprite = Util.LoadSprite(HeroStageSprite[demonData.HeroStage])
roleLevel.text=monsterCongig.Level
hpSlider:GetComponent("Slider").value = 1
--if monsterData.bossTeaminfo.hero[i].remainHp <= 0 then
-- Util.SetGray(demon,true)
--else
-- Util.SetGray(demon,false)
--end
end
else
LogError("无 monsterData.bossTeaminfo.teamInfo")
end
FindFairyManager.ResetItemView(this.root,this.root.transform,itemList,5,1,sortingOrder,false,rewardData)
end
function this:OnClose()
if fun then
fun()
fun = nil
end
end
function this:OnDestroy()
end
return this