367 lines
15 KiB
Lua
367 lines
15 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="UI_hz_yt_03", titleImg = "chall_title_fangyu",name="防御副本", titleTip = GetLanguageStrById(specialConfig[150].Value),pos = Vector3.New(257.08,658.37,0)},
|
|
--伤害
|
|
[2]={bg="UI_hz_yt_04", titleImg = "chall_title_shanghai",name="伤害副本", titleTip = GetLanguageStrById(specialConfig[151].Value),pos = Vector3.New(257.08,651.24,0)},
|
|
}
|
|
--难度图片
|
|
local qualityBg={
|
|
[1]={s="r_richang_dengjie_jiandan_zh",b="r_richang_di_lan"},
|
|
[2]={s="r_richang_dengjie_putong_zh",b="r_richang_di_lan"},
|
|
[3]={s="r_richang_dengjie_kunnan_zh",b="r_richang_di_lan"},
|
|
[4]={s="r_richang_dengjie_emeng_zh",b="r_richang_di_zi"},
|
|
[5]={s="r_richang_dengjie_lianyu_zh",b="r_richang_di_zi"},
|
|
[6]={s="r_richang_dengjie_diyu_zh",b="r_richang_di_zi"},
|
|
[7]={s="r_richang_dengjie_shenyuan_zh",b="r_richang_di_hong"},
|
|
[8]={s="r_richang_dengjie_chuanqi_zh",b="r_richang_di_hong"},
|
|
[9]={s="r_richang_dengjie_shenhua_zh",b="r_richang_di_hong"}
|
|
}
|
|
|
|
local itemList={}--奖励容器
|
|
|
|
--每日副本服务器数据
|
|
local buyTime=0--剩余购买次数
|
|
local freeTime=0--剩余免费次数
|
|
|
|
--Tab
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
local _TabData={ [1] = { default = "UI_hz_gonghui_31", select = "UI_hz_gonghui_31",lock = "UI_hz_gonghui_31", name = Language[10285],type=FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN },
|
|
[2] = { default = "UI_hz_gonghui_32", select = "UI_hz_gonghui_32",lock = "UI_hz_gonghui_32", name = Language[10286],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.titleImg=Util.GetGameObject(this.panel,"TitleBg/Image"):GetComponent("Image")
|
|
this.titleTip=Util.GetGameObject(this.panel,"TitleBg/Text"):GetComponent("Text")
|
|
this.TilteTxt=Util.GetGameObject(this.panel,"TitleBg/TilteTxt"):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, 901.2), 1, 1, Vector2.New(0, 10))
|
|
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.titleImg.sprite=this.spLoader:LoadSprite(titleBg[i].titleImg)
|
|
this.titleTip.text=titleBg[i].titleTip
|
|
this.TilteTxt.text=titleBg[i].name
|
|
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 bgQuality=Util.GetGameObject(root,"Bg"):GetComponent("Image")
|
|
local title=Util.GetGameObject(root,"Title"):GetComponent("Image")
|
|
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=goBtn:GetComponent("Image")
|
|
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])--商店表数据
|
|
-- title.sprite=this.spLoader:LoadSprite(qualityBg[1].s)
|
|
title:SetNativeSize()
|
|
titleText.text=data.Section
|
|
-- local challengeStage= ConfigManager.GetConfigData(ConfigName.ChallengeStage,data.id)
|
|
copyName.text=data.Name
|
|
-- bgQuality.sprite=this.spLoader:LoadSprite(qualityBg[1].b)
|
|
type=CarbonManager.CheckChallengeCopyId(data.Chapter,data.NextLevel)
|
|
local showReward={}
|
|
ConnectTable(showReward,data.FixedReward)
|
|
-- ConnectTable(showReward,data.PassReward)
|
|
-- if type~=2 then
|
|
-- ConnectTable(showReward,data.VictoryReward)
|
|
-- end
|
|
ResetItemView(root,rewardGrid.transform,itemList,3,0.75,orginLayer,false,showReward)
|
|
for i = 0, 2 do
|
|
local item=rewardGrid.transform:GetChild(i)
|
|
-- local image = Util.GetGameObject(item,"PreciousShow")
|
|
-- image.gameObject:SetActive(true)
|
|
-- Util.GetGameObject(image, "Text").gameObject:SetActive(false)
|
|
-- if i==0 then
|
|
-- image:GetComponent("Image").sprite = this.spLoader:LoadSprite("x_xianyuan_baodijiaobiao_zh")
|
|
-- elseif i==1 then
|
|
-- image:GetComponent("Image").sprite = this.spLoader:LoadSprite("x_xianyuan_jindujiaobiao_zh")
|
|
-- else
|
|
-- image:GetComponent("Image").sprite = this.spLoader:LoadSprite("x_xianyuan_shoucijiaobiao_zh")
|
|
-- end
|
|
|
|
end
|
|
|
|
--解锁状态
|
|
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.sprite=this.spLoader:LoadSprite("chall_btn_tiaozhan")
|
|
power.text = _power
|
|
tip.gameObject:SetActive(false)
|
|
goBtnImage.gameObject:SetActive(true)
|
|
cost:SetActive(isOpen and freeTime<=0)
|
|
if type==2 then
|
|
-- goBtnImage.sprite=this.spLoader:LoadSprite("chall_btn_saodang")
|
|
score.gameObject:SetActive(true)
|
|
end
|
|
else
|
|
power.text = _power --string.format(Language[10291], _power)
|
|
goBtnImage.gameObject:SetActive(false)
|
|
tip.text="未开启"
|
|
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[10293],_lv))
|
|
return
|
|
elseif PlayerManager.maxForce < _power then
|
|
PopupTipPanel.ShowTip(string.format(Language[10294], _power))
|
|
return
|
|
elseif _point ~= 0 and not FightPointPassManager.IsFightPointPass(_point) then
|
|
PopupTipPanel.ShowTip(string.format(Language[10295], GetLanguageStrById(mainLevelConfig[_point].Name)))
|
|
return
|
|
end
|
|
if not isOpen then
|
|
PopupTipPanel.ShowTip(Language[10296])
|
|
return
|
|
end
|
|
|
|
--检测剩余次数
|
|
if buyTime<=0 and freeTime<=0 then
|
|
PopupTipPanel.ShowTip(Language[10297])
|
|
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[10298],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[12292],tostring(freeTime))
|
|
else
|
|
str=string.format(Language[10300],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 = _TabData[index].name
|
|
Util.GetGameObject(tab,"select"):SetActive(status=="select")
|
|
end
|
|
---检测tab是否锁定
|
|
function this.TabIsLockCheck(index)
|
|
if CarbonManager.challengeCopyDataTable[index].openState==0 then
|
|
local tipStr=""
|
|
if CarbonManager.challengeCopyDataTable[index].type==1 then
|
|
tipStr="副本每周一,三,五,七开启"
|
|
else
|
|
tipStr="副本每周二,四,六,七开启"
|
|
end
|
|
return true,tipStr
|
|
end
|
|
return false
|
|
end
|
|
|
|
return ChallengeCopyPanel |