miduo_client/Assets/ManagedResources/~Lua/Modules/Carbon/XuanYuanMirrorPanel.lua

222 lines
7.2 KiB
Lua
Raw Normal View History

2020-07-15 16:27:58 +08:00
require("Base/BasePanel")
2020-07-16 20:24:28 +08:00
XuanYuanMirrorPanel = Inherit(BasePanel)
2020-08-05 15:00:56 +08:00
local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
2020-07-16 20:24:28 +08:00
local this = XuanYuanMirrorPanel
2020-07-15 16:27:58 +08:00
local hasFresh = false
local orginLayer = 0
2020-08-05 15:00:56 +08:00
local type = {
[1] = {
id = FUNCTION_OPEN_TYPE.PEOPLE_MIRROR, --人杰
bg = "ui_fb_btn_jy",
name = "人杰宝镜",
gameObject = "btnRoot/circle/root/renjiebaojing" ,
redPointType = RedPointType.People_Mirror
},
[2] = {
id = FUNCTION_OPEN_TYPE.BUDDHIST_MIRROR, --佛禅
bg = "ui_fb_btn_gh",
name = "佛禅宝镜",
gameObject = "btnRoot/circle/root/fuochanbaojing" ,
redPointType = RedPointType.Buddhist_Mirror
},
[3] = {
id = FUNCTION_OPEN_TYPE.MAGIC_MIRROR, --妖灵
bg = "ui_fb_btn_sl",
name = "妖灵宝镜",
gameObject = "btnRoot/circle/root/yaolingbaojing" ,
redPointType = RedPointType.Magic_Mirror
},
[4] = {
id = FUNCTION_OPEN_TYPE.TAOIST_MIRROR, --道玄
bg = "ui_fb_btn_jq",
name = "道玄宝镜",
gameObject = "btnRoot/circle/root/daoxuanbaojing" ,
redPointType = RedPointType.Buddhist_Mirror
},
}
2020-07-15 16:27:58 +08:00
--初始化组件(用于子类重写)
2020-07-16 20:24:28 +08:00
function this:InitComponent()
this.btnHelp = Util.GetGameObject(self.gameObject, "btnRoot/btnhelp")
this.helpPosition = this.btnHelp:GetComponent("RectTransform").localPosition
this.btnRank = Util.GetGameObject(self.gameObject, "btnRoot/btnRank")
this.btnReward = Util.GetGameObject(self.gameObject, "btnRoot/btnReward")
this.btnClose = Util.GetGameObject(self.gameObject, "btnRoot/btnBack")
this.remainTimes = Util.GetGameObject(self.gameObject, "remainTimes") :GetComponent("Text")
2020-07-15 16:27:58 +08:00
this.effect = Util.GetGameObject(self.gameObject, "CarbonTypePanel_effect")
this.wind = Util.GetGameObject(self.gameObject, "CarbonTypePanel_effect/juneng_chenggong/GameObject")
orginLayer = 0
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
this.AnimRoot = Util.GetGameObject(self.gameObject, "btnRoot/circle/root")
end
local index = 1
--绑定事件(用于子类重写)
2020-07-16 20:24:28 +08:00
function this:BindEvent()
Util.AddClick(this.btnHelp, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.XuanYuanMirror,this.helpPosition.x,this.helpPosition.y)
2020-07-15 16:27:58 +08:00
end)
2020-07-16 20:24:28 +08:00
Util.AddClick(this.btnRank, function()
2020-07-15 16:27:58 +08:00
end)
2020-07-16 20:24:28 +08:00
Util.AddClick(this.btnReward, function()
end)
Util.AddClick(this.btnClose, function()
this:OnClose()
2020-07-15 16:27:58 +08:00
end)
end
--添加事件监听(用于子类重写)
2020-07-16 20:24:28 +08:00
function this:AddListener()
2020-08-05 21:01:20 +08:00
-- Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionOpen, this.FreshIconShow)
-- Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionClose, this.FreshIconShow)
2020-07-15 16:27:58 +08:00
end
--移除事件监听(用于子类重写)
2020-07-16 20:24:28 +08:00
function this:RemoveListener()
2020-08-05 21:01:20 +08:00
-- Game.GlobalEvent:RemoveEvent(GameEvent.FunctionCtrl.OnFunctionOpen, this.FreshIconShow)
-- Game.GlobalEvent:RemoveEvent(GameEvent.FunctionCtrl.OnFunctionClose, this.FreshIconShow)
2020-07-15 16:27:58 +08:00
end
2020-07-16 20:24:28 +08:00
function this:OnOpen()
2020-07-15 16:27:58 +08:00
this.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
end
--界面打开时调用(用于子类重写)
2020-07-16 20:24:28 +08:00
function this:OnShow(...)
2020-08-05 15:00:56 +08:00
this:UpdateCarbonContent()
2020-07-25 20:42:11 +08:00
this.remainTimes = Language[12249]..5
2020-07-15 16:27:58 +08:00
-- 音效
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
-- 播放动画
2020-07-16 20:24:28 +08:00
this:PlayAni()
2020-07-15 16:27:58 +08:00
this.PlayScaleAnim()
end
2020-08-05 15:00:56 +08:00
function this:BtnAction(_type)
2020-08-05 21:01:20 +08:00
-- if ActTimeCtrlManager.SingleFuncState(_type) then
-- UIManager.OpenPanel(UIName.XuanYuanMirrorPanelList,_type,XuanYuanMirrorManager.GetMirrorData(_type))
-- else
-- PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(_type))
-- end
UIManager.OpenPanel(UIName.XuanYuanMirrorPanelList,_type,XuanYuanMirrorManager.GetMirrorData(_type))
2020-08-05 15:00:56 +08:00
end
function this:GetOpenTime(id)
2020-08-05 21:01:20 +08:00
local str = nil
-- local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,68)
-- if config then
-- for k,v in ipairs(string.split(config.Value,"|")) do
-- local isFunction = false
-- for n,m in ipairs(string.split(v,"#")) do
-- if n == 1 and m == id then
-- isFunction = true
-- else
-- if isFunction then
-- if str then
-- str = "、周"..NumToSimplenessFont[m]
-- else
-- str = "周"..NumToSimplenessFont[m]
-- end
-- end
-- end
-- end
-- end
-- end
return str
2020-08-05 15:00:56 +08:00
end
function this:UpdateCarbonContent()
if not type then
return
end
for k,v in pairs(type) do
local go = Util.GetGameObject(self.gameObject, v.gameObject)
BindRedPointObject(v.redPointType, Util.GetGameObject(go, "redPoint"))
go:GetComponent("Image").sprite = Util.LoadSprite(v.bg)
Util.GetGameObject(go, "titileBg/Text"):GetComponent("Text").text =v.name
2020-08-05 21:01:20 +08:00
local timeStr = this:GetOpenTime(v.id)
if timeStr then
Util.GetGameObject(go, "timeBg/Text"):GetComponent("Text").text = timeStr.."开启"
else
Util.GetGameObject(go, "timeBg/Text"):GetComponent("Text").text = ""
LogRed("无此功能时间:"..v.id)
end
2020-08-05 15:00:56 +08:00
Util.SetGray(go,not ActTimeCtrlManager.SingleFuncState(v.id))
2020-08-05 21:01:20 +08:00
--go:GetComponent("Button").enabled = ActTimeCtrlManager.SingleFuncState(v.id)
2020-08-05 15:00:56 +08:00
Util.AddOnceClick(go ,function()
2020-08-05 21:01:20 +08:00
this:BtnAction(v.id)
2020-08-05 15:00:56 +08:00
end)
end
end
2020-07-15 16:27:58 +08:00
function this:OnSortingOrderChange()
Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer)
Util.AddParticleSortLayer(this.wind, self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
end
2020-07-16 20:24:28 +08:00
function this:PlayAni()
2020-07-15 16:27:58 +08:00
-- 启动定时器
this.StartCountTime()
-- 开门音效
if not this.isPlayDoorAudio then
this.isPlayDoorAudio = true
Timer.New(function ()
if this.isPlayDoorAudio then
SoundManager.PlaySound(SoundConfig.Sound_Door)
end
end, 1.3):Start()
end
end
function this.PlayScaleAnim()
local isOpen = FunctionOpenMananger.GetRootState(PanelTypeView.Carbon)
if isOpen then
PlayUIAnim(this.AnimRoot)
else
PlayUIAnimBack(this.AnimRoot)
end
end
function this.StartCountTime()
2020-07-16 20:24:28 +08:00
2020-07-15 16:27:58 +08:00
end
function this.FreshIconShow(id)
if not hasFresh then
hasFresh = true
this.refreshTimer = nil
this.refreshTimer = Timer.New(function ()
2020-07-21 10:42:20 +08:00
Util.SetGray(this.btnDaoxuan, not ActTimeCtrlManager.SingleFuncState(46))
2020-07-15 16:27:58 +08:00
this.StartCountTime()
end, 1)
this.refreshTimer:Start()
end
end
--界面关闭时调用(用于子类重写)
2020-07-16 20:24:28 +08:00
function this:OnClose()
2020-07-15 16:27:58 +08:00
this.isPlayDoorAudio = false
end
--界面销毁时调用(用于子类重写)
2020-07-16 20:24:28 +08:00
function this:OnDestroy()
2020-08-05 21:01:20 +08:00
for k,v in pairs(type) do
ClearRedPointObject(v.redPointType,Util.GetGameObject(self.gameObject, v.gameObject.."/redPoint"))
end
2020-07-15 16:27:58 +08:00
SubUIManager.Close(this.UpView)
end
2020-07-16 20:24:28 +08:00
return XuanYuanMirrorPanel