171 lines
6.7 KiB
Lua
171 lines
6.7 KiB
Lua
require("Base/BasePanel")
|
|
MonsterCampMainPanel = Inherit(BasePanel)
|
|
local this = MonsterCampMainPanel
|
|
local orginLayer
|
|
local monsterGroup = ConfigManager.GetConfig(ConfigName.MonsterGroup)
|
|
local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
|
|
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
|
|
local campTowerSetting = ConfigManager.GetConfigDataByKey(ConfigName.CampTowerSetting,"Id",1)
|
|
local trails = {}
|
|
local redTrailType = {
|
|
[1] = RedPointType.PersonTrail,
|
|
[2] = RedPointType.BuddishTrail,
|
|
[3] = RedPointType.DemonTrail,
|
|
[4] = RedPointType.TaoistTrail,
|
|
}
|
|
--初始化组件(用于子类重写)
|
|
function MonsterCampMainPanel:InitComponent()
|
|
orginLayer = 0
|
|
this.spLoader = SpriteLoader.New()
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
|
|
this.waveNum = Util.GetGameObject(self.gameObject, "Bg/BgRoot/waveImg/wave"):GetComponent("Text")
|
|
this.nextWave = Util.GetGameObject(self.gameObject, "Bg/btnWave")
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
|
|
|
|
for i = 1 ,4 do
|
|
table.insert(trails,Util.GetGameObject(self.gameObject, "Bg/SiLingDi/trail"..i))
|
|
end
|
|
this.btnShenYing = Util.GetGameObject(self.gameObject, "Bg/SiLingDi/shenyingPro")
|
|
this.btnShenYing:GetComponent("Image").sprite = this.spLoader:LoadSprite("j_jianmushenshu_anniu_02_zh")
|
|
this.btnShenYingText = Util.GetGameObject(this.btnShenYing, "Text"):GetComponent("Text")
|
|
this.shenYingProgressText = Util.GetGameObject(self.gameObject, "Bg/SiLingDi/progress/Text"):GetComponent("Text")
|
|
this.shenYingProgressIma = Util.GetGameObject(self.gameObject, "Bg/SiLingDi/progress/Image"):GetComponent("Image")
|
|
this.shenYingProgress = Util.GetGameObject(self.gameObject, "Bg/SiLingDi/progress")
|
|
this.btnShenYing:SetActive(false)
|
|
this.shenYingProgress:SetActive(false)
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function MonsterCampMainPanel:BindEvent()
|
|
Util.AddClick(this.btnBack, function ()
|
|
-- PlayerManager.carbonType = 1
|
|
self:ClosePanel()
|
|
end)
|
|
|
|
Util.AddClick(this.nextWave, function ()
|
|
JumpManager.GoJump(1011)
|
|
end)
|
|
|
|
Util.AddClick(this.btnShenYing, function ()
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.ShenYingShuXing)
|
|
end)
|
|
|
|
for i = 1 ,#trails do
|
|
BindRedPointObject(redTrailType[i],Util.GetGameObject(trails[i],"redPoint"))
|
|
end
|
|
|
|
BindRedPointObject(RedPointType.HeartDemon,Util.GetGameObject(self.gameObject, "Bg/BgRoot/redPoint"))
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function MonsterCampMainPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.FourEle.RefreshView, this.OnShow)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function MonsterCampMainPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.FourEle.RefreshView, this.OnShow)
|
|
end
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function MonsterCampMainPanel:OnOpen(...)
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.MonsterCamp })
|
|
end
|
|
|
|
function MonsterCampMainPanel:OnShow()
|
|
local totalWaves = MonsterCampManager.GetFourElementTotalWave()
|
|
local nextWaves = SacredTreeManager.NextAttriFloor()
|
|
this.waveNum.text = MonsterCampManager.monsterWave
|
|
this.btnShenYingText.text = SacredTreeManager.CulAttri().."/"..#attriConfig.PropertyUnlcokLevels
|
|
this.shenYingProgressText.text = string.format("四灵试炼进度:%d/%d",totalWaves,nextWaves)
|
|
this.shenYingProgressIma.fillAmount = totalWaves/nextWaves
|
|
for i = 1,#trails do
|
|
local singleFourElementData = MonsterCampManager.GetCurFourElementMonsterInfo(i)
|
|
this:SetSingleTrailData(trails[i],singleFourElementData)
|
|
end
|
|
|
|
local waves = MonsterCampManager.GetFourElementTotalWave()
|
|
if not PlayerPrefs.HasKey("FourElement"..PlayerManager.uid) then
|
|
PlayerPrefs.SetInt("FourElement"..PlayerManager.uid,-1)
|
|
end
|
|
if waves ~= PlayerPrefs.GetInt("FourElement"..PlayerManager.uid) then
|
|
PlayerPrefs.SetInt("FourElement"..PlayerManager.uid,waves)
|
|
local propertyId = SacredTreeManager.GetUnLockNewProperty(waves)
|
|
if propertyId > 0 then
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,nil,nil,nil,CompShowType.fourElement,nil,nil,nil,propertyId)
|
|
end
|
|
end
|
|
end
|
|
|
|
function this:GetOpenTime(id)
|
|
local str = nil
|
|
local isFunction = false
|
|
local config = ConfigManager.GetConfigData(ConfigName.CampTowerSetting,1)
|
|
if config then
|
|
for k,v in ipairs(config.CampOpenDay) do
|
|
isFunction = false
|
|
for n,m in ipairs(v) do
|
|
if tonumber(n) == 1 and tonumber(m) == id then
|
|
isFunction = true
|
|
else
|
|
if isFunction then
|
|
if str then
|
|
str =str.. Language[10336]..NumConvertWeek[tonumber(m)]
|
|
else
|
|
str = Language[10337]..NumConvertWeek[tonumber(m)]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return str
|
|
end
|
|
|
|
function MonsterCampMainPanel:SetSingleTrailData(go,data)
|
|
local title = Util.GetGameObject(go, "title"):GetComponent("Image")
|
|
local curwave = Util.GetGameObject(go, "curwave"):GetComponent("Text")
|
|
local canFightWave = Util.GetGameObject(go, "canFightWave"):GetComponent("Text")
|
|
local openTime = Util.GetGameObject(go, "openTime"):GetComponent("Text")
|
|
title.sprite = this.spLoader:LoadSprite(FourElementNameImage[data.fourElementType])
|
|
curwave.text = (data.monsterWave + 1).."层"
|
|
if data.canFightTime >= campTowerSetting.TimesStoreMax then
|
|
canFightWave.text = data.canFightTime
|
|
else
|
|
canFightWave.text = data.canFightTime
|
|
end
|
|
|
|
openTime.text = this:GetOpenTime(data.fourElementType).."开启"
|
|
Util.SetGray(go, data.openState == 0)
|
|
Util.AddOnceClick(go,function()
|
|
if data.openState == 1 then
|
|
UIManager.OpenPanel(UIName.FourElementMonsterCampPanel,data.fourElementType)
|
|
else
|
|
PopupTipPanel.ShowTip("未在开启时间内!")
|
|
end
|
|
end)
|
|
end
|
|
|
|
function MonsterCampMainPanel:OnSortingOrderChange()
|
|
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function MonsterCampMainPanel:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function MonsterCampMainPanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
SubUIManager.Close(this.UpView)
|
|
trails = {}
|
|
for i = 1 ,#trails do
|
|
ClearRedPointObject(redTrailType[i],Util.GetGameObject(trails[i],"redPoint"))
|
|
end
|
|
ClearRedPointObject(RedPointType.HeartDemon,Util.GetGameObject(self.gameObject, "Bg/BgRoot/redPoint"))
|
|
end
|
|
|
|
return MonsterCampMainPanel |