157 lines
6.1 KiB
Lua
157 lines
6.1 KiB
Lua
|
----- 远征招募节点弹窗 -----
|
||
|
local this = {}
|
||
|
--传入父脚本模块
|
||
|
local parent
|
||
|
--传入特效层级
|
||
|
local sortingOrder=0
|
||
|
local fun
|
||
|
--item容器
|
||
|
local itemList = {}
|
||
|
this.Demons = {}
|
||
|
local monsterData = {}
|
||
|
local type = 1 --1 前往 2 放弃
|
||
|
local curSelectHero = nil
|
||
|
local oldSelectHeroGo = nil
|
||
|
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.Demons = {}
|
||
|
for i = 1, 4 do
|
||
|
table.insert(this.Demons, Util.GetGameObject(gameObject, "demons/item"..i))
|
||
|
end
|
||
|
this.backBtn=Util.GetGameObject(gameObject,"BackBtn")
|
||
|
end
|
||
|
|
||
|
function this:BindEvent()
|
||
|
Util.AddClick(this.sureBtn, function()
|
||
|
this:BtnClickEvent()
|
||
|
|
||
|
end)
|
||
|
Util.AddClick(this.backBtn, function()
|
||
|
parent:ClosePanel()
|
||
|
end)
|
||
|
end
|
||
|
function this:BtnClickEvent()
|
||
|
if type == 1 then
|
||
|
parent:ClosePanel()
|
||
|
elseif type == 2 then
|
||
|
if curSelectHero then
|
||
|
--LogError("monsterData.sortId,curSelectHero.dynamicId "..monsterData.sortId.." "..curSelectHero.id)
|
||
|
NetManager.HeroNodeRequest(monsterData.sortId,curSelectHero.id,function (msg)
|
||
|
LogError("#msg.drop.Hero "..#msg.drop.Hero)
|
||
|
if msg.drop and msg.drop.Hero and msg.drop.Hero[1] then
|
||
|
ExpeditionManager.UpdateHeroDatas(msg.drop.Hero[1])
|
||
|
end
|
||
|
parent:ClosePanel()
|
||
|
if fun then
|
||
|
fun()
|
||
|
fun = nil
|
||
|
end
|
||
|
end)
|
||
|
else
|
||
|
PopupTipPanel.ShowTip("请选择要招募的猎妖师!")
|
||
|
end
|
||
|
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]
|
||
|
this.titleText.text="招 募"
|
||
|
if type == 1 then
|
||
|
this.sureBtnText.text = "确 定"
|
||
|
elseif type == 2 then
|
||
|
this.sureBtnText.text = "招 募"
|
||
|
end
|
||
|
curSelectHero = nil
|
||
|
oldSelectHeroGo = nil
|
||
|
if monsterData == nil then LogError("远征数据为nil") return end
|
||
|
NetManager.HeroNodeGetInfoRequest(monsterData.sortId,function (msg)
|
||
|
this:FormationAdapter(msg)
|
||
|
end)
|
||
|
end
|
||
|
-- 编队数据匹配
|
||
|
function this:FormationAdapter(msg)
|
||
|
local allPower = 0
|
||
|
LogError("msg.viewHeroInfo "..#msg.viewHeroInfo)
|
||
|
for i, demon in ipairs(this.Demons) do
|
||
|
if(msg.viewHeroInfo[i]) then
|
||
|
demon:SetActive(true)
|
||
|
local curData = msg.viewHeroInfo[i]
|
||
|
local demonId = curData.hero.heroId
|
||
|
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")
|
||
|
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, curData.hero.star)
|
||
|
proImage.sprite = Util.LoadSprite(GetProStrImageByProNum(demonData.PropertyName))
|
||
|
posImage.sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(demonData.Profession))
|
||
|
--heroStage.sprite = Util.LoadSprite(HeroStageSprite[demonData.HeroStage])
|
||
|
roleLevel.text = curData.hero.level
|
||
|
hpSlider:SetActive(false)
|
||
|
local choosed = Util.GetGameObject(demon, "selectImage")
|
||
|
choosed:SetActive(false)
|
||
|
--hpSlider:GetComponent("Slider").value = 1
|
||
|
--if monsterData.bossTeaminfo.hero[i].remainHp <= 0 then
|
||
|
-- Util.SetGray(demon,true)
|
||
|
--else
|
||
|
-- Util.SetGray(demon,false)
|
||
|
--end
|
||
|
|
||
|
Util.AddOnceClick(frameBtn, function()
|
||
|
if curSelectHero == curData.hero then
|
||
|
choosed:SetActive(false)
|
||
|
curSelectHero = nil
|
||
|
oldSelectHeroGo = nil
|
||
|
return
|
||
|
end
|
||
|
curSelectHero = curData.hero
|
||
|
choosed:SetActive(true)
|
||
|
if oldSelectHeroGo then
|
||
|
Util.GetGameObject(oldSelectHeroGo, "selectImage"):SetActive(false)
|
||
|
end
|
||
|
oldSelectHeroGo = demon
|
||
|
end)
|
||
|
local heroData = {}
|
||
|
Util.AddLongPressClick(frameBtn, function()
|
||
|
--NetManager.ViewHeroInfoRequest(this._PlayerId,teamInfo.team[i].heroid,function(msg)
|
||
|
heroData= GoodFriendManager.GetHeroDatas(curData.hero,curData.force,curData.SpecialEffects)
|
||
|
GoodFriendManager.InitEquipData(curData.equip,heroData)
|
||
|
UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true)
|
||
|
--end)
|
||
|
end, 0.5)
|
||
|
|
||
|
end
|
||
|
--allPower = allPower + curData.force
|
||
|
end
|
||
|
--this.power.text = allPower
|
||
|
end
|
||
|
end
|
||
|
function this:OnClose()
|
||
|
|
||
|
end
|
||
|
function this:OnDestroy()
|
||
|
end
|
||
|
|
||
|
return this
|