miduo_client/Assets/ManagedResources/~Lua/Modules/Expedition/ExpeditionMonsterInfoPopup.lua

124 lines
5.6 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
local ExpeditionMonsterInfoPopup = Inherit(BasePanel)
local monsterData = {}
--初始化组件(用于子类重写)
function ExpeditionMonsterInfoPopup:InitComponent()
self.btnBack = Util.GetGameObject(self.transform, "tipImage/btnClose")
self.memPower = Util.GetGameObject(self.transform, "tipImage/panel/defendbox/power"):GetComponent("Text")
self.attackCount = Util.GetGameObject(self.transform, "tipImage/panel/defendbox/power"):GetComponent("Text")
self.demonsHeroList=Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/demons")
self.diffDemonsHeroList=Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/diffdemons")
self.DiffDemons = {}
for i = 1, 3 do
table.insert(self.DiffDemons, Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/diffdemons/icon_"..i))
end
self.Demons = {}
for i = 1, 5 do
table.insert(self.Demons, Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/demons/item"..i))
end
self.btnSure = Util.GetGameObject(self.transform, "tipImage/panel/box/btn1")
end
--绑定事件(用于子类重写)
function ExpeditionMonsterInfoPopup:BindEvent()
Util.AddClick(self.btnBack, function()
--PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(self.btnSure, function()
self:ClosePanel()
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.EXPEDITION, monsterData)
end)
end
--添加事件监听(用于子类重写)
function ExpeditionMonsterInfoPopup:AddListener()
end
--移除事件监听(用于子类重写)
function ExpeditionMonsterInfoPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function ExpeditionMonsterInfoPopup:OnOpen(data)
monsterData = data
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ExpeditionMonsterInfoPopup:OnShow()
self:FormationAdapter()
end
-- 编队数据匹配
function ExpeditionMonsterInfoPopup:FormationAdapter()
-- 战斗力
if monsterData == nil then Log("远征数据为nil") return end
self.memPower.text = monsterData.bossTeaminfo.totalForce
for i, demon in ipairs(self.Demons) do
if(monsterData.bossTeaminfo.hero[i]) then
demon:SetActive(true)
local demonId = monsterData.bossTeaminfo.hero[i].heroTid
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, monsterData.bossTeaminfo.hero[i].star)
proImage.sprite = Util.LoadSprite(GetProStrImageByProNum(demonData.PropertyName))
posImage.sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(demonData.Profession))
heroStage.sprite = Util.LoadSprite(HeroStageSprite[demonData.HeroStage])
roleLevel.text=monsterData.bossTeaminfo.hero[i].level
hpSlider:GetComponent("Slider").value = monsterData.bossTeaminfo.hero[i].remainHp
Log("monsterData.bossTeaminfo.hero[i].remainHp "..monsterData.bossTeaminfo.hero[i].remainHp)
if monsterData.bossTeaminfo.hero[i].remainHp <= 0 then
Util.SetGray(demon,true)
else
Util.SetGray(demon,false)
end
--local heroData = {}
--Util.AddOnceClick(frameBtn, function()
-- NetManager.ViewHeroInfoRequest(this._PlayerId,teamInfo.team[i].heroid,function(msg)
-- heroData= GoodFriendManager.GetHeroDatas(msg.hero,msg.force,msg.SpecialEffects)
-- GoodFriendManager.InitEquipData(msg.equip,heroData)
-- UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true)
-- end)
--end)
end
else
demon:SetActive(false)
end
end
-- 异妖
for i, diffDemon in ipairs(self.DiffDemons) do
local demonId = monsterData.bossTeaminfo.PokemonInfos[i]
if demonId then
diffDemon:SetActive(true)
local resId = ConfigManager.GetConfigData(ConfigName.DifferDemonsConfig, demonId).LiveIcon
diffDemon:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(resId))
else
diffDemon:SetActive(false)
end
end
end
--界面关闭时调用(用于子类重写)
function ExpeditionMonsterInfoPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function ExpeditionMonsterInfoPopup:OnDestroy()
end
return ExpeditionMonsterInfoPopup