miduo_client/Assets/ManagedResources/~Lua/Modules/JumpServer/JumpServerPanel.lua

250 lines
9.0 KiB
Lua
Raw Normal View History

2021-06-15 20:08:14 +08:00
require("Base/BasePanel")
JumpServerPanel = Inherit(BasePanel)
local this = JumpServerPanel
local orginLayer = 0
local carbons = {}
local carbonsRedPoint = {}
local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
local type = {
[1] = {
id = JumpServer_Type.HightLadder, --跨服天梯
bg = "r_Dungeon_rendi_01",
name = "k_kuafuwanfa_luofuzhengfeng",
live = "m_chsm_0035_png",
livePos = Vector2(274.5, -408.1),
liveSize = Vector2(1612, 1802),
tipBg = "r_Dungeon_juqingdian",
resetTime = string.format("<color=#BA9AC2>%s</color>",specialConfig[97].Value),
tip = string.format("<color=#BA9AC2>%s</color>",specialConfig[97].Value),
redPointType = RedPointType.JumpServer_HightLadder
},
[2] = {
id = -1,
bg = "r_Dungeon_rendi_01"
},
[3] = {
id = -1,
bg = "r_Dungeon_rendi_01"
},
[4] = {
id = -1,
bg = "r_Dungeon_rendi_01"
},
}
2021-07-14 15:08:54 +08:00
local state,tipStr
2021-06-15 20:08:14 +08:00
--初始化组件(用于子类重写)
function JumpServerPanel:InitComponent()
2021-06-25 15:23:55 +08:00
this.spLoader = SpriteLoader.New()
2021-06-15 20:08:14 +08:00
-- 屏幕适配修改
this.btnRoot = Util.GetGameObject(self.gameObject, "btnRoot")
this.btnRoot.transform.localScale = Vector3.one * UIManager.adapterScale
carbons = {}
carbonsRedPoint = {}
this.hightLadderBtn = Util.GetGameObject(self.gameObject, "btnRoot/circle/root/HightLadderBtn")
table.insert(carbons, this.hightLadderBtn)
table.insert(carbonsRedPoint, Util.GetGameObject(this.hightLadderBtn, "bg/carbon/redPoint"))
this.otherBtn1 = Util.GetGameObject(self.gameObject, "btnRoot/circle/root/otherBtn1")
table.insert(carbons, this.otherBtn1)
table.insert(carbonsRedPoint, Util.GetGameObject(this.otherBtn1, "bg/carbon/redPoint"))
this.otherBtn2 = Util.GetGameObject(self.gameObject, "btnRoot/circle/root/otherBtn2")
table.insert(carbons, this.otherBtn2)
table.insert(carbonsRedPoint, Util.GetGameObject(this.otherBtn2, "bg/carbon/redPoint"))
this.otherBtn3 = Util.GetGameObject(self.gameObject, "btnRoot/circle/root/otherBtn3")
table.insert(carbons, this.otherBtn3)
table.insert(carbonsRedPoint, Util.GetGameObject(this.otherBtn3, "bg/carbon/redPoint"))
this.effect = Util.GetGameObject(self.gameObject, "CarbonTypePanel_effect")
this.wind = Util.GetGameObject(self.gameObject, "CarbonTypePanel_effect/juneng_chenggong/GameObject")
orginLayer = 0
this.backBtn = Util.GetGameObject(self.gameObject, "backBtn")
this.AnimRoot = Util.GetGameObject(self.gameObject, "btnRoot/circle/root")
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
end
--绑定事件(用于子类重写)
function JumpServerPanel:BindEvent()
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
for i = 1, #type do
if type[i].redPointType and carbons[i] then
BindRedPointObject(type[i].redPointType, carbonsRedPoint[i])
end
end
end
--添加事件监听(用于子类重写)
function JumpServerPanel:AddListener()
end
--移除事件监听(用于子类重写)
function JumpServerPanel:RemoveListener()
end
--跨服
function JumpServerPanel:OnOpen()
2021-07-13 11:28:36 +08:00
this.UpView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main})
2021-06-15 20:08:14 +08:00
end
--界面打开时调用(用于子类重写)
function JumpServerPanel:OnShow(...)
for i = 1, #type do
if type[i].redPointType and carbons[i] then
CheckRedPointStatus(type[i].redPointType)
end
end
this.UpdateCarbonContent()
-- 音效
-- SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
end
function this.UpdateCarbonContent()
for k,v in ipairs(carbons) do
local data = type[k]
2021-06-25 15:23:55 +08:00
Util.GetGameObject(v, "bg"):GetComponent("Image").sprite = this.spLoader:LoadSprite(data.bg)
2021-06-15 20:08:14 +08:00
if data.id == -1 then
Util.GetGameObject(v, "bg/carbon"):SetActive(false)
Util.GetGameObject(v, "bg/InfoBg"):SetActive(false)
Util.GetGameObject(v, "bg/Text").gameObject:SetActive(true)
v:GetComponent("Button").enabled = false
2021-07-14 15:08:54 +08:00
Util.SetGray(v,true)
2021-06-15 20:08:14 +08:00
else
Util.GetGameObject(v, "bg/carbon"):SetActive(true)
Util.GetGameObject(v, "bg/InfoBg"):SetActive(true)
Util.GetGameObject(v, "bg/InfoBg/InfoBg"):SetActive(false)
Util.GetGameObject(v, "bg/Text").gameObject:SetActive(false)
v:GetComponent("Button").enabled = true
local live = Util.GetGameObject(v, "bg/carbon/Live")
local name = Util.GetGameObject(v, "bg/carbon/Name")
local timeReset = Util.GetGameObject(v, "bg/InfoBg/timeReset")
-- local di = Util.GetGameObject(v, "bg/InfoBg/InfoBg/Image")
-- local dropContent = Util.GetGameObject(v, "bg/InfoBg/InfoBg/dropContent")
2021-06-25 15:23:55 +08:00
live:GetComponent("Image").sprite =this.spLoader:LoadSprite(data.live)
2021-06-15 20:08:14 +08:00
live:GetComponent("RectTransform").localPosition = data.livePos
live:GetComponent("RectTransform").sizeDelta = data.liveSize
2021-06-25 15:23:55 +08:00
name:GetComponent("Image").sprite = this.spLoader:LoadSprite(data.name)
2021-06-15 20:08:14 +08:00
timeReset:GetComponent("Text").text =string.format(data.resetTime)
2021-07-14 15:08:54 +08:00
this.SystemState(data.id,function()
if state < 0 then
timeReset:GetComponent("Text").text = tipStr
end
if state < 0 then
Util.SetGray(v,true)
else
Util.SetGray(v,false)
end
end)
2021-06-15 20:08:14 +08:00
-- dropContent:GetComponent("Text").text =string.format(data.tip)
2021-06-25 15:23:55 +08:00
-- di:GetComponent("Image").sprite = this.spLoader:LoadSprite(data.tipBg)
2021-06-15 20:08:14 +08:00
Util.AddOnceClick(v,function()
this.BtnClick(data.id)
end)
end
2021-07-14 15:08:54 +08:00
end
end
function this.BtnClick(id)
if id == JumpServer_Type.HightLadder then
-- this.SystemState(id,function()
if state == 1 then
UIManager.OpenPanel(UIName.JumpServerHightLadderPanel)
2021-06-15 20:08:14 +08:00
else
2021-07-14 15:08:54 +08:00
PopupTipPanel.ShowTip(tipStr)
2021-06-15 20:08:14 +08:00
end
2021-07-14 15:08:54 +08:00
-- end)
else
PopupTipPanel.ShowTip("敬请期待")
2021-06-15 20:08:14 +08:00
end
end
2021-07-14 15:08:54 +08:00
function this:OnSortingOrderChange()
Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.wind, self.sortingOrder - orginLayer)
end
function this.SystemState(id,fun)
2021-06-15 20:08:14 +08:00
if id == JumpServer_Type.HightLadder then
2021-07-14 15:48:34 +08:00
if not ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.JumpServer_HightLadder) then
2021-07-14 15:08:54 +08:00
state = -1
tipStr = ActTimeCtrlManager.GetFuncTip( FUNCTION_OPEN_TYPE.JumpServer_HightLadder)
if fun then
fun()
fun = nil
end
2021-07-14 17:41:26 +08:00
return
end
2021-06-15 20:08:14 +08:00
local conFigWorldLevel = ConfigManager.GetConfigData(ConfigName.MServerArenaSetting,1).WorldLevel
if PlayerManager.worldLeve < conFigWorldLevel then --如果世界等级不足
2021-07-14 15:08:54 +08:00
state = -2
tipStr = string.format("世界等级到达%s后开启",conFigWorldLevel)
if fun then
fun()
fun = nil
end
2021-07-14 17:41:26 +08:00
return
2021-06-15 20:08:14 +08:00
end
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.JumpServer_HightLadder) == false then --如果未解锁
2021-07-14 15:08:54 +08:00
state = -3
tipStr = "赛季过渡中!"
if fun then
fun()
fun = nil
end
2021-07-14 17:41:26 +08:00
return
2021-06-15 20:08:14 +08:00
end
JumpServerManager.GetWorldArenaInfoRequest(function()
2021-07-14 15:08:54 +08:00
if not JumpServerManager.GetHightLadderDataIsStart() then
state = -4
tipStr = string.format("开服第%s周开放",ConfigManager.GetConfigData(ConfigName.MServerArenaSetting,1).OpenWeek)
if fun then
fun()
fun = nil
end
2021-07-14 17:41:26 +08:00
return
2021-07-14 15:08:54 +08:00
elseif not JumpServerManager.GetHightLadderDataIsGroup() then
state = -5
tipStr = "未划分跨服分组,无法参与!"
if fun then
fun()
fun = nil
end
2021-07-14 17:41:26 +08:00
return
2021-07-13 11:28:36 +08:00
else
2021-07-14 15:08:54 +08:00
state = 1
tipStr = ""
if fun then
fun()
fun = nil
end
2021-07-14 17:41:26 +08:00
return
2021-06-15 20:08:14 +08:00
end
end)
else
2021-07-14 15:08:54 +08:00
-- PopupTipPanel.ShowTip("敬请期待")
return -6,"敬请期待"
2021-06-15 20:08:14 +08:00
end
end
--界面关闭时调用(用于子类重写)
function JumpServerPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function JumpServerPanel:OnDestroy()
carbons = {}
for i = 1, #type do
if type[i].redPointType and carbons[i] then
ClearRedPointObject(type[i].redPointType, carbonsRedPoint[i])
end
end
2021-06-25 15:23:55 +08:00
this.spLoader:Destroy()
2021-06-15 20:08:14 +08:00
end
return JumpServerPanel