require("Base/BasePanel") SupremeHeroPopupNew = Inherit(BasePanel) local this=SupremeHeroPopupNew 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] = { panelId = 1, wenziId = 1, btnTip = Language[11530].."%s", [1] = {id = 4201,state1 = "前往充值",state2 = "",state3 = "s_slbz_yilingqu_zh"}, [2] = {id = 4202,state1 = "前往充值",state2 = "",state3 = "s_slbz_yilingqu_zh"}, [3] = {id = 4203,state1 = "前往充值",state2 = "领 取",state3 = "s_slbz_yilingqu_zh"}, rotation = Vector3.New(0,0,11.7), position = Vector3.New(-16,-10.8,0), banner = "b_baolishuchu_juese1", mat = "Fx_mat_UI_SupremeHeroPopup_renwuchuxian", }, [2] = { panelId = 1, wenziId = 2, btnTip = Language[10317], [1] = {id = 4204,state1 = "前往充值",state2 = "",state3 = "s_slbz_yilingqu_zh"}, [2] = {id = 4205,state1 = "前往充值",state2 = "领 取",state3 = "s_slbz_yilingqu_zh"}, [3] = {id = 4206,state1 = "前往充值",state2 = "领 取",state3 = "s_slbz_yilingqu_zh"}, rotation = Vector3.New(0,0,-0.2), position = Vector3.New(-16,-9,0), banner = "b_baolishuchu_juese1", mat = "Fx_mat_UI_SupremeHeroPopup_renwuchuxian", }, [3] = { panelId = 2, wenziId = 3, btnTip = Language[10317], [1] = {id = 4207,state1 = "前往充值",state2 = "领 取",state3 = "s_slbz_yilingqu_zh"}, [2] = {id = 4208,state1 = "前往充值",state2 = "领 取",state3 = "s_slbz_yilingqu_zh"}, [3] = {id = 4209,state1 = "前往充值",state2 = "点击购买",state3 = "s_slbz_yilingqu_zh"}, rotation = Vector3.New(0,0,-16.2), position = Vector3.New(-16,9,0), banner = "y_yujianzuoji_zuixiacengbudi", mat = "", }, [4] = { panelId = 1, wenziId = 4, btnTip = Language[10317], [1] = {id = 4210,state1 = "前往充值",state2 = "领 取",state3 = "s_slbz_yilingqu_zh"}, [2] = {id = 4211,state1 = "前往充值",state2 = "领 取",state3 = "s_slbz_yilingqu_zh"}, [3] = {id = 4212,state1 = "前往充值",state2 = "点击购买",state3 = "s_slbz_yilingqu_zh"}, rotation = Vector3.New(0,0,-29.5), position = Vector3.New(-30.7,18.5,0), banner = "z_zixuanpifu_ren", mat = "Fx_mat_UI_SupremeHeroPopup_renwuchuxian_1", }, } local orginLayer = 0 local orginLayer2 = 0 -- 界面是否可以关闭 local canClose = false local curPage = 0 local lastPage = 0 local isFrist = false local tab = 4 ---剑影迷踪 --初始化组件(用于子类重写) function SupremeHeroPopupNew:InitComponent() this.spLoader = SpriteLoader.New() orginLayer = 0 orginLayer2 = 0 this.panel = Util.GetGameObject(self.gameObject,"Panel") this.middle = Util.GetGameObject(this.panel,"Middle") --玉帝 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.tipText.gameObject:SetActive(false) 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].btnGetTip = Util.GetGameObject(this.RewardList[i].btnGet, "Text"):GetComponent("Text") this.RewardList[i].doneImg = Util.GetGameObject(this.RewardList[i].go, "BtnDone"):GetComponent("Image") 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/updateTime/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.oneTab = Util.GetGameObject(this.btnLayer.transform, "oneTab") this.oneTabRed = Util.GetGameObject(this.oneTab, "red") this.tianjingzunzhe = Util.GetGameObject(this.btnLayer.transform, "twoTab") this.tianjingzunzheRed = Util.GetGameObject(this.tianjingzunzhe, "red") this.lingxiaobaojian = Util.GetGameObject(this.btnLayer.transform, "threeTab") this.lingxiaobaojianRed = Util.GetGameObject(this.lingxiaobaojian, "red") this.fourTab = Util.GetGameObject(this.btnLayer.transform, "fourTab") this.fourTabRed = Util.GetGameObject(this.fourTab, "red") this.select = Util.GetGameObject(this.btnLayer.transform, "select") --1玉帝 2御剑 this.panelist = {} for i = 1,tab do if not this.panelist[i] then this.panelist[i] = {} end this.panelist[i].role = Util.GetGameObject(self.gameObject, "Panel/role"..idList[i].panelId) this.panelist[i].role.gameObject:SetActive(false) this.panelist[i].jian = Util.GetGameObject(self.gameObject, "Panel/jian"..idList[i].panelId) this.panelist[i].jian.gameObject:SetActive(false) this.panelist[i].wenzi = Util.GetGameObject(self.gameObject, "Panel/wenzi"..idList[i].wenziId) this.panelist[i].wenzi.gameObject:SetActive(false) if i == 1 or i == 2 or i == 4 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, idList[i].mat) 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 == 3 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 SupremeHeroPopupNew: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 SupremeHeroPopupNew:BindEvent() --返回按钮 Util.AddClick(this.backBtn,function() if not canClose then return end self:ClosePanel() 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.oneTab, function() if not canClose then return end curPage = 1 if lastPage == curPage then return end this:SetSelect() this.SetMissionData() end) Util.AddClick(this.tianjingzunzhe, function() if not canClose then return end curPage = 2 if lastPage == curPage then return end this:SetSelect() this.SetMissionData() end) Util.AddClick(this.lingxiaobaojian, function() if not canClose then return end curPage = 3 if lastPage == curPage then return end this:SetSelect() this.SetMissionData() end) Util.AddClick(this.fourTab, function() if not canClose then return end curPage = 4 if lastPage == curPage then return end this:SetSelect() this.SetMissionData() end) end function SupremeHeroPopupNew:SetSelect() local parent = this.lingxiaobaojian.transform if curPage == 1 then parent = this.oneTab.transform elseif curPage == 2 then parent = this.tianjingzunzhe.transform elseif curPage == 3 then parent = this.lingxiaobaojian.transform else parent = this.fourTab.transform end this.select.transform:SetParent(parent) this.select.transform.localPosition = idList[curPage].position this.select:GetComponent("RectTransform").rotation = Quaternion.Euler(idList[curPage].rotation) end --添加事件监听(用于子类重写) function SupremeHeroPopupNew:AddListener() end --移除事件监听(用于子类重写) function SupremeHeroPopupNew:RemoveListener() end --界面打开时调用(用于子类重写) local fun = nil function SupremeHeroPopupNew:OnOpen(_fun) Timer.New(function () SoundManager.PlaySound(SoundConfig.UI_Hd_yhdd) end,0.5):Start() fun = _fun end function SupremeHeroPopupNew:OnShow() for i = 1,#this.panelist do for k,v in pairs(this.panelist[i]) do if ((i == 1 or i == 2) and v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian") or (i == 4 and v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian_1") then else v.gameObject:SetActive(false) end end end this.money = VipManager.GetChargedNum() isFrist = true curPage = tab for i = 1 ,tab do if not ActivityGiftManager.CheckSupremeMission(i,true) then curPage = i lastPage = 0 break end end self:SetSelect() local actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SupremeHero) this.oneTab.gameObject:SetActive(this.RefreshActive(1)) this.tianjingzunzhe.gameObject:SetActive(this.RefreshActive(2)) this.lingxiaobaojian.gameObject:SetActive(this.RefreshActive(3)) this.fourTab.gameObject:SetActive(this.RefreshActive(4)) --curPage = 2 this.InitShowPanel() this.tianjingzunzheRed.gameObject:SetActive(this.RefreshRedPoint(2)) this.lingxiaobaojianRed.gameObject:SetActive(this.RefreshRedPoint(3)) this.oneTabRed.gameObject:SetActive(this.RefreshRedPoint(1)) this.fourTabRed.gameObject:SetActive(this.RefreshRedPoint(4)) 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] this.timer:Stop() end end, 1, -1, true) end this.timer:Start() end function this.SetMissionData() this.panelist[curPage].role:GetComponent("Image").sprite = this.spLoader:LoadSprite(idList[curPage].banner) if lastPage > 0 then if idList[lastPage].panelId ~= idList[curPage].panelId then for k,v in pairs(this.panelist[lastPage]) do if idList[lastPage].panelId == 1 and (v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian" or v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian_1") then else v.gameObject:SetActive(false) end end end end for k,v in pairs(this.panelist[curPage]) do if v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian" or v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian_1" 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 if idList[lastPage].panelId == idList[curPage].panelId then this.panelist[curPage].wenzi.gameObject:SetActive(true) this.panelist[lastPage].wenzi.gameObject:SetActive(false) else v.gameObject:SetActive(true) end end end Timer.New(function() isFrist = false end,4):Start() lastPage = curPage if curPage == 1 or curPage == 2 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() -- LogRed("dataConfig.Jump[1]:"..tostring(dataConfig.Jump[1]).." "..tostring(idList[curPage][j].id)) --这里做了处理,要求这种充值优先新人商城,未开启则跳转每日特惠 if dataConfig.Jump[1] == 36008 then if ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.XinRenShop) then JumpManager.GoJump(36012) else JumpManager.GoJump(36008) end else JumpManager.GoJump(dataConfig.Jump[1]) end Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceClear) end) Util.AddOnceClick(this.RewardList[j].btnGet,function() if curPage == 3 and j == 3 then DynamicActivityManager.Index = 6 JumpManager.GoJump(1300) Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceClear) elseif curPage == 4 and j == 3 then DynamicActivityManager.Index = 7 JumpManager.GoJump(1300) Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceClear) else NetManager.GetActivityRewardRequest(idList[curPage][j].id, actData.activityId,function(drop) UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function() ActivityGiftManager.SetActivityInfo(actData.activityId, idList[curPage][j].id, 1) actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SupremeHero) this.RefreshItemData(j,idList[curPage][j].id) this.SetButtonState() this.tianjingzunzheRed.gameObject:SetActive(this.RefreshRedPoint(2)) this.lingxiaobaojianRed.gameObject:SetActive(this.RefreshRedPoint(3)) this.oneTabRed.gameObject:SetActive(this.RefreshRedPoint(1)) this.fourTabRed.gameObject:SetActive(this.RefreshRedPoint(4)) end) 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) this.RewardList[index].doneImg.gameObject:SetActive(false) this.RewardList[index].Btn.gameObject:SetActive(false) this.RewardList[index].btnGet.gameObject:SetActive(false) for i = 1,#actData.mission do if actData.mission[i].missionId == missionId then if actData.mission[i].state == 1 then this.RewardList[index].doneImg.gameObject:SetActive(true) this.RewardList[index].doneImg.sprite = this.spLoader:LoadSprite(idList[curPage][index].state3) elseif this.money < activityConfig[missionId].Values[1][1] then this.RewardList[index].Btn.gameObject:SetActive(true) this.RewardList[index].btnTip.text = idList[curPage][index].state1 else this.RewardList[index].btnGet.gameObject:SetActive(true) this.RewardList[index].btnGetTip.text = idList[curPage][index].state2 end end end end function this.SetButtonState() local color = this.money < activityConfig[idList[curPage][#idList[curPage]].id].Values[1][1] and "#FF0000FF" or "#F4D98AFF" this.taskProgress.text = string.format("已充值:%s/%s元", color, this.money,activityConfig[idList[curPage][#idList[curPage]].id].Values[1][1]) end function this.RefreshRedPoint(indexType) local isShow = false for k,v in ipairs(actData.mission) do if activityConfig[v.missionId].Sort == indexType then if v.state == 0 and this.money >= activityConfig[v.missionId].Values[1][1] then return true end end end return isShow end function this.RefreshActive(indexType) local isShow = false local actData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.SupremeHero) for k,v in ipairs(actData.mission) do if activityConfig[v.missionId].Sort == indexType then isShow = true end end return isShow end --界面关闭时调用(用于子类重写) function SupremeHeroPopupNew: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" or v.gameObject.name == "Fx_mat_UI_SupremeHeroPopup_renwuchuxian_1" then else v.gameObject:SetActive(false) end end end end --界面销毁时调用(用于子类重写) function SupremeHeroPopupNew:OnDestroy() this.spLoader:Destroy() this.RewardList = {} this.panelist = {} end return SupremeHeroPopupNew