require("Base/BasePanel") SupremeHeroPopup = Inherit(BasePanel) local this=SupremeHeroPopup local artResConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig) local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig) local activityConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local live2dResName = "" local heroId = 0 local heroData = {} local actIsOpen = false local missionData = {} local actData = {} local idList = { [1] = { bigId = 0, [1] = {id = 30, jumpevent = function() JumpManager.GoJump(26082) end,btnTip = Language[11530].."%s",isGet = false}, [2] = {id = 31, jumpevent = function() PopupTipPanel.ShowTip(Language[11531]) end,btnTip = Language[11530].."%s",isGet = false}, [3] = {id = 32, jumpevent = function() JumpManager.GoJump(36005) end,btnTip = Language[11530].."%s",isGet = true}, }, [2] = { bigId = 36, [1] = {id = 33, jumpevent = function() JumpManager.GoJump(26082) end,btnTip = Language[10317],isGet = true}, [2] = {id = 34, jumpevent = function() JumpManager.GoJump(26082) end,btnTip = Language[10018],isGet = true}, [3] = {id = 35, jumpevent = function() JumpManager.GoJump(36012) end,btnTip = Language[10101],isGet = true}, }, } local orginLayer = 0 local orginLayer2 = 0 -- 界面是否可以关闭 local canClose = false local curPage = 0 local isFrist = false ---剑影迷踪 --初始化组件(用于子类重写) function SupremeHeroPopup:InitComponent() this.spLoader = SpriteLoader.New() orginLayer = 0 orginLayer2 = 0 this.panel = Util.GetGameObject(self.gameObject,"Panel") this.middle = Util.GetGameObject(this.panel,"Middle") this.doneBtn = Util.GetGameObject(this.middle,"DoneBtn") this.btnText = Util.GetGameObject(this.doneBtn, "Text"):GetComponent("Text") --玉帝 this.previewBtn = Util.GetGameObject(this.middle, "PreviewBtn") this.click = Util.GetGameObject(this.middle, "PreviewBtn/click") this.clickNameParent = Util.GetGameObject(this.middle, "PreviewBtn/di/Name") this.clickName = Util.GetGameObject(this.clickNameParent, "Text"):GetComponent("Text") this.proImage = Util.GetGameObject(this.middle, "PreviewBtn/di/Image"):GetComponent("Image") this.previewBtn.gameObject:SetActive(false) this.taskProgress = Util.GetGameObject(this.middle, "di/TaskProgress"):GetComponent("Text")--完成进度 this.tipText = Util.GetGameObject(this.middle, "textTime (1)"):GetComponent("Text") this.itemList = {} this.RewardList = {} for i = 1, 3 do this.RewardList[i] = {} this.RewardList[i].go = Util.GetGameObject(this.middle, "Reward/Panel".. i) this.RewardList[i].title = Util.GetGameObject(this.RewardList[i].go, "Image/Title"):GetComponent("Text") this.RewardList[i].Btn = Util.GetGameObject(this.RewardList[i].go, "Button") this.RewardList[i].BtnTip = Util.GetGameObject(this.RewardList[i].Btn, "Text"):GetComponent("Text") this.RewardList[i].btnGet = Util.GetGameObject(this.RewardList[i].go, "BtnGet") this.RewardList[i].doneImg = Util.GetGameObject(this.RewardList[i].go, "doneImg") this.RewardList[i].frame = Util.GetGameObject(this.RewardList[i].go, "frame") this.RewardList[i].red = Util.GetGameObject(this.RewardList[i].btnGet, "redPot") end this.activityTime = Util.GetGameObject(self.gameObject, "Panel/Middle/freshTime"):GetComponent("Text")--活动时间 this.backBtn = Util.GetGameObject(self.gameObject, "Panel/btnBack") this.effectRoot5 = Util.GetGameObject(self.gameObject, "Fx_mat_UI_SupremeHeroPopup_yunwusankai") this.effectRoot3 = Util.GetGameObject(self.gameObject, "Fx_mat_UI_SupremeHeroPopup_changzhu") this.Effect_UI_SupremeHeroPopup_zhuzi = Util.GetGameObject(self.gameObject, "Panel/Effect_UI_SupremeHeroPopup_zhuzi") this.LoadLive2D() this.btnLayer = Util.GetGameObject(self.gameObject, "Panel/Middle/btnLayer"):GetComponent("Canvas") this.tianjingzunzhe = Util.GetGameObject(this.btnLayer.transform, "tianjingzunzhe") this.tianjingzunzheRed = Util.GetGameObject(this.tianjingzunzhe, "red") this.lingxiaobaojian = Util.GetGameObject(this.btnLayer.transform, "lingxiaobaojian") this.lingxiaobaojianRed = Util.GetGameObject(this.lingxiaobaojian, "red") --1玉帝 2御剑 this.panelist = {} for i = 1,2 do if not this.panelist[i] then this.panelist[i] = {} end this.panelist[i].role = Util.GetGameObject(self.gameObject, "Panel/role"..i) this.panelist[i].role.gameObject:SetActive(false) this.panelist[i].jian = Util.GetGameObject(self.gameObject, "Panel/jian"..i) this.panelist[i].jian.gameObject:SetActive(false) this.panelist[i].wenzi = Util.GetGameObject(self.gameObject, "Panel/wenzi"..i) this.panelist[i].wenzi.gameObject:SetActive(false) if i == 1 then this.panelist[i].jianEffect = Util.GetGameObject(this.panelist[i].jian, "Effect_UI_SupremeHeroPopup_jian") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_daohen = Util.GetGameObject(self.gameObject, "Fx_mat_UI_SupremeHeroPopup_daohen") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_renwuchuxian = Util.GetGameObject(self.gameObject, "Fx_mat_UI_SupremeHeroPopup_renwuchuxian") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_changzhu = Util.GetGameObject(this.panelist[i].Fx_mat_UI_SupremeHeroPopup_renwuchuxian, "Particle System") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_renwuchuxian.gameObject:SetActive(true) elseif i == 2 then this.panelist[i].jianEffect = Util.GetGameObject(this.panelist[i].role, "Image/fx_yujiantongxing_01") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_daohen = Util.GetGameObject(this.panelist[i].role, "Image1/fx_yujiantongxing_02") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_renwuchuxian = Util.GetGameObject(this.panelist[i].role, "Image (1)/fx_yujiantongxing_03") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_changzhu = Util.GetGameObject(this.panelist[i].role, "fx_yujiantongxing_luodi") this.panelist[i].Fx_mat_UI_SupremeHeroPopup_renwuchuxian.gameObject:SetActive(false) end this.panelist[i].jianEffect.gameObject:SetActive(false) this.panelist[i].Fx_mat_UI_SupremeHeroPopup_daohen.gameObject:SetActive(false) this.panelist[i].Fx_mat_UI_SupremeHeroPopup_changzhu.gameObject:SetActive(false) end end function this.LoadLive2D() local liveId = ActivityGiftManager.GetActivityDataById(42).Drawing heroId = liveId or 10011 heroData = heroConfig[heroId] liveId = heroConfig[heroId].Live this.clickName.text = GetLanguageStrById(heroConfig[heroId].ReadingName) SetTextVerTial(this.clickName,Vector3.New(59,-10,0)) live2dResName = artResConfig[liveId].Name this.proImage.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig[heroId].PropertyName)) end function SupremeHeroPopup:OnSortingOrderChange() local layer = self.sortingOrder Util.SetParticleSortLayer(this.effectRoot3, layer + 1) Util.SetParticleSortLayer(this.effectRoot5, layer + 1) Util.SetParticleSortLayer(this.Effect_UI_SupremeHeroPopup_zhuzi, layer + 1) for i = 1,#this.panelist do Util.SetParticleSortLayer(this.panelist[i].jianEffect, layer + 1) Util.SetParticleSortLayer(this.panelist[i].Fx_mat_UI_SupremeHeroPopup_daohen, layer + 1) Util.SetParticleSortLayer(this.panelist[i].Fx_mat_UI_SupremeHeroPopup_renwuchuxian, layer + 1) Util.SetParticleSortLayer(this.panelist[i].Fx_mat_UI_SupremeHeroPopup_changzhu, layer + 1) end this.btnLayer.overrideSorting = true this.btnLayer.sortingOrder = layer + 1 end --绑定事件(用于子类重写) function SupremeHeroPopup:BindEvent() --返回按钮 Util.AddClick(this.backBtn,function() if not canClose then return end self:ClosePanel() end) --完成按钮 Util.AddClick(this.doneBtn,function() if actIsOpen then local finishedNum,isGetBigReward = this.GetBtnState() if finishedNum >= 3 and not isGetBigReward then NetManager.GetActivityRewardRequest(idList[curPage].bigId, ActivityTypeDef.SupremeHero, function (drop) UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1,function() actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SupremeHero) this.SetButtonState() end) local time=PlayerPrefs.GetString(PlayerManager.uid..PlayerManager.serverInfo.server_id.."supermeMan",0) if time ~= 666 then PlayerPrefs.SetString(PlayerManager.uid..PlayerManager.serverInfo.server_id.."supermeMan",GetTimeStamp()) Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnPlayerGetSuperManReward) end CheckRedPointStatus(RedPointType.SupremeHero) this.tianjingzunzheRed.gameObject:SetActive(this.RefreshRedPoint(1)) this.lingxiaobaojianRed.gameObject:SetActive(this.RefreshRedPoint(2)) end) end else PopupTipPanel.ShowTip(Language[10024]) end end) --预览按钮 Util.AddClick(this.previewBtn,function() UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, heroId, heroData.Star) end) Util.AddClick(this.click, function() UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, heroId, heroData.Star) end) Util.AddClick(this.tianjingzunzhe, function() curPage = 1 this.SetMissionData() end) Util.AddClick(this.lingxiaobaojian, function() curPage = 2 this.SetMissionData() end) RedpotManager.BindObject(RedPointType.SupremeHero_mission3,this.redPot3) end --添加事件监听(用于子类重写) function SupremeHeroPopup:AddListener() end --移除事件监听(用于子类重写) function SupremeHeroPopup:RemoveListener() end --界面打开时调用(用于子类重写) local fun = nil function SupremeHeroPopup:OnOpen(_fun) Timer.New(function () SoundManager.PlaySound(SoundConfig.UI_Hd_yhdd) end,0.5):Start() fun = _fun end function SupremeHeroPopup:OnShow() isFrist = true if ActivityGiftManager.CheckSupremeMission(1,true) then curPage = 2 else curPage = 1 end local actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SupremeHero) if #actData.mission > 3 then this.lingxiaobaojian.gameObject:SetActive(true) else curPage = 1 this.lingxiaobaojian.gameObject:SetActive(false) end --curPage = 2 this.InitShowPanel() this.tianjingzunzheRed.gameObject:SetActive(this.RefreshRedPoint(1)) this.lingxiaobaojianRed.gameObject:SetActive(this.RefreshRedPoint(2)) end function this.InitShowPanel() --初始化静态显示数据 this.InitShow() canClose = false this.effectTime = nil this.effectTime = Timer.New(function () canClose = true isFrist = false end, 5) this.effectTime:Start() end function this.InitShow() ActivityGiftManager.isFirstForSupremeHero = true actIsOpen = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.SupremeHero) > 0 actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SupremeHero) this.SetMissionData() -- 开始倒计时 local endTime = ActivityGiftManager.GetTaskEndTime(ActivityTypeDef.SupremeHero) this.activityTime.text = "" if not this.timer then this.timer = Timer.New(function () local tempTime = endTime - PlayerManager.serverTime if tempTime > 0 then if tempTime >= 86400 then this.activityTime.text = TimeToDH(tempTime) else this.activityTime.text = TimeToHMS(tempTime) end else this.activityTime.text = Language[10119] Util.SetGray(this.doneBtn, true) this.doneBtn:GetComponent("Button").enabled = false this.timer:Stop() end end, 1, -1, true) end this.timer:Start() end function this.SetMissionData() for i = 1,#this.panelist do for k,v in pairs(this.panelist[i]) do if i == curPage then if v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian" then elseif isFrist then if v.gameObject.name == "Particle System" then Timer.New(function() v.gameObject:SetActive(true) end,3.2):Start() else Timer.New(function() v.gameObject:SetActive(true) end,3.6):Start() end else v.gameObject:SetActive(true) end else if i == 1 and v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian" then else v.gameObject:SetActive(false) end end end end Timer.New(function() isFrist = false end,4):Start() if curPage == 1 then this.previewBtn.gameObject:SetActive(true) else this.previewBtn.gameObject:SetActive(false) end for i = 1,#this.RewardList do this.RewardList[i].go.gameObject:SetActive(false) end for j = 1,3 do if this.RewardList[j] then this.RewardList[j].go.gameObject:SetActive(true) local dataConfig = activityConfig[idList[curPage][j].id] this.RewardList[j].title.text = GetLanguageStrById(dataConfig.ContentsShow) --if dataConfig.ExtraParm == 0 then if dataConfig.ExtraParm and dataConfig.ExtraParm[1] and dataConfig.ExtraParm[1] == 0 then Log(string.format("ActivityRewardConfig表中ID为%s对应的ExtraParm项数据为空", idList[curPage][j].id)) Log("请检查表或者重新导表!") return end -- local itemId = dataConfig.ExtraParm -- local itemnum = 1 local itemId = dataConfig.ExtraParm[1] local itemnum = dataConfig.ExtraParm[2] or 0 if not this.itemList[j] then this.itemList[j] = SubUIManager.Open(SubUIConfig.ItemView, this.RewardList[j].frame.transform) end this.itemList[j]:OnOpen(false, {itemId, itemnum}, 0.92) this.itemList[j].num.gameObject:SetActive(itemnum > 1) this.RefreshItemData(j,idList[curPage][j].id) Util.AddOnceClick(this.RewardList[j].Btn,function() idList[curPage][j].jumpevent() Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceClear) this:ClosePanel() end) Util.AddOnceClick(this.RewardList[j].btnGet,function() NetManager.GetActivityRewardRequest(idList[curPage][j].id, actData.activityId,function(drop) UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function() actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SupremeHero) this.RefreshItemData(j,idList[curPage][j].id) this.SetButtonState() this.tianjingzunzheRed.gameObject:SetActive(this.RefreshRedPoint(1)) this.lingxiaobaojianRed.gameObject:SetActive(this.RefreshRedPoint(2)) end) end) end) end end if curPage == 1 then this.tipText.text = string.format(idList[curPage][1].btnTip,GetLanguageStrById(heroConfig[heroId].ReadingName)) else this.tipText.text = activityConfig[idList[curPage].bigId].ContentsShow end this.SetButtonState() end function this.RefreshItemData(index,missionId) for i = 1,#actData.mission do if actData.mission[i].missionId == missionId then this.RewardList[index].Btn.gameObject:SetActive(actData.mission[i].state == 0) this.RewardList[index].btnGet.gameObject:SetActive(actData.mission[i].state == 3) this.RewardList[index].doneImg.gameObject:SetActive(actData.mission[i].state == 1 or actData.mission[i].state == 2) end end end function this.SetButtonState() local finishedNum,isGetBigReward = this.GetBtnState() local total = 3 local color = finishedNum < total and "#FF0000FF" or "#F4D98AFF" this.taskProgress.text = string.format(" %s/3", color, finishedNum) Util.SetGray(this.doneBtn, (finishedNum < total) or isGetBigReward) this.doneBtn:GetComponent("Button").enabled = (finishedNum >= total) and not isGetBigReward if finishedNum < total then this.btnText.text = "未完成" elseif isGetBigReward then this.btnText.text = "已领取" else this.btnText.text = "领取" end end function this.GetBtnState() local finishedNum = 0 local isGetBigReward = true for i = 1,#actData.mission do if activityConfig[actData.mission[i].missionId].Sort == curPage then if actData.mission[i].state == 1 or actData.mission[i].state == 2 then finishedNum = finishedNum + 1 end if curPage == 1 then if actData.mission[i].state ~= 2 then isGetBigReward = false end end end if curPage == 2 and activityConfig[actData.mission[i].missionId].Sort == 3 then isGetBigReward = (actData.mission[i].state == 1 or actData.mission[i].state == 2) and true or false end end return finishedNum,isGetBigReward end function this.RefreshRedPoint(indexType) local isShow = true if indexType ~= 1 then isShow = false end for k,v in ipairs(actData.mission) do if indexType == 1 then if activityConfig[v.missionId].Sort == indexType then if v.state == 3 then return true end if v.state == 2 or v.state == 0 then isShow = false end end else if activityConfig[v.missionId].Sort ~= 1 then if v.state == 3 then return true end end end end return isShow end --界面关闭时调用(用于子类重写) function SupremeHeroPopup:OnClose() if this.timer then this.timer:Stop() this.timer = nil end if this.effectTime then this.effectTime:Stop() this.effectTime = nil end if fun then fun() fun = nil end curPage = 0 for k,v in pairs(this.itemList) do SubUIManager.Close(v) end this.itemList = {} for i = 1,#this.panelist do for k,v in pairs(this.panelist[i]) do if v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian" then else v.gameObject:SetActive(false) end end end end --界面销毁时调用(用于子类重写) function SupremeHeroPopup:OnDestroy() this.spLoader:Destroy() this.RewardList = {} this.panelist = {} end return SupremeHeroPopup