miduo_client/Assets/ManagedResources/~Lua/Modules/Carbon/NewCarbon/CarbonsPanel.lua

416 lines
17 KiB
Lua
Raw Normal View History

2021-07-06 11:55:21 +08:00
require("Base/BasePanel")
local CarbonsPanel = Inherit(BasePanel)
2021-07-06 18:32:23 +08:00
local systemConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig)
2021-07-06 11:55:21 +08:00
local carbonData = {
2021-07-15 15:25:25 +08:00
[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",
2021-07-06 11:55:21 +08:00
},
2021-07-06 18:32:23 +08:00
[FUNCTION_OPEN_TYPE.MONSTER_COMING] = {
2021-07-06 11:55:21 +08:00
id = FUNCTION_OPEN_TYPE.MONSTER_COMING, --心魔
2021-07-06 18:32:23 +08:00
objName = "monster",
2021-07-07 14:43:37 +08:00
nameImg = "f_fuben_fubenming_04",
btnPos = Vector2(-39,-110),
2021-07-06 16:30:58 +08:00
redPointType = RedPointType.EpicExplore,
2021-07-15 15:25:25 +08:00
effect1 = "Fx_XinMoShiLian",
effect2 = "Fx_XinMoShiLian_S",
2021-07-06 11:55:21 +08:00
},
2021-07-06 18:32:23 +08:00
[FUNCTION_OPEN_TYPE.ENDLESS] = {
2021-07-06 11:55:21 +08:00
id = FUNCTION_OPEN_TYPE.ENDLESS, --无尽
2021-07-06 18:32:23 +08:00
objName = "endless",
2021-07-07 14:43:37 +08:00
nameImg = "f_fuben_fubenming_06",
btnPos = Vector2(302,63),
2021-07-06 16:30:58 +08:00
redPointType = RedPointType.EndLess,
2021-07-15 15:25:25 +08:00
effect1 = "Fx_WuJinFuBen",
effect2 = "Fx_WuJinFuBen_S",
2021-07-06 11:55:21 +08:00
},
2021-07-06 18:32:23 +08:00
[FUNCTION_OPEN_TYPE.FIGHTLEVEL] = {
2021-07-06 14:47:10 +08:00
id = FUNCTION_OPEN_TYPE.FIGHTLEVEL, --山河社稷图
2021-07-06 18:32:23 +08:00
objName = "fightlevel",
2021-07-07 14:43:37 +08:00
nameImg = "f_fuben_fubenming_07",
btnPos = Vector2(5,-224),
2021-07-06 16:30:58 +08:00
redPointType = RedPointType.FightLevel,
2021-07-15 15:25:25 +08:00
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,47),
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(-189,21),
redPointType = RedPointType.Trial,
effect1 = "Fx_SenLuoHuanJjing",
effect2 = "Fx_SenLuoHuanJjing_S",
2021-07-06 14:47:10 +08:00
},
2021-07-06 11:55:21 +08:00
}
--初始化组件(用于子类重写)
function CarbonsPanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.sortingOrder = 0
if not self.playerInfoView then
2021-07-06 14:47:10 +08:00
self.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, self.transform)
2021-07-06 11:55:21 +08:00
end
2021-07-06 14:47:10 +08:00
self.BtView = SubUIManager.Open(SubUIConfig.BtView, self.transform)
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
2021-07-15 19:46:43 +08:00
self.upviewParent = Util.GetGameObject(self.gameObject,"upviewP")
self.playerInfoView.transform:SetParent(self.upviewParent.transform)
self.UpView.transform:SetParent(self.upviewParent.transform)
2021-07-06 14:47:10 +08:00
2021-07-07 13:50:11 +08:00
self.map = Util.GetGameObject(self.gameObject,"Map")
self.btnPre = Util.GetGameObject(self.gameObject,"btnPre")
self.btnList = {}
2021-07-07 17:05:32 +08:00
self.timeList = {}
2021-07-15 15:25:25 +08:00
self.effectList = {}
2021-07-15 15:54:18 +08:00
self.randomList = {}
2021-07-06 11:55:21 +08:00
end
--绑定事件(用于子类重写)
function CarbonsPanel:BindEvent()
end
--添加事件监听(用于子类重写)
function CarbonsPanel:AddListener()
end
--移除事件监听(用于子类重写)
function CarbonsPanel:RemoveListener()
end
2021-07-06 16:30:58 +08:00
2021-07-06 11:55:21 +08:00
function CarbonsPanel:OnOpen()
2021-07-06 14:47:10 +08:00
self.BtView.gameObject:SetActive(true)
self.BtView:OnOpen(self, {sortOrder = self.sortingOrder, panelType = PanelTypeView.Carbon})
2021-07-06 11:55:21 +08:00
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()
2021-07-06 11:55:21 +08:00
end
2021-07-06 14:47:10 +08:00
function CarbonsPanel:ShowMap()
2021-07-07 13:50:11 +08:00
for key, value in pairs(carbonData) do
2021-07-15 15:54:18 +08:00
self.randomList[#self.randomList + 1] = key
2021-07-07 13:50:11 +08:00
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
2021-07-07 14:43:37 +08:00
go.transform.localPosition = value.btnPos
2021-07-07 13:50:11 +08:00
self.btnList[key] = go
end
go:SetActive(true)
2021-07-07 14:43:37 +08:00
local nameImg = Util.GetGameObject(go,"Name"):GetComponent("Image")
local lock = Util.GetGameObject(go,"Lock")
2021-07-07 17:05:32 +08:00
local redPoint = Util.GetGameObject(go,"redPoint")
2021-07-15 15:25:25 +08:00
local effect = Util.GetGameObject(selfObj,"GameObject/"..value.effect1)
2021-07-22 15:13:24 +08:00
local canGetImg = Util.GetGameObject(go,"canGetImg"):GetComponent("Image")
2021-07-15 15:25:25 +08:00
self.effectList[key] = Util.GetGameObject(selfObj,"GameObject/"..value.effect2)
self.effectList[key]:SetActive(false)
2021-07-07 17:05:32 +08:00
lock:SetActive(true)
2021-07-22 15:13:24 +08:00
canGetImg.gameObject:SetActive(false)
2021-07-07 14:43:37 +08:00
nameImg.sprite = self.spLoader:LoadSprite(value.nameImg)
2021-07-22 15:13:24 +08:00
nameImg:SetNativeSize()
2021-07-15 15:25:25 +08:00
Util.SetParticleSortLayer(effect,self.sortingOrder + 1)
Util.SetParticleSortLayer(self.effectList[key],self.sortingOrder + 1)
2021-07-07 14:43:37 +08:00
if ActTimeCtrlManager.SingleFuncState(value.id) then
2021-07-07 17:05:32 +08:00
BindRedPointObject(value.redPointType,redPoint)
2021-07-07 14:43:37 +08:00
lock:SetActive(false)
2021-07-22 15:13:24 +08:00
canGetImg.gameObject:SetActive(true)
canGetImg.sprite = SetIcon(self.spLoader,systemConfig[value.id].RewardItemId)
2021-07-07 14:43:37 +08:00
end
2021-07-07 17:05:32 +08:00
self:TipShow(go,value)
2021-07-22 15:13:24 +08:00
Util.SetGray(go, not ActTimeCtrlManager.SingleFuncState(value.id))
2021-07-07 13:50:11 +08:00
Util.AddOnceClick(selfObj,function ()
self:BtnClick(key)
end)
Util.AddOnceClick(go,function ()
self:BtnClick(key)
end)
2021-07-07 13:50:11 +08:00
end
2021-07-06 14:47:10 +08:00
end
2021-07-06 11:55:21 +08:00
2021-07-07 17:05:32 +08:00
--时间/剩余次数显示
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")
2021-07-07 17:05:32 +08:00
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)
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
2021-07-07 17:05:32 +08:00
elseif _value.id == FUNCTION_OPEN_TYPE.ENDLESS then--无尽副本
time:SetActive(true)
self.timeList[_value.id] = {}
self.timeList[_value.id].TextObj = timeText
self.timeList[_value.id].Text = "剩余时间:"
2021-07-07 17:05:32 +08:00
self.timeList[_value.id].time = ActTimeCtrlManager.GetSerDataByTypeId(FUNCTION_OPEN_TYPE.ENDLESS).endTime - GetTimeStamp()
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 = "剩余时间:"
2021-07-07 17:05:32 +08:00
self.timeList[_value.id].time = ActTimeCtrlManager.GetSerDataByTypeId(FUNCTION_OPEN_TYPE.TRIAL).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))
2021-07-07 17:05:32 +08:00
end
else
openLevel:SetActive(true)
openLevelText.text = string.format("%s级开启",systemConfig[_value.id].OpenRules[2])
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
2021-07-07 17:05:32 +08:00
end
end
function CarbonsPanel:SetTime()
if self.timer then
self.timer:Stop()
self.timer = nil
end
2021-07-15 15:54:18 +08:00
if self.timer2 then
self.timer2:Stop()
self.timer2 = nil
end
2021-07-07 17:05:32 +08:00
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))
2021-07-07 17:05:32 +08:00
item.time = item.time - 1
if item.time <= 0 then
self:OnShow()
end
end
end, 1, -1, true)
self.timer:Start()
2021-07-15 15:54:18 +08:00
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()
2021-07-07 17:05:32 +08:00
end
--点击
2021-07-06 11:55:21 +08:00
function CarbonsPanel:BtnClick(id)
if id == FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN then
if ActTimeCtrlManager.SingleFuncState(id) == false then --如果未解锁
PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN))
return
end
UIManager.OpenPanel(UIName.DailyCarbonPanel)
elseif id == FUNCTION_OPEN_TYPE.MONSTER_COMING then
JumpManager.GoJump(1011)
elseif id == FUNCTION_OPEN_TYPE.EXPEDITION then
if ActTimeCtrlManager.SingleFuncState(id) then
if #ExpeditionManager.nodeInfo <= 0 then
if ExpeditionManager.expeditionLeve == -1 then
2021-07-07 14:43:37 +08:00
NetManager.GetExpeditionRequest(2,function()
JumpManager.GoJump(64001)
end)
2021-07-06 11:55:21 +08:00
else
2021-07-07 14:43:37 +08:00
NetManager.GetExpeditionRequest(ExpeditionManager.expeditionLeve,function()
JumpManager.GoJump(64001)
end)
2021-07-06 11:55:21 +08:00
end
else
JumpManager.GoJump(64001)
end
NetManager.TreasureOfHeavenScoreRequest()
PlayerPrefs.SetInt(PlayerManager.uid.."ExpeditionRed",ActTimeCtrlManager.GetSerDataByTypeId(FUNCTION_OPEN_TYPE.EXPEDITION).endTime)
CheckRedPointStatus(RedPointType.OrdinaryExplore)
else
if ActTimeCtrlManager.IsQualifiled(id) then
PopupTipPanel.ShowTip(Language[12183])
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.EXPEDITION))
end
end
2021-07-07 17:05:32 +08:00
-- 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
2021-07-06 11:55:21 +08:00
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,FUNCTION_OPEN_TYPE.TRIAL)
PopupTipPanel.ShowTip(string.format(Language[10279],config.OpenRules[2]))
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
local config = ConfigManager.GetConfigData(ConfigName.GlobalSystemConfig,FUNCTION_OPEN_TYPE.PEOPLE_MIRROR)
PopupTipPanel.ShowTip(string.format(Language[10279],config.OpenRules[2]))
end
elseif id == FUNCTION_OPEN_TYPE.ENDLESS then
if ActTimeCtrlManager.IsQualifiled(id) then
if ActTimeCtrlManager.SingleFuncState(id) then
local serData = ActTimeCtrlManager.GetSerDataByTypeId(FUNCTION_OPEN_TYPE.ENDLESS)
PlayerPrefs.SetInt("WuJin1"..PlayerManager.uid,serData.endTime)
CheckRedPointStatus(RedPointType.EndlessPanel)
MapManager.curCarbonType = CarBonTypeId.ENDLESS
MapManager.SetViewSize(3)--设置视野范围(明雷形式)
MapManager.isTimeOut = false
UIManager.OpenPanel(UIName.EndLessCarbonPanel)
else
PopupTipPanel.ShowTip(Language[10281])
end
2021-07-06 11:55:21 +08:00
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.TRIAL))
2021-07-06 11:55:21 +08:00
end
2021-07-07 14:43:37 +08:00
elseif id == FUNCTION_OPEN_TYPE.FIGHTLEVEL then
if ActTimeCtrlManager.SingleFuncState(id) then
UIManager.OpenPanel(UIName.FightLevelChapterPanel)
else
PopupTipPanel.ShowTip(ActTimeCtrlManager.SystemOpenTip(FUNCTION_OPEN_TYPE.FIGHTLEVEL))
end
2021-07-06 11:55:21 +08:00
end
end
function CarbonsPanel:OnSortingOrderChange()
self.BtView.gameObject:SetActive(true)
-- 头像层级
if self.playerInfoView then
self.playerInfoView:SetLayer(self.sortingOrder)
end
2021-07-15 19:46:43 +08:00
self.upviewParent:GetComponent("Canvas").sortingOrder = self.sortingOrder + 10
2021-07-06 11:55:21 +08:00
end
--界面关闭时调用(用于子类重写)
function CarbonsPanel:OnClose()
2021-07-07 17:05:32 +08:00
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
2021-07-15 15:54:18 +08:00
if self.timer2 then
self.timer2:Stop()
self.timer2 = nil
end
2021-07-06 11:55:21 +08:00
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
2021-07-07 13:50:11 +08:00
self.btnList = {}
2021-07-15 15:25:25 +08:00
self.effectList = {}
2021-07-06 11:55:21 +08:00
end
return CarbonsPanel