miduo_client/Assets/ManagedResources/~Lua/Modules/MonsterCamp/FourElementMonsterCampPanel...

180 lines
7.2 KiB
Lua

require("Base/BasePanel")
FourElementMonsterCampPanel = Inherit(BasePanel)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local this = FourElementMonsterCampPanel
this.monsterInfoList = {}
this.rewardList = {}
this.grid = {}
local curType = 0
local trailData = {}
local callBack
--初始化组件(用于子类重写)
function FourElementMonsterCampPanel:InitComponent()
this.btnBack = Util.GetGameObject(self.gameObject, "InfoRoot/btnBack")
this.help = Util.GetGameObject(self.gameObject, "InfoRoot/help")
this.pre = Util.GetGameObject(self.gameObject, "InfoRoot/pre")
this.grid = Util.GetGameObject(self.gameObject, "InfoRoot/grid")
local rootHight = this.grid.transform.rect.height
local width = this.grid.transform.rect.width
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.grid.transform,
this.pre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(40, 10))
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
this.titleText = Util.GetGameObject(self.gameObject, "InfoRoot/tiitleRoot/title"):GetComponent("Text")
this.canFightWaves = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/canFightWaves"):GetComponent("Text")
this.freeMoppingTimes = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/freeMoppingTimes"):GetComponent("Text")
this.buyMoppingTimes = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/buyMoppingTimes"):GetComponent("Text")
this.addBtn = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/addBtn")
this.btnRank = Util.GetGameObject(self.gameObject, "InfoRoot/btnRank")
this.btnHelpFight = Util.GetGameObject(self.gameObject, "InfoRoot/btnHelpFight")
end
--绑定事件(用于子类重写)
function FourElementMonsterCampPanel:BindEvent()
Util.AddClick(this.btnBack, function ()
self:ClosePanel()
if callBack then callBack() end
end)
Util.AddClick(this.help, function ()
end)
Util.AddClick(this.addBtn, function ()
end)
Util.AddClick(this.btnRank, function ()
end)
Util.AddClick(this.btnHelpFight, function ()
end)
end
--添加事件监听(用于子类重写)
function FourElementMonsterCampPanel:AddListener()
end
--移除事件监听(用于子类重写)
function FourElementMonsterCampPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function FourElementMonsterCampPanel:OnOpen(index)
curType = index
trailData = MonsterCampManager.GetCurFourElementMonsterInfo(index)
end
--界面打开时调用(用于子类重写)
function FourElementMonsterCampPanel:OnShow()
this.titleText.text = FourElementName[curType]
this.canFightWaves.text = "可挑战层数:"..trailData.canFightTime
local freeTimes,buyTimes = MonsterCampManager.GetTimeTip(curType)
this.freeMoppingTimes = "免费扫荡:" ..freeTimes
this.buyMoppingTimes = "购买次数:" ..buyTimes
this.InitMonsterShow()
end
-- 初始化奖励显示
function this.InitShowReward(reward,rewardShow)
local rewardGrid = Util.GetGameObject(reward,"grid")
if not this.rewardList[reward] then
this.rewardList[reward] = {}
end
for i = 1 ,#this.rewardList[reward] do
this.rewardList[reward][i].gameObject:SetActive(false)
end
for i = 1,#rewardShow do
if not this.rewardList[reward][i] then
this.rewardList[reward][i] = SubUIManager.Open(SubUIConfig.ItemView, rewardGrid.transform)
this.rewardList[reward][i].gameObject:SetActive(false)
end
this.rewardList[reward][i]:OnOpen(false, {rewardShow[i].id,rewardShow[i].num}, 0.65,false,false,false)
this.rewardList[reward][i].gameObject:SetActive(true)
end
end
--设置每条英雄数据
function this.SingleHeroDataShow(_go, monConfig,heroData,wave)
local go = _go
local frame=Util.GetGameObject(go,"Bg1"):GetComponent("Image")
local icon=Util.GetGameObject(go, "Mask/icon"):GetComponent("RawImage")
local lv= Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
local pro= Util.GetGameObject(go, "Pro/Image"):GetComponent("Image")
local starGrid = Util.GetGameObject(go, "star")
frame.sprite=Util.LoadSprite(GetHeroQuantityImageByquality(monConfig.Quality,monConfig.Star))
local liveName = heroData.live
icon.texture = CardRendererManager.GetSpineTexture(1, heroData.live, Vector3.one * heroData.scale, Vector3.New(heroData.position[1],heroData.position[2],0), true)
icon.transform.localScale = Vector3.one
icon.transform.localPosition = Vector3.zero
lv.text = monConfig.Level
pro.sprite= Util.LoadSprite(GetProStrImageByProNum(heroData.property))
SetHeroStars(starGrid, monConfig.Star,1,Vector2.New(30,30),-8)
Util.AddOnceClick(go, function()
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.FourElementMonster,curType,wave)
end)
end
function this.SingleDataShow(go, data)
local wave = Util.GetGameObject(go,"bg/leftLayout/num"):GetComponent("Text")
local power = Util.GetGameObject(go,"bg/power/Text"):GetComponent("Text")
local reward = Util.GetGameObject(go,"bg/rewardRect")
local fight = Util.GetGameObject(go,"bg/fight")
local pass = Util.GetGameObject(go,"bg/pass"):GetComponent("Image")
pass.sprite = Util.LoadSprite("")
local hero = Util.GetGameObject(go,"bg/Hero")
wave.text = ""..data.wave..""
power.text = ""..data.power..""
if data.wave < trailData.monsterWave then
pass.gameObject:SetActive(true)
fight.gameObject:SetActive(false)
reward.gameObject:SetActive(false)
else
pass.gameObject:SetActive(false)
if data.wave == trailData.monsterWave then
--设置扫荡按钮
Util.GetGameObject(fight,"mask"):GetComponent("Image").sprite = Util.LoadSprite("r_chouka_button_002")
elseif data.wave == trailData.monsterWave + 1 then
--设置挑战fight
Util.GetGameObject(fight,"mask"):GetComponent("Image").sprite = Util.LoadSprite("r_chouka_button_001")
Util.GetGameObject(fight,"layout/icon").gameObject:SetActive(false)
Util.GetGameObject(fight,"layout/num").gameObject:SetActive(false)
Util.GetGameObject(fight,"layout/Text"):GetComponent("Text").text = "挑战"
this.InitShowReward(reward, data.firstReward)
else
fight.gameObject:SetActive(false)
this.InitShowReward(reward, data.commonReward)
end
end
this.SingleHeroDataShow(hero, data.monsterConfig,data.herodata,data.wave)
end
function this.InitMonsterShow()
local curwaves = trailData.monsterWave + 1 --当前可挑战层
local monsterInfo = MonsterCampManager.GetFourElementMonstersInfo(curType,curwaves)
this.scrollView:SetData(monsterInfo, function (index, go)
this.SingleDataShow(go, monsterInfo[index])
end)
end
--界面关闭时调用(用于子类重写)
function FourElementMonsterCampPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function FourElementMonsterCampPanel:OnDestroy()
this.monsterInfoList = {}
this.rewardList = {}
end
return FourElementMonsterCampPanel