require("Base/BasePanel") local CarbonsPanel = Inherit(BasePanel) local systemConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig) local expeditionLevel = { [1] = 1, [2] = 2, [3] = 3, [-1] = 2, [4] = 3, } local carbonData = { --[FUNCTION_OPEN_TYPE.EXPEDITION] = { -- id = FUNCTION_OPEN_TYPE.EXPEDITION, --大闹天宫 -- objName = "expedition", -- nameImg = "f_fuben_fubenming_03", -- btnPos = Vector2(39,-67), -- redPointType = RedPointType.OrdinaryExplore, -- effect1 = "Fx_DaNaoTianGong", -- effect2 = "Fx_DaNaoTianGong_S", --}, [FUNCTION_OPEN_TYPE.QIJIESHILIAN] = { id = FUNCTION_OPEN_TYPE.QIJIESHILIAN, --宇宙生存挑战 objName = "expedition", nameImg = "f_fuben_fubenming_10", name="宇宙生存挑战", titleBg="UI_hz_fb_02", btnPos = Vector2(-60,0), redPointType = RedPointType.QiJieShiLian, effect1 = "Fx_DaNaoTianGong", effect2 = "Fx_DaNaoTianGong_S", }, [FUNCTION_OPEN_TYPE.PEOPLE_MIRROR] = { id = FUNCTION_OPEN_TYPE.PEOPLE_MIRROR, --轩辕 objName = "xuanyuan", nameImg = "f_fuben_fubenming_02", name="超次元挑战", titleBg="UI_hz_fb_03", btnPos = Vector2(0,108), redPointType = RedPointType.People_Mirror, effect1 = "Fx_XuanYuanBaoJing", effect2 = "Fx_XuanYuanBaoJing_S", }, [FUNCTION_OPEN_TYPE.MONSTER_COMING] = { id = FUNCTION_OPEN_TYPE.MONSTER_COMING, --心魔 objName = "monster", nameImg = "f_fuben_fubenming_04", name="蛇道挑战", titleBg="UI_hz_fb_04", btnPos = Vector2(0,-50), redPointType = RedPointType.EpicExplore, effect1 = "Fx_XinMoShiLian", effect2 = "Fx_XinMoShiLian_S", }, [FUNCTION_OPEN_TYPE.ENDLESS] = { id = FUNCTION_OPEN_TYPE.ENDLESS, --无尽 objName = "endless", nameImg = "f_fuben_fubenming_06", name="修行挑战", titleBg="UI_hz_fb_05", btnPos = Vector2(86,-9), redPointType = RedPointType.challengeCopy, effect1 = "Fx_WuJinFuBen", effect2 = "Fx_WuJinFuBen_S", }, [FUNCTION_OPEN_TYPE.FIGHTLEVEL] = { id = FUNCTION_OPEN_TYPE.FIGHTLEVEL, --山河社稷图 objName = "fightlevel", nameImg = "f_fuben_fubenming_07", name="超越之路", titleBg="UI_hz_fb_06", btnPos = Vector2(0,-167), redPointType = RedPointType.FightLevel, effect1 = "ImgBg/Fx_ShanHeSheJiTu", effect2 = "Fx_ShanHeSheJiTu_S", }, [FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN] = { id = FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN, --日常 objName = "daily", nameImg = "f_fuben_fubenming_05", name="神龙试炼", titleBg="UI_hz_fb_07", btnPos = Vector2(13,77), redPointType = RedPointType.HeroExplore, effect1 = "Fx_RiChangFuBen", effect2 = "Fx_RiChangFuBen_S", }, -- [FUNCTION_OPEN_TYPE.TRIAL] = { -- id = FUNCTION_OPEN_TYPE.TRIAL, --森罗 -- objName = "trial", -- nameImg = "f_fuben_fubenming_01", -- btnPos = Vector2(-156,-12), -- redPointType = RedPointType.Trial, -- effect1 = "Fx_SenLuoHuanJjing", -- effect2 = "Fx_SenLuoHuanJjing_S", -- }, [FUNCTION_OPEN_TYPE.LINGMAIMIJING] = { id = FUNCTION_OPEN_TYPE.LINGMAIMIJING, --灵脉秘境 objName = "trial", nameImg = "f_fuben_fubenming_09", name="那美克星寻宝", titleBg="UI_hz_fb_08", btnPos = Vector2(18,-12), redPointType = RedPointType.LingMaiMiJing, effect1 = "Fx_SenLuoHuanJjing", effect2 = "Fx_SenLuoHuanJjing_S", }, [FUNCTION_OPEN_TYPE.GodsWayTower_1] = { id = FUNCTION_OPEN_TYPE.GodsWayTower_1, --多队塔 objName = "other", nameImg = "f_fuben_fubenming_08", name="破坏神试炼", titleBg="UI_hz_fb_08", btnPos = Vector2(-78,66), redPointType = RedPointType.godsWayTower, effect1 = "Fx_XuanYuanBaoJing", effect2 = "Fx_XuanYuanBaoJing_S", }, } --初始化组件(用于子类重写) function CarbonsPanel:InitComponent() self.spLoader = SpriteLoader.New() self.sortingOrder = 0 if not self.playerInfoView then self.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, self.transform) end self.BtView = SubUIManager.Open(SubUIConfig.BtView, self.transform) self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform) self.upviewParent = Util.GetGameObject(self.gameObject,"upviewP") self.playerInfoView.transform:SetParent(self.upviewParent.transform) self.UpView.transform:SetParent(self.upviewParent.transform) self.map = Util.GetGameObject(self.gameObject,"Map") self.btnPre = Util.GetGameObject(self.gameObject,"btnPre") self.btnList = {} self.timeList = {} self.effectList = {} self.randomList = {} end --绑定事件(用于子类重写) function CarbonsPanel:BindEvent() end --添加事件监听(用于子类重写) function CarbonsPanel:AddListener() end --移除事件监听(用于子类重写) function CarbonsPanel:RemoveListener() end function CarbonsPanel:OnOpen() self.BtView.gameObject:SetActive(true) self.BtView:OnOpen(self, {sortOrder = self.sortingOrder, panelType = PanelTypeView.Carbon}) self.UpView:OnOpen({showType = UpViewOpenType.ShowRight, panelType = PanelType.Main}) end --界面打开时调用(用于子类重写) function CarbonsPanel:OnShow(...) -- 音效 SoundManager.PlayMusic(SoundConfig.BGM_Carbon) -- 刷新一次编队战斗力 FormationManager.RefreshMainFormationPower() self:DoRequest(function () self:ShowMap() self:SetTime() end) end --界面开启前的请求信息 function CarbonsPanel:DoRequest(func) NetManager.GetExpeditionRequest(ExpeditionManager.expeditionLeve) func() end function CarbonsPanel:ShowMap() for key, value in pairs(carbonData) do self.randomList[#self.randomList + 1] = key local go = self.btnList[key] local selfObj = Util.GetGameObject(self.map,value.objName) if not go then go = newObject(self.btnPre) go.transform:SetParent(selfObj.transform) go.transform.localScale = Vector3.one go.transform.localPosition = value.btnPos self.btnList[key] = go end go:SetActive(true) local nameImg = Util.GetGameObject(go,"Name"):GetComponent("Image") local lock = Util.GetGameObject(go,"Lock") local redPoint = Util.GetGameObject(go,"redPoint") local effect = Util.GetGameObject(selfObj,"GameObject/"..value.effect1) local canGetImg = Util.GetGameObject(go,"canGetImg"):GetComponent("Image") local titleImg = Util.GetGameObject(go,"Image"):GetComponent("Image") local titleName= Util.GetGameObject(go,"titleName"):GetComponent("Text") self.effectList[key] = Util.GetGameObject(selfObj,"GameObject/"..value.effect2) self.effectList[key]:SetActive(false) lock:SetActive(true) canGetImg.gameObject:SetActive(false) titleName.text=value.name titleImg.sprite = self.spLoader:LoadSprite(value.titleBg) nameImg.sprite = self.spLoader:LoadSprite(value.nameImg) nameImg:SetNativeSize() Util.SetParticleSortLayer(effect,self.sortingOrder + 1) Util.SetParticleSortLayer(self.effectList[key],self.sortingOrder + 1) if ActTimeCtrlManager.SingleFuncState(value.id) then BindRedPointObject(value.redPointType,redPoint) lock:SetActive(false) canGetImg.gameObject:SetActive(false) canGetImg.sprite = SetIcon(self.spLoader,systemConfig[value.id].RewardItemId) end self:TipShow(go,value) Util.SetGray(go, not ActTimeCtrlManager.SingleFuncState(value.id)) Util.AddOnceClick(selfObj,function () self:BtnClick(key) end) Util.AddOnceClick(go,function () self:BtnClick(key) end) end end --时间/剩余次数显示 function CarbonsPanel:TipShow(_go,_value) local openLevel = Util.GetGameObject(_go,"Grid/openlevel") local time = Util.GetGameObject(_go,"Grid/time") local freetimes = Util.GetGameObject(_go,"Grid/freetimes") local buytimes = Util.GetGameObject(_go,"Grid/buytimes") local redPoint = Util.GetGameObject(_go,"redPoint") local openLevelText = Util.GetGameObject(openLevel,"Text"):GetComponent("Text") local timeText = Util.GetGameObject(time,"Text"):GetComponent("Text") local freetimesText = Util.GetGameObject(freetimes,"Text"):GetComponent("Text") local buytimesText = Util.GetGameObject(buytimes,"Text"):GetComponent("Text") openLevel:SetActive(false) time:SetActive(false) freetimes:SetActive(false) buytimes:SetActive(false) if ActTimeCtrlManager.SingleFuncState(_value.id) then --免费次数 if _value.id == FUNCTION_OPEN_TYPE.MONSTER_COMING then freetimes:SetActive(true) buytimes:SetActive(true) freetimesText.text = string.format("免费扫荡次数:%s",MonsterCampManager.GetCanBattleCount()) buytimesText.text = string.format("剩余购买次数:%s",MonsterCampManager.GetCanBuyBattleCount()) elseif _value.id == FUNCTION_OPEN_TYPE.PEOPLE_MIRROR then freetimes:SetActive(true) buytimes:SetActive(true) local free,buy = XuanYuanMirrorManager.RetrunFreeAndBuyTimes() freetimesText.text = string.format("免费挑战次数:%s",free) buytimesText.text = string.format("剩余购买次数:%s",buy) elseif _value.id == FUNCTION_OPEN_TYPE.EXPEDITION then freetimes:SetActive(true) buytimes:SetActive(false) LogError("ExpeditionManager.expeditionLeve=="..ExpeditionManager.expeditionLeve) local free = ExpeditionManager.GetCurNodeInfo().lay-1+(expeditionLevel[ExpeditionManager.expeditionLeve]-1)*10 local num = free <= 30 and free or 30 freetimesText.text = string.format("进度:%s/%s",num,30) end --刷新时间 if _value.id == FUNCTION_OPEN_TYPE.EXPEDITION then--大闹天宫 time:SetActive(true) local expeditionData = systemConfig[JumpType.Expedition] self.timeList[_value.id] = {} self.timeList[_value.id].TextObj = timeText self.timeList[_value.id].Text = "剩余时间:" self.timeList[_value.id].time =ExpeditionManager.startTime + tonumber(expeditionData.SeasonEnd) - GetTimeStamp() + expeditionData.SeasonInterval * 60 - 300 elseif _value.id == FUNCTION_OPEN_TYPE.ENDLESS then--修行挑战 time:SetActive(false) self.timeList[_value.id] = {} self.timeList[_value.id].TextObj = timeText self.timeList[_value.id].Text = "剩余时间:" self.timeList[_value.id].time = CalculateSecondsNowTo_N_OClock(0) elseif _value.id == FUNCTION_OPEN_TYPE.TRIAL then--森罗幻境 time:SetActive(true) self.timeList[_value.id] = {} self.timeList[_value.id].TextObj = timeText self.timeList[_value.id].Text = "剩余时间:" self.timeList[_value.id].time = ActTimeCtrlManager.GetSerDataByTypeId(_value.id).endTime - GetTimeStamp() end if self.timeList[_value.id] then timeText.text = string.format("%s%s",self.timeList[_value.id].Text,TimeToFelaxible(self.timeList[_value.id].time)) end else openLevel:SetActive(true) openLevelText.text = string.format(ActTimeCtrlManager.GetFuncTip(_value.id)) if (_value.id == FUNCTION_OPEN_TYPE.EXPEDITION or _value.id == FUNCTION_OPEN_TYPE.ENDLESS or _value.id == FUNCTION_OPEN_TYPE.TRIAL) and ActTimeCtrlManager.IsQualifiled(_value.id) then--无尽副本、森罗幻境 openLevel:SetActive(false) redPoint:SetActive(false) self.timeList[_value.id] = {} self.timeList[_value.id].TextObj = timeText self.timeList[_value.id].Text = "重置时间:" self.timeList[_value.id].time = CalculateSecondsNowTo_N_OClock(24) end end end function CarbonsPanel:SetTime() if self.timer then self.timer:Stop() self.timer = nil end if self.timer2 then self.timer2:Stop() self.timer2 = nil end self.timer = Timer.New(function () for key, item in pairs(self.timeList) do item.TextObj.text = string.format("%s%s",item.Text,TimeToFelaxible(item.time)) item.time = item.time - 1 if item.time <= 0 then self:OnShow() end end end, 1, -1, true) self.timer:Start() self.timer2 = Timer.New(function () for key, value in pairs(self.effectList) do value:SetActive(false) end local num = math.random(1,#self.randomList) self.effectList[self.randomList[num]]:SetActive(false) end, 5, -1, true) self.timer2:Start() end --点击 function CarbonsPanel:BtnClick(id) if id == FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN then if ActTimeCtrlManager.SingleFuncState(id) == false then --如果未解锁 PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(id)) return end UIManager.OpenPanel(UIName.DailyCarbonPanel) elseif id == FUNCTION_OPEN_TYPE.MONSTER_COMING then if ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.FourElementTrail) then UIManager.OpenPanel(UIName.MonsterCampMainPanel) else JumpManager.GoJump(1011) end elseif id == FUNCTION_OPEN_TYPE.EXPEDITION then if ActTimeCtrlManager.SingleFuncState(id) then if #ExpeditionManager.nodeInfo <= 0 then if ExpeditionManager.expeditionLeve == -1 then NetManager.GetExpeditionRequest(2,function() JumpManager.GoJump(64001) end) else NetManager.GetExpeditionRequest(ExpeditionManager.expeditionLeve,function() JumpManager.GoJump(64001) end) end else JumpManager.GoJump(64001) end NetManager.TreasureOfHeavenScoreRequest() PlayerPrefs.SetInt(PlayerManager.uid.."ExpeditionRed",ActTimeCtrlManager.GetSerDataByTypeId(id).endTime) CheckRedPointStatus(RedPointType.OrdinaryExplore) else if ActTimeCtrlManager.IsQualifiled(id) then PopupTipPanel.ShowTip(Language[12183]) else PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(id)) end end -- elseif id == FUNCTION_OPEN_TYPE.CARDELAY then -- if ActTimeCtrlManager.IsQualifiled(id) then -- if PlayerManager.familyId == 0 then -- PopupTipPanel.ShowTip(Language[10278]) -- return -- end -- UIManager.OpenPanel(UIName.GuildCarDelayMainPanel) -- else -- PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(id)) -- end elseif id == FUNCTION_OPEN_TYPE.TRIAL then--森罗在此!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --LogGreen("点击进入森罗时候的层数"..MapTrialManager.curTowerLevel) if ActTimeCtrlManager.SingleFuncState(id) then CarbonManager.difficulty = CARBON_TYPE.TRIAL CarbonManager.carbonType = CARBON_TYPE.TRIAL local trialDataConfig = ConfigManager.GetConfig(ConfigName.TrialConfig) MapManager.curCarbonType =CarBonTypeId.TRIAL NetManager.MapInfoRequest(MapManager.curCarbonType, function(msg) MapManager.isReloadEnter = false MapTrialManager.firstEnter = true MapManager.SetViewSize(20)--设置视野范围(明雷形式) MapManager.curAreaId =FormationTypeDef.FORMATION_DREAMLAND MapTrialManager.isHaveBoss = false MapManager.isTimeOut = false SwitchPanel.OpenPanel(UIName.MapPanel) end) else if not ActTimeCtrlManager.IsQualifiled(id) then local config = ConfigManager.GetConfigData(ConfigName.GlobalSystemConfig,id) PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(id)) else PopupTipPanel.ShowTip(Language[10280]) end end elseif id == FUNCTION_OPEN_TYPE.PEOPLE_MIRROR then if ActTimeCtrlManager.IsQualifiled(id) then CarbonManager.difficulty = 1 UIManager.OpenPanel(UIName.XuanYuanMirrorPanel) else PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(id)) end elseif id == FUNCTION_OPEN_TYPE.ENDLESS then if ActTimeCtrlManager.IsQualifiled(id) then if ActTimeCtrlManager.SingleFuncState(id) then -- local serData = ActTimeCtrlManager.GetSerDataByTypeId(id) -- PlayerPrefs.SetInt("WuJin1"..PlayerManager.uid,serData.endTime) -- CheckRedPointStatus(RedPointType.EndlessPanel) -- MapManager.curCarbonType = CarBonTypeId.ENDLESS -- MapManager.SetViewSize(3)--设置视野范围(明雷形式) -- MapManager.isTimeOut = false -- UIManager.OpenPanel(UIName.EndLessCarbonPanel) UIManager.OpenPanel(UIName.ChallengeCopyPanel) else PopupTipPanel.ShowTip(Language[10281]) end else PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(id)) end elseif id == FUNCTION_OPEN_TYPE.FIGHTLEVEL then if ActTimeCtrlManager.SingleFuncState(id) then FightLevelManager.curSelect = 0 local time=PlayerPrefs.GetInt(PlayerManager.uid.."openFightLevelTime") if time==0 then NetManager.HardStageRequest(function() UIManager.OpenPanel(UIName.FightLevelChapterPanel) end) else UIManager.OpenPanel(UIName.FightLevelChapterPanel) end else PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(id)) end elseif id == FUNCTION_OPEN_TYPE.GodsWayTower_1 then if ActTimeCtrlManager.SingleFuncState(id) then local time=PlayerPrefs.GetInt(PlayerManager.uid.."openFightLevelTime") NetManager.RequestDuoduiInfoRequest(function() UIManager.OpenPanel(UIName.GodsWayListPanel) end) else PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(id)) end elseif id==FUNCTION_OPEN_TYPE.QIJIESHILIAN then --宇宙生存挑战 if ActTimeCtrlManager.SingleFuncState(id) then local tipStr="" local state=0 if not ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.QIJIESHILIAN) then state = -1 tipStr = ActTimeCtrlManager.GetFuncTip( FUNCTION_OPEN_TYPE.QIJIESHILIAN) end -- 跨服相关判断 if not JumpServerManager.GetQiJieIsStart() then state = -4 tipStr = string.format("开服第%s周开放!",ConfigManager.GetConfigData(ConfigName.MServerArenaSetting,3).OpenWeek) elseif not JumpServerManager.GetHightLadderDataIsGroup() then state = -5 tipStr = "未划分跨服分组,无法参与!" else state = 1 tipStr = "" end if state<1 then PopupTipPanel.ShowTip(tipStr) return end local qiejieConfig = ConfigManager.GetConfig(ConfigName.QijieStage) NetManager.SevenWorldInfoRequest(0,function (msg) QiJieShiLianManager.IsLock = false if qiejieConfig[msg.id] then UIManager.OpenPanel(UIName.QiJieShiLianPanel) else LogError("宇宙生存挑战不存在该ID:"..tostring(msg.id)) PopupTipPanel.ShowTip("无法进入,请联系客服!") end end) else --JumpManager.GoJump(40059) PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(id)) end elseif id==FUNCTION_OPEN_TYPE.HOMELAND then --洞府 if ActTimeCtrlManager.SingleFuncState(id) then JumpManager.GoJump(40059) else PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(id)) end elseif id==FUNCTION_OPEN_TYPE.LINGMAIMIJING then --灵脉 if not ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.LINGMAIMIJING) then PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip( FUNCTION_OPEN_TYPE.LINGMAIMIJING)) return end -- 跨服相关判断 if not JumpServerManager.GetLingMaiIsStart() then PopupTipPanel.ShowTip(string.format("开服第%s周开放!",ConfigManager.GetConfigData(ConfigName.MServerLodeSetting,1).OpenWeek)) return elseif not JumpServerManager.GetHightLadderDataIsGroup() then PopupTipPanel.ShowTip("未划分跨服分组,无法参与!") return end if ActTimeCtrlManager.SingleFuncState(id) then NetManager.GetLingMaiInfoRequest(0,function () if LingMaiMiJingManager.state == 0 then PopupTipPanel.ShowTip("今日不开放灵脉秘境玩法!") else if not LingMaiMiJingManager.GetData() then LogError("灵脉试炼数据为空") PopupTipPanel.ShowTip("灵脉暂无法进入,请耐心等待!") return end UIManager.OpenPanel(UIName.LingMaiMiJingPanel) end end) else PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(id)) end end end function CarbonsPanel:OnSortingOrderChange() self.BtView.gameObject:SetActive(true) -- 头像层级 if self.playerInfoView then self.playerInfoView:SetLayer(self.sortingOrder) end self.upviewParent:GetComponent("Canvas").sortingOrder = self.sortingOrder + 10 end --界面关闭时调用(用于子类重写) function CarbonsPanel:OnClose() for key, value in pairs(carbonData) do local redPoint = Util.GetGameObject(self.btnList[key],"redPoint") ClearRedPointObject(value.redPointType,redPoint) end if self.timer then self.timer:Stop() self.timer = nil end if self.timer2 then self.timer2:Stop() self.timer2 = nil end end --界面销毁时调用(用于子类重写) function CarbonsPanel:OnDestroy() self.spLoader:Destroy() if self.BtView then SubUIManager.Close(self.BtView) end if self.playerInfoView then SubUIManager.Close(self.playerInfoView) self.playerInfoView = nil end SubUIManager.Close(self.UpView) self.UpView = nil self.BtView = nil self.btnList = {} self.effectList = {} end return CarbonsPanel