279 lines
8.9 KiB
Lua
279 lines
8.9 KiB
Lua
require("Base/BasePanel")
|
|
EndLessCarbonPanel = Inherit(BasePanel)
|
|
local this = EndLessCarbonPanel
|
|
local endLessConfig = ConfigManager.GetConfig(ConfigName.EndlessMapConfig)
|
|
local mapConfig = ConfigManager.GetConfig(ConfigName.ChallengeConfig)
|
|
local hadClikcBuy = false
|
|
|
|
--初始化组件(用于子类重写)
|
|
function EndLessCarbonPanel:InitComponent()
|
|
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
|
|
-- 显示行动力
|
|
this.energy = Util.GetGameObject(self.gameObject, "Bg/bg1/miniMap/tBottom/energy")
|
|
this.curValue = Util.GetGameObject(self.energy, "energyInfo"):GetComponent("Text")
|
|
this.btnBuy = Util.GetGameObject(self.energy, "add")
|
|
|
|
-- 小地图
|
|
this.miniMap = Util.GetGameObject(self.gameObject, "Bg/bg1/miniMap"):GetComponent("Image")
|
|
this.miniMapName = Util.GetGameObject(this.miniMap.gameObject, "tBottom/main/mapName"):GetComponent("Text")
|
|
this.text2 = Util.GetGameObject(this.miniMap.gameObject, "tBottom/right/text"):GetComponent("Text")
|
|
|
|
-- 怪物组
|
|
this.bossGrid = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/bossList/grid")
|
|
this.bossGridText = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/bossList/grid/Text"):GetComponent("Text")
|
|
this.bossItemPre = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/bossList/itemPre")
|
|
|
|
-- 奖励预览
|
|
this.rewwardGrid = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/rewardList/grid")
|
|
|
|
this.btnFight = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/btnFight")
|
|
|
|
this.btnMapInfo = Util.GetGameObject(self.gameObject, "Bg/bg1/miniMap/mapInfo")
|
|
this.btnMapInfo:SetActive(false)
|
|
--幫助
|
|
this.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn ")
|
|
this.helpPosition = this.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
-- 行动力刷新倒计时显示
|
|
this.bgTime = Util.GetGameObject(self.energy, "Bgtime")
|
|
this.actCountTime = Util.GetGameObject(this.bgTime, "time"):GetComponent("Text")
|
|
|
|
--红点
|
|
this.redPoint = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/btnFight/redPoint")
|
|
|
|
this.rewardList = {}
|
|
this.bossList = {}
|
|
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function EndLessCarbonPanel:BindEvent()
|
|
|
|
Util.AddClick(this.btnBack, function ()
|
|
|
|
if UIManager.IsOpen(UIName.HelpPopup) then
|
|
UIManager.ClosePanel(UIName.HelpPopup)
|
|
end
|
|
-- !!!! PS: 这里必须是主动打开副本选择界面,从地图中返回时,这个界面的上一级是地图界面,
|
|
-- 如果只是关闭自己,则会打开地图界面,不会打开副本选择界面,导致报错
|
|
this:ClosePanel()
|
|
--检测到上一个面板打开之后,关闭自己
|
|
CallBackOnPanelOpen(UIName.CarbonsPanel, function()
|
|
UIManager.ClosePanel(UIName.EndLessCarbonPanel)
|
|
end)
|
|
CarbonManager.difficulty = 0
|
|
end)
|
|
|
|
Util.AddClick(this.btnFight, function ()
|
|
this.EnterMap()
|
|
end)
|
|
|
|
|
|
Util.AddClick(this.btnBuy, function ()
|
|
---- 先同步位置再弹出购买界面
|
|
--if not hadClikcBuy then
|
|
-- hadClikcBuy = true
|
|
UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = 1 })
|
|
--end
|
|
end)
|
|
|
|
Util.AddClick(this.btnMapInfo, function ()
|
|
--UIManager.OpenPanel(UIName.MinMapPopup)
|
|
end)
|
|
|
|
--帮助按钮
|
|
Util.AddClick(this.helpBtn, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.EndLessMap, this.helpPosition.x, this.helpPosition.y)
|
|
end)
|
|
|
|
BindRedPointObject(RedPointType.EndlessPanel,this.redPoint)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function EndLessCarbonPanel:AddListener()
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.InitActPowerShow)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function EndLessCarbonPanel:RemoveListener()
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.InitActPowerShow)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function EndLessCarbonPanel:OnOpen(...)
|
|
|
|
-- 初始化组件
|
|
this.InitCompShow()
|
|
-- 请求获取队伍血量
|
|
-- 设置静态表数据
|
|
this.SetStaticData()
|
|
this.RequestBlood(function ()
|
|
this.InitActPowerShow()
|
|
end)
|
|
|
|
end
|
|
|
|
function EndLessCarbonPanel:OnSortingOrderChange()
|
|
|
|
end
|
|
|
|
function EndLessCarbonPanel:OnShow()
|
|
this.InitActPowerShow()
|
|
this.ShowCountTime()
|
|
|
|
-- 界面打开时刷新队伍血量数据
|
|
hadClikcBuy = false
|
|
end
|
|
|
|
function this.InitActPowerShow()
|
|
local curEnergy = 0
|
|
curEnergy = BagManager.GetItemCountById(1)
|
|
local color = curEnergy <= 5 and "FF0014FF" or "A0B2B2FF"
|
|
local str = string.format("<color=#%s>%s</color>", color, tostring(curEnergy))
|
|
this.curValue.text = str
|
|
end
|
|
|
|
|
|
function this.RequestBlood(func)
|
|
NetManager.RequestAllHeroHp(function ()
|
|
if func then func() end
|
|
end)
|
|
end
|
|
|
|
function this.EnterMap()
|
|
CarbonManager.difficulty = CARBON_TYPE.ENDLESS
|
|
CarbonManager.carbonType = CARBON_TYPE.ENDLESS
|
|
local serData = ActTimeCtrlManager.GetSerDataByTypeId(FUNCTION_OPEN_TYPE.ENDLESS)
|
|
if not PlayerPrefs.HasKey("WuJin"..PlayerManager.uid) then
|
|
PlayerPrefs.SetInt("WuJin"..PlayerManager.uid, 0)
|
|
end
|
|
local note = PlayerPrefs.GetInt("WuJin"..PlayerManager.uid)
|
|
MapManager.curMapId = EndLessMapManager.openMapId
|
|
if serData.endTime ~= note then
|
|
-- 首次登录不清除数据
|
|
if note ~= 0 then
|
|
TaskManager.ResetEndlessMissionState()
|
|
end
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.CARBON, MapManager.curMapId)
|
|
else
|
|
MapManager.curCarbonType = CarBonTypeId.ENDLESS
|
|
NetManager.MapInfoRequest(MapManager.curCarbonType, function()
|
|
MapManager.isReloadEnter = false
|
|
SwitchPanel.OpenPanel(UIName.MapPanel)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function this.InitCompShow()
|
|
-- 8个奖励预览
|
|
for j = 1, 8 do
|
|
if not this.rewardList[j] then
|
|
this.rewardList[j] = SubUIManager.Open(SubUIConfig.ItemView, this.rewwardGrid.transform)
|
|
this.rewardList[j].gameObject:SetActive(false)
|
|
end
|
|
end
|
|
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.endlessDifficulty,"MapPool",EndLessMapManager.openMapId)
|
|
local lv = PlayerManager.level
|
|
local config = nil
|
|
for i = 1,#configs do
|
|
if lv >= configs[i].WorldLevel[1] and lv <= configs[i].WorldLevel[2] then
|
|
config = configs[i]
|
|
end
|
|
end
|
|
this.bossGridText.text = config.Desc
|
|
this.miniMapName.text = config.Title
|
|
end
|
|
|
|
function this.SetStaticData()
|
|
local mapData = endLessConfig[EndLessMapManager.openMapId]
|
|
if not mapData then Log(Language[12148]) end
|
|
|
|
for i = 1, #mapData.RewardShow do
|
|
local item = {}
|
|
local itemId = mapData.RewardShow[i][1]
|
|
item[#item + 1] = itemId
|
|
item[#item + 1] = 0
|
|
this.rewardList[i]:OnOpen(false, item, 1.05)
|
|
-- this.rewardList[i].gameObject:SetActive(true)
|
|
|
|
Timer.New(function()
|
|
this.rewardList[i].gameObject:SetActive(true)
|
|
PlayUIAnim(this.rewardList[i].gameObject)
|
|
end, 0.001 * (i - 1)):Start()
|
|
end
|
|
|
|
end
|
|
|
|
-- 行动力是否显示倒计时
|
|
function this.ShowCountTime()
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
end
|
|
this.timer = nil
|
|
this.actCountTime.text = ""
|
|
this.bgTime:SetActive(true)
|
|
local tempLeftTime = 0
|
|
-- 启动倒计时
|
|
this.timer = Timer.New(function ()
|
|
local leftTime = AutoRecoverManager.GetRecoverTime(1)
|
|
if leftTime >= tempLeftTime then
|
|
this.InitActPowerShow()
|
|
tempLeftTime = leftTime
|
|
end
|
|
if leftTime < 0 then
|
|
PlayerManager.RequestEnergy()
|
|
leftTime = 0
|
|
end
|
|
this.actCountTime.text = GetTimeMaoHaoStrBySeconds(math.floor(leftTime)).."后恢复1点"
|
|
end, 1, -1, true)
|
|
this.timer:Start()
|
|
|
|
if this.timer1 then
|
|
this.timer1:Stop()
|
|
this.timer1 = nil
|
|
end
|
|
local serData = ActTimeCtrlManager.GetSerDataByTypeId(FUNCTION_OPEN_TYPE.ENDLESS)
|
|
local freshData = serData.endTime - GetTimeStamp()
|
|
local updateTime = function()
|
|
this.text2.text = TimeToFelaxible(freshData).."后重置"
|
|
end
|
|
|
|
updateTime()
|
|
|
|
this.timer1 = Timer.New(function ()
|
|
freshData = freshData - 1
|
|
if freshData < 0 then
|
|
CheckRedPointStatus(RedPointType.EndlessPanel)
|
|
this:ClosePanel()
|
|
else
|
|
updateTime()
|
|
end
|
|
end, 1, -1, true)
|
|
this.timer1:Start()
|
|
|
|
end
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function EndLessCarbonPanel:OnClose()
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
if this.timer1 then
|
|
this.timer1:Stop()
|
|
this.timer1 = nil
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function EndLessCarbonPanel:OnDestroy()
|
|
ClearRedPointObject(RedPointType.EndlessPanel,this.redPoint)
|
|
this.rewardList = {}
|
|
this.bossList = {}
|
|
end
|
|
|
|
return EndLessCarbonPanel |