331 lines
13 KiB
Lua
331 lines
13 KiB
Lua
----- 日常副本 -----
|
|
require("Base/BasePanel")
|
|
ChallengeCopyPanel = Inherit(BasePanel)
|
|
local this = ChallengeCopyPanel
|
|
local mainLevelConfig = ConfigManager.GetConfig(ConfigName.MainLevelConfig)
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
|
|
local curData = {}
|
|
|
|
local orginLayer = 0
|
|
|
|
local carbonIndex = 0 -- 1 无尽副本 2 金币副本 副本索引id
|
|
local fightIndex = 1 --关卡索引
|
|
local maxForce = 0
|
|
--顶部背景图
|
|
local titleBg = {
|
|
--回合
|
|
[1] = { bg = "godsWayTower_floor_bg2", titleImg = "chall_title_fangyu", name = Language[10307], titleTip = GetLanguageStrById(specialConfig[150].Value), pos = Vector3.New(257.08, 658.37, 0) },
|
|
--伤害
|
|
[2] = { bg = "godsWayTower_floor_bg1", titleImg = "chall_title_shanghai", name = Language[10308], titleTip = GetLanguageStrById(specialConfig[151].Value), pos = Vector3.New(257.08, 651.24, 0) },
|
|
}
|
|
|
|
local itemList = {} --奖励容器
|
|
|
|
--每日副本服务器数据
|
|
local buyTime = 0 --剩余购买次数
|
|
local freeTime = 0 --剩余免费次数
|
|
|
|
--Tab
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabData = {
|
|
[1] = { default = "chall_tab_btn1", select = "chall_tab_btn1", lock = "chall_tab_btn1", btnName = Language[10307], name = Language[10309], type = FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN },
|
|
[2] = { default = "chall_tab_btn2", select = "chall_tab_btn2", lock = "chall_tab_btn2", btnName = Language[10308], name = Language[10310], type = FUNCTION_OPEN_TYPE.DAILYCHALLENGE_EXP },
|
|
}
|
|
|
|
function ChallengeCopyPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.panel = Util.GetGameObject(this.gameObject, "Panel")
|
|
this.titleBg = Util.GetGameObject(this.panel, "TitleBg"):GetComponent("Image")
|
|
this.titleTip = Util.GetGameObject(this.panel, "TitleBg/Text"):GetComponent("Text")
|
|
this.titleTextName = Util.GetGameObject(this.panel, "TitleBg/TextTitleName"):GetComponent("Text")
|
|
this.timeTip = Util.GetGameObject(this.panel, "TimeTip"):GetComponent("Text")
|
|
this.backBtn = Util.GetGameObject(this.panel, "BackBtn")
|
|
this.helpBtn = Util.GetGameObject(this.panel, "HelpBtn")
|
|
this.helpPosition = this.helpBtn:GetComponent("RectTransform").localPosition
|
|
--滚动条
|
|
this.pre = Util.GetGameObject(this.panel, "Scroll/Pre")
|
|
this.scroll = Util.GetGameObject(this.panel, "Scroll")
|
|
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scroll.transform,
|
|
this.pre, nil, Vector2.New(1080, 1000), 1, 1, Vector2.New(40, -30))
|
|
this.scrollView.moveTween.MomentumAmount = 1
|
|
this.scrollView.moveTween.Strength = 2
|
|
|
|
this.upView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
|
|
|
|
this.tabBox = Util.GetGameObject(this.panel, "TabBox")
|
|
this.TabCtrl = TabBox.New()
|
|
end
|
|
|
|
function ChallengeCopyPanel:BindEvent()
|
|
--返回按钮
|
|
Util.AddClick(this.backBtn, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
self:ClosePanel()
|
|
end)
|
|
--帮助按钮
|
|
Util.AddClick(this.helpBtn, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup, 128, this.helpPosition.x, this.helpPosition.y)
|
|
end)
|
|
end
|
|
|
|
function ChallengeCopyPanel:OnSortingOrderChange()
|
|
orginLayer = self.sortingOrder
|
|
for i, v in pairs(itemList) do
|
|
for j = 1, #itemList[i] do
|
|
itemList[i][j]:SetEffectLayer(orginLayer)
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChallengeCopyPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.ChallengeCopy.RefreshView, this.FiveRefresh)
|
|
end
|
|
|
|
function ChallengeCopyPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.ChallengeCopy.RefreshView, this.FiveRefresh)
|
|
end
|
|
|
|
function ChallengeCopyPanel:OnOpen(_carbonIndex)
|
|
carbonIndex = CarbonManager.CheckCopyOpenState(1) and 1 or 2
|
|
this.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
|
|
end
|
|
|
|
function ChallengeCopyPanel:OnShow()
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
|
|
local curFormationForce = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
if PlayerManager.maxForce < curFormationForce then
|
|
PlayerManager.maxForce = curFormationForce
|
|
end
|
|
maxForce = PlayerManager.maxForce
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
this.TabCtrl:SetTabIsLockCheck(this.TabIsLockCheck)
|
|
this.TabCtrl:SetChangeTabCallBack(function(index)
|
|
this.RefreshShow(index)
|
|
end)
|
|
this.TabCtrl:Init(this.tabBox, _TabData, carbonIndex)
|
|
-- 音效
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
|
|
end
|
|
|
|
function ChallengeCopyPanel:RefreshRedPotShow()
|
|
local tabs = Util.GetGameObject(this.tabBox, "box").transform
|
|
for i = 1, tabs.childCount do
|
|
Util.GetGameObject(tabs:GetChild(i - 1), "Redpot").gameObject:SetActive(CarbonManager.challengeCopyDataTable[i]
|
|
.openState == 1 and freeTime > 0)
|
|
end
|
|
CheckRedPointStatus(RedPointType.challengeCopy)
|
|
end
|
|
|
|
function ChallengeCopyPanel:OnClose()
|
|
|
|
end
|
|
|
|
function ChallengeCopyPanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
itemList = {}
|
|
this.scrollView = nil
|
|
SubUIManager.Close(this.upView)
|
|
end
|
|
|
|
function this.FiveRefresh()
|
|
this.RefreshShow(carbonIndex)
|
|
end
|
|
|
|
--刷新面板
|
|
function this.RefreshShow(i)
|
|
carbonIndex = i
|
|
local challengeStageId = CarbonManager.challengeCopyDataTable[carbonIndex].currentFloor
|
|
if challengeStageId > 0 then
|
|
fightIndex = ConfigManager.GetConfigData(ConfigName.ChallengeStage, challengeStageId).Section
|
|
else
|
|
fightIndex = 1
|
|
end
|
|
curData = {}
|
|
curData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ChallengeStage, "Chapter", i)
|
|
this.titleBg.sprite = this.spLoader:LoadSprite(titleBg[i].bg)
|
|
this.titleTextName.text = GetLanguageStrById(titleBg[i].name)
|
|
this.titleTip.text = GetLanguageStrById(titleBg[i].titleTip)
|
|
this.SetTimeTip()
|
|
this.SetScroll(fightIndex)
|
|
ChallengeCopyPanel:RefreshRedPotShow()
|
|
end
|
|
|
|
--设置滚动条
|
|
function this.SetScroll(i)
|
|
LogRed("列表索引:" .. i)
|
|
this.scrollView:SetData(curData, function(index, root)
|
|
this.SetData(root, curData[index], curData[index - 1])
|
|
end, false, false)
|
|
this.scrollView:SetIndex(i)
|
|
end
|
|
|
|
--设置滚动条数据 root根节点 data本地表数据
|
|
function this.SetData(root, data)
|
|
local type = 0 --0为未开启 1为挑战 2为扫荡
|
|
local titleText = Util.GetGameObject(root, "TitleText"):GetComponent("Text")
|
|
local copyName = Util.GetGameObject(root, "nameLay/nameBg/name"):GetComponent("Text")
|
|
local score = Util.GetGameObject(root, "nameLay/score"):GetComponent("Image")
|
|
local rewardGrid = Util.GetGameObject(root, "Reward")
|
|
local tip = Util.GetGameObject(root, "Tip"):GetComponent("Text")
|
|
local power = Util.GetGameObject(root, "powerBtn/value"):GetComponent("Text")
|
|
power.transform.parent.gameObject:SetActive(false)
|
|
local goBtn = Util.GetGameObject(root, "GoBtn")
|
|
local goBtnImage = Util.GetGameObject(root, "GoBtn/TextGo"):GetComponent("Text")
|
|
local cost = Util.GetGameObject(root, "cost")
|
|
local goIconNumText = Util.GetGameObject(cost, "IconNum"):GetComponent("Text")
|
|
|
|
local storeData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.StoreConfig, "StoreId", 7, "Limit",
|
|
data.PivilegeID[1]) --商店表数据
|
|
titleText.text = GetLanguageStrById(data.Section)
|
|
copyName.text = GetLanguageStrById(data.Name)
|
|
type = CarbonManager.CheckChallengeCopyId(data.Chapter, data.NextLevel)
|
|
local showReward = {}
|
|
ConnectTable(showReward, data.FixedReward)
|
|
ResetItemView(root, rewardGrid.transform, itemList, 3, 0.75, orginLayer, false, showReward)
|
|
|
|
--解锁状态
|
|
local _lv = 0 --等级
|
|
local _point = 0 --关卡
|
|
local _power = 0 --data.ForceShow--表战力
|
|
|
|
for i = 1, #data.LevelLimit do
|
|
if data.LevelLimit[i][1] == 1 then
|
|
_lv = data.LevelLimit[i][2]
|
|
elseif data.LevelLimit[i][1] == 2 then
|
|
_power = data.LevelLimit[i][2]
|
|
elseif data.LevelLimit[i][1] == 3 then
|
|
_point = data.LevelLimit[i][2]
|
|
end
|
|
end
|
|
|
|
-- 判断每日副本是否解锁
|
|
local isOpen = CarbonManager.CheckChallengeCopyId(data.Chapter, data.NextLevel) > 0 -- 上一个副本解锁
|
|
and PlayerManager.level >= _lv -- 等级
|
|
and PlayerManager.maxForce >= _power -- 战斗力
|
|
--显示挑战或扫荡道具消耗
|
|
cost:SetActive(false)
|
|
|
|
local usedTime = PrivilegeManager.GetPrivilegeUsedTimes(storeData.Limit) --已使用次数
|
|
local limitTime = PrivilegeManager.GetPrivilegeNumber(storeData.Limit) --购买次数上限
|
|
local buyTimes = (usedTime + 1) > limitTime and limitTime or usedTime + 1
|
|
LogBlue("~~~~~~~usedTime:" .. usedTime .. " limitTime" .. limitTime)
|
|
if freeTime <= 0 then
|
|
goIconNumText.text = storeData.Cost[2][buyTimes]
|
|
end
|
|
--表现显示
|
|
Util.SetGray(goBtn, not isOpen)
|
|
score.gameObject:SetActive(false)
|
|
if type == 1 or type == 2 then
|
|
goBtnImage.text = Language[10311]
|
|
power.text = _power
|
|
tip.gameObject:SetActive(false)
|
|
goBtn.gameObject:SetActive(true)
|
|
cost:SetActive(isOpen and freeTime <= 0)
|
|
if type == 2 then
|
|
goBtnImage.text = Language[10312]
|
|
score.gameObject:SetActive(true)
|
|
end
|
|
else
|
|
power.text = _power --string.format(Language[10313], _power)
|
|
goBtn.gameObject:SetActive(false)
|
|
tip.text = Language[10314]
|
|
tip.gameObject:SetActive(true)
|
|
end
|
|
power.color = PlayerManager.maxForce >= _power and UIColor.WRITE or UIColor.RED
|
|
|
|
--点击事件
|
|
Util.AddOnceClick(goBtn, function()
|
|
if PlayerManager.level < _lv then
|
|
PopupTipPanel.ShowTip(string.format(Language[10315], _lv))
|
|
return
|
|
elseif PlayerManager.maxForce < _power then
|
|
PopupTipPanel.ShowTip(string.format(Language[10316], _power))
|
|
return
|
|
elseif _point ~= 0 and not FightPointPassManager.IsFightPointPass(_point) then
|
|
PopupTipPanel.ShowTip(string.format(Language[10317], GetLanguageStrById(mainLevelConfig[_point].Name)))
|
|
return
|
|
end
|
|
if not isOpen then
|
|
PopupTipPanel.ShowTip(Language[10318])
|
|
return
|
|
end
|
|
|
|
--检测剩余次数
|
|
if buyTime <= 0 and freeTime <= 0 then
|
|
PopupTipPanel.ShowTip(Language[10319])
|
|
return
|
|
end
|
|
--检测妖晶数量
|
|
local itemId = storeData.Cost[1][1] --消耗道具
|
|
|
|
if BagManager.GetItemCountById(itemId) < storeData.Cost[2][buyTimes] and freeTime <= 0 then
|
|
PopupTipPanel.ShowTip(string.format(Language[10320], GetLanguageStrById(itemConfig[itemId].Name)))
|
|
return
|
|
end
|
|
|
|
--当免费次数不足 是扫荡 购买次数
|
|
if freeTime <= 0 then
|
|
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP, storeData.Id, 1, function() end)
|
|
end
|
|
|
|
if type == 1 then --挑战
|
|
if data.Chapter == 1 then
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.ChallengeCopy_1, data)
|
|
else
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.ChallengeCopy_2, data)
|
|
end
|
|
elseif type == 2 then --扫荡
|
|
NetManager.ChallengeCopyRequest(data.Chapter, 2, data.Id, function(msg)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1, function()
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(data.PivilegeID[2], 1)
|
|
this.RefreshShow(carbonIndex, false, false)
|
|
end)
|
|
end)
|
|
end
|
|
end)
|
|
end
|
|
|
|
--设置剩余次数
|
|
function this.SetTimeTip()
|
|
local storeData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.StoreConfig, "StoreId", 7, "Limit",
|
|
curData[1].PivilegeID[1]) --商店表数据
|
|
local buyTimeId = curData[1].PivilegeID[1]
|
|
local freeTimeId = curData[1].PivilegeID[2]
|
|
buyTime = ShopManager.GetShopItemRemainBuyTimes(SHOP_TYPE.FUNCTION_SHOP, storeData.Id) --购买次数
|
|
freeTime = PrivilegeManager.GetPrivilegeRemainValue(freeTimeId) --免费次数
|
|
local str = ""
|
|
if freeTime > 0 then
|
|
str = string.format(Language[10321], tostring(freeTime))
|
|
else
|
|
str = string.format(Language[10322], tostring(buyTime))
|
|
end
|
|
this.timeTip.text = str
|
|
end
|
|
|
|
-- tab节点显示自定义
|
|
function this.TabAdapter(tab, index, status)
|
|
local lock = Util.GetGameObject(tab, "LockImage")
|
|
local islock = status == "lock"
|
|
Util.SetGray(Util.GetGameObject(tab, "Image").gameObject, islock)
|
|
lock:SetActive(islock)
|
|
Util.GetGameObject(tab, "Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
|
|
Util.GetGameObject(tab, "Text"):GetComponent("Text").text = GetLanguageStrById(_TabData[index].btnName)
|
|
end
|
|
|
|
---检测tab是否锁定
|
|
function this.TabIsLockCheck(index)
|
|
if CarbonManager.challengeCopyDataTable[index].openState == 0 then
|
|
local tipStr = ""
|
|
if CarbonManager.challengeCopyDataTable[index].type == 1 then
|
|
tipStr = Language[10323]
|
|
else
|
|
tipStr = Language[10324]
|
|
end
|
|
return true, tipStr
|
|
end
|
|
return false
|
|
end
|
|
|
|
return ChallengeCopyPanel
|