require("Base/BasePanel") XuanYuanMirrorPanel = Inherit(BasePanel) local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig) local this = XuanYuanMirrorPanel local hasFresh = false local orginLayer = 0 local activityType = { [1] = { bg = "ui_fb_btn_jy", name = Language[12299], gameObject = "renjiebaojing" , }, [2] = { bg = "ui_fb_btn_gh", name = Language[12300], gameObject = "fuochanbaojing" , }, [3] = { bg = "ui_fb_btn_sl", name = Language[12301], gameObject = "yaolingbaojing" , }, [4] = { bg = "ui_fb_btn_jq", name = Language[12302], gameObject = "daoxuanbaojing" , }, } local NumConvertWeek = {[1]=Language[10005],[2]=Language[10006],[3]=Language[10007],[4]=Language[10008],[5]=Language[10009],[6]=Language[10010],[7]=Language[12303]} --初始化组件(用于子类重写) 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") 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") -- NumConvertWeek = {[1]=Language[10005],[2]=Language[10006],[3]=Language[10007],[4]=Language[10008],[5]=Language[10009],[6]=Language[10010],[7]=Language[12303]} -- activityType = { -- [1] = { -- bg = "ui_fb_btn_jy", -- name = Language[12299], -- gameObject = "renjiebaojing" , -- }, -- [2] = { -- bg = "ui_fb_btn_gh", -- name = Language[12300], -- gameObject = "fuochanbaojing" , -- }, -- [3] = { -- bg = "ui_fb_btn_sl", -- name = Language[12301], -- gameObject = "yaolingbaojing" , -- }, -- [4] = { -- bg = "ui_fb_btn_jq", -- name = Language[12302], -- gameObject = "daoxuanbaojing" , -- }, -- } end local index = 1 --绑定事件(用于子类重写) function this:BindEvent() Util.AddClick(this.btnHelp, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.XuanYuanMirror,this.helpPosition.x,this.helpPosition.y) end) Util.AddClick(this.btnRank, function() UIManager.OpenPanel(UIName.XuanYuanMirrorRankPopup) end) Util.AddClick(this.btnReward, function() UIManager.OpenPanel(UIName.XuanYuanMirrorRewardSortPopup) end) Util.AddClick(this.btnClose, function() this:ClosePanel() end) end --添加事件监听(用于子类重写) function this:AddListener() Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnXuanYuanFunctionChange, this.UpdateCarbonContent,1) end --移除事件监听(用于子类重写) function this:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.FunctionCtrl.OnXuanYuanFunctionChange, this.UpdateCarbonContent,1) end function this:OnOpen() if not this.UpView then this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform) end this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main }) end --界面打开时调用(用于子类重写) function this:OnShow(...) this.UpdateCarbonContent(0) -- 音效 SoundManager.PlayMusic(SoundConfig.BGM_Carbon) -- 播放动画 this:PlayAni() this.PlayScaleAnim() end function this:GetOpenTime(id) local str = nil local isFunction = false local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,70) if config then for k,v in ipairs(string.split(config.Value,"|")) do isFunction = false for n,m in ipairs(string.split(v,"#")) do if tonumber(n) == 1 and tonumber(m) == id then isFunction = true else if isFunction then if str then str =str.. Language[12304]..NumConvertWeek[tonumber(m)] else str = Language[12305]..NumConvertWeek[tonumber(m)] end end end end end end LogBlue(str.." 宝镜开启时间") return str end this.UpdateCarbonContent = function(...) LogBlue("type长度: "..LengthOfTable(activityType)) if not activityType then activityType = { [1] = { bg = "ui_fb_btn_jy", name = Language[12299], gameObject = "renjiebaojing" , }, [2] = { bg = "ui_fb_btn_gh", name = Language[12300], gameObject = "fuochanbaojing" , }, [3] = { bg = "ui_fb_btn_sl", name = Language[12301], gameObject = "yaolingbaojing" , }, [4] = { bg = "ui_fb_btn_jq", name = Language[12302], gameObject = "daoxuanbaojing" , }, } end local temp = {...} local temp = temp[1] if index and index >= 0 then Timer.New(function() local openFunctions = {} for k,v in pairs(activityType) do local go = Util.GetGameObject(this.AnimRoot, v.gameObject) go:GetComponent("Image").sprite = Util.LoadSprite(v.bg) Util.GetGameObject(go, "titileBg/Text"):GetComponent("Text").text =v.name local state = XuanYuanMirrorManager.GetMirrorState(k) == 1 LogGreen(k.." 宝镜state:"..XuanYuanMirrorManager.GetMirrorState(k)) if not state or state == 0 then local timeStr = this:GetOpenTime(k) Util.GetGameObject(go, "timeBg/Text"):GetComponent("Text").text = timeStr..Language[10357] Util.GetGameObject(go, "redPoint").gameObject:SetActive(false) else openFunctions[k] = {} openFunctions[k].timeComp = Util.GetGameObject(go, "timeBg/Text"):GetComponent("Text") if XuanYuanMirrorManager.CarbonRedCheck() then Util.GetGameObject(go, "redPoint").gameObject:SetActive(true) else Util.GetGameObject(go, "redPoint").gameObject:SetActive(false) end end Util.SetGray(go,not state) Util.AddOnceClick(go ,function() if state then LogBlue("宝镜状态:"..activityType[k].name..XuanYuanMirrorManager.GetMirrorState(k)) UIManager.OpenPanel(UIName.XuanYuanMirrorPanelList,k) else LogBlue("宝镜未开启提示:"..activityType[k].name..Language[12306]) PopupTipPanel.ShowTip(activityType[k].name..Language[12306]) end end) end this:TimeCountDown(openFunctions) this.remainTimes.text = XuanYuanMirrorManager.GetTimeTip() end, index):Start() end end function this:OnSortingOrderChange() Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer) Util.AddParticleSortLayer(this.wind, self.sortingOrder - orginLayer) orginLayer = self.sortingOrder end function this:PlayAni() -- 开门音效 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:OnClose() if self.timer then self.timer:Stop() self.timer = nil end this.isPlayDoorAudio = false self.gameObject:SetActive(false) PlayerManager.carbonType = 2 if this.UpView then SubUIManager.Close(this.UpView) this.UpView = nil end end --界面销毁时调用(用于子类重写) function this:OnDestroy() if self.timer then self.timer:Stop() self.timer = nil end if this.UpView then SubUIManager.Close(this.UpView) this.UpView = nil end end --刷新时间 function this:TimeCountDown(_openFunctions) if self.timer then self.timer:Stop() self.timer = nil end for k,v in pairs(_openFunctions) do v.remainTime = XuanYuanMirrorManager.GetMirrorEndTime(k) - PlayerManager.serverTime v.timeComp.text = TimeToHMS(v.remainTime)..Language[12307] end self.timer = Timer.New(function() for k,v in pairs(_openFunctions) do v.remainTime = v.remainTime - 1 if v.remainTime > 0 then v.timeComp.text = TimeToHMS(v.remainTime)..Language[12307] else this:UpdateCarbonContent(1) end end end, 1, -1, true) self.timer:Start() end return XuanYuanMirrorPanel