444 lines
18 KiB
Lua
444 lines
18 KiB
Lua
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.PEOPLE_MIRROR] = {
|
|
id = FUNCTION_OPEN_TYPE.PEOPLE_MIRROR, --轩辕
|
|
objName = "xuanyuan",
|
|
nameImg = "f_fuben_fubenming_02",
|
|
btnPos = Vector2(-4,-60),
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
btnPos = Vector2(124,-49),
|
|
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 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")
|
|
self.effectList[key] = Util.GetGameObject(selfObj,"GameObject/"..value.effect2)
|
|
self.effectList[key]:SetActive(false)
|
|
lock:SetActive(true)
|
|
canGetImg.gameObject:SetActive(false)
|
|
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(true)
|
|
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)
|
|
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(true)
|
|
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
|
|
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 |