2020-05-09 13:31:21 +08:00
|
|
|
|
----- 日常副本 -----
|
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
DailyCarbonPanel = Inherit(BasePanel)
|
|
|
|
|
local this = DailyCarbonPanel
|
|
|
|
|
local dailyChallengeConfig=ConfigManager.GetConfig(ConfigName.DailyChallengeConfig)
|
|
|
|
|
local mainLevelConfig = ConfigManager.GetConfig(ConfigName.MainLevelConfig)
|
|
|
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local curData={}
|
|
|
|
|
|
|
|
|
|
local orginLayer=0
|
|
|
|
|
|
|
|
|
|
local carbonIndex=0--副本索引
|
|
|
|
|
|
|
|
|
|
--顶部背景图
|
|
|
|
|
local titleBg={
|
|
|
|
|
[1]="r_richang_banner_5",
|
|
|
|
|
[2]="r_richang_banner_4",
|
|
|
|
|
[3]="r_richang_banner_3",
|
|
|
|
|
[4]="r_richang_banner_2",
|
|
|
|
|
[5]="r_richang_banner_1",
|
|
|
|
|
}
|
|
|
|
|
--难度图片
|
|
|
|
|
local qualityBg={
|
|
|
|
|
[1]={s="r_richang_dengjie_jiandan",b="r_richang_di_lan"},
|
|
|
|
|
[2]={s="r_richang_dengjie_putong",b="r_richang_di_lan"},
|
|
|
|
|
[3]={s="r_richang_dengjie_kunnan",b="r_richang_di_lan"},
|
|
|
|
|
[4]={s="r_richang_dengjie_emeng",b="r_richang_di_zi"},
|
|
|
|
|
[5]={s="r_richang_dengjie_lianyu",b="r_richang_di_zi"},
|
|
|
|
|
[6]={s="r_richang_dengjie_diyu",b="r_richang_di_zi"},
|
|
|
|
|
[7]={s="r_richang_dengjie_shenyuan",b="r_richang_di_hong"},
|
|
|
|
|
[8]={s="r_richang_dengjie_chuanqi",b="r_richang_di_hong"},
|
|
|
|
|
[9]={s="r_richang_dengjie_shenhua",b="r_richang_di_hong"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local itemList={}--奖励容器
|
|
|
|
|
|
|
|
|
|
--每日副本服务器数据
|
|
|
|
|
local dailyChallengeData={}
|
|
|
|
|
local buyTime=0--购买次数
|
|
|
|
|
local freeTime=0--免费次数
|
|
|
|
|
|
|
|
|
|
--Tab
|
|
|
|
|
local TabBox = require("Modules/Common/TabBox")
|
|
|
|
|
local _TabData={ [1] = { default = "r_richang_anniu_jinbi_01", select = "r_richang_anniu_jinbi",lock = "r_richang_anniu_jinbi", name = "金币副本",type=FUNCTION_OPEN_TYPE.DAILYCHALLENGE_COIN },
|
|
|
|
|
[2] = { default = "r_richang_anniu_jingyan_01", select = "r_richang_anniu_jingyan",lock = "r_richang_anniu_jingyan", name = "经验副本",type=FUNCTION_OPEN_TYPE.DAILYCHALLENGE_EXP },
|
|
|
|
|
[3] = { default = "r_richang_anniu_lieyaoshi_01", select = "r_richang_anniu_lieyaoshi",lock = "r_richang_anniu_lieyaoshi", name = "猎妖师副本",type=FUNCTION_OPEN_TYPE.DAILYCHALLENGE_HERODEBRIS },
|
|
|
|
|
[4] = { default = "r_richang_anniu_fabao_01", select = "r_richang_anniu_fabao",lock = "r_richang_anniu_fabao", name = "法宝副本",type=FUNCTION_OPEN_TYPE.DAILYCHALLENGE_TALISMAN },
|
|
|
|
|
[5] = { default = "r_richang_anniu_hunyin_01", select = "r_richang_anniu_hunyin",lock = "r_richang_anniu_hunyin", name = "魂印副本",type=FUNCTION_OPEN_TYPE.DAILYCHALLENGE_SOULPRINT }
|
|
|
|
|
}
|
|
|
|
|
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
|
|
|
|
|
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1),
|
|
|
|
|
lock=Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:InitComponent()
|
|
|
|
|
this.panel=Util.GetGameObject(this.gameObject,"Panel")
|
|
|
|
|
this.titleBg=Util.GetGameObject(this.panel,"Bg/TitleBg"):GetComponent("Image")
|
|
|
|
|
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(992.4, 1205.6), 1, 1, Vector2.New(40, 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 DailyCarbonPanel:BindEvent()
|
|
|
|
|
--返回按钮
|
|
|
|
|
Util.AddClick(this.backBtn, function()
|
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
--帮助按钮
|
|
|
|
|
Util.AddClick(this.helpBtn, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.DailyCarbon,this.helpPosition.x,this.helpPosition.y)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:OnSortingOrderChange()
|
|
|
|
|
orginLayer = self.sortingOrder
|
2020-05-25 19:16:23 +08:00
|
|
|
|
for i, v in pairs(itemList) do
|
|
|
|
|
for j = 1, #itemList[i] do
|
|
|
|
|
itemList[i][j]:SetEffectLayer(orginLayer)
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:AddListener()
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh,this.FiveRefresh)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:RemoveListener()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh,this.FiveRefresh)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:OnOpen()
|
|
|
|
|
this.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:OnShow()
|
|
|
|
|
if carbonIndex==0 then carbonIndex=1 end
|
|
|
|
|
this.TabCtrl:SetTabAdapter(this.TabAdapter)
|
|
|
|
|
this.TabCtrl:SetTabIsLockCheck(this.TabIsLockCheck)
|
|
|
|
|
this.TabCtrl:SetChangeTabCallBack(this.RefreshShow)
|
|
|
|
|
this.TabCtrl:Init(this.tabBox, _TabData,carbonIndex)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
-- 音效
|
|
|
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:OnClose()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DailyCarbonPanel:OnDestroy()
|
2020-05-25 19:16:23 +08:00
|
|
|
|
itemList={}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.scrollView=nil
|
|
|
|
|
SubUIManager.Close(this.upView)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.FiveRefresh()
|
|
|
|
|
this.RefreshShow(1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新面板
|
|
|
|
|
function this.RefreshShow(i)
|
|
|
|
|
Log("刷新面板"..i)
|
|
|
|
|
carbonIndex = i
|
|
|
|
|
dailyChallengeData=CarbonManager.dailyChallengeInfo
|
|
|
|
|
for key, value in ipairs(dailyChallengeData) do
|
|
|
|
|
LogRed(value)
|
|
|
|
|
end
|
|
|
|
|
curData={}
|
|
|
|
|
curData=ConfigManager.GetAllConfigsDataByKey(ConfigName.DailyChallengeConfig,"Type",i)
|
|
|
|
|
|
|
|
|
|
this.titleBg.sprite=Util.LoadSprite(titleBg[i])
|
|
|
|
|
this.SetTimeTip()
|
|
|
|
|
this.SetScroll(i)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--设置滚动条
|
|
|
|
|
function this.SetScroll(i)
|
|
|
|
|
this.scrollView:SetData(curData,function(index,root)
|
|
|
|
|
this.SetData(root,curData[index])
|
|
|
|
|
end)
|
|
|
|
|
this.scrollView:SetIndex(1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--设置滚动条数据 root根节点 data本地表数据 sdata服务器数据
|
|
|
|
|
function this.SetData(root,data,sdata)
|
|
|
|
|
local type=0 --0为未开启 1为挑战 2为扫荡
|
|
|
|
|
local bgQuality=Util.GetGameObject(root,"BgQuality"):GetComponent("Image")
|
|
|
|
|
local title=Util.GetGameObject(root,"Title"):GetComponent("Image")
|
|
|
|
|
local reward=Util.GetGameObject(root,"Reward")
|
|
|
|
|
local tip=Util.GetGameObject(root,"Tip"):GetComponent("Text")
|
|
|
|
|
local goBtn=Util.GetGameObject(root,"GoBtn")
|
|
|
|
|
local goBtnImage=goBtn:GetComponent("Image")
|
|
|
|
|
local goBtnText=Util.GetGameObject(goBtn,"Text"):GetComponent("Text")
|
|
|
|
|
local goIcon=Util.GetGameObject(goBtn,"Icon")
|
|
|
|
|
local goIconNum=Util.GetGameObject(goBtn,"IconNum")
|
|
|
|
|
local goIconNumText=goIconNum:GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
local storeData=ConfigManager.GetConfigDataByDoubleKey(ConfigName.StoreConfig,"StoreId",7,"Limit",data.PrivilegeId[1])--商店表数据
|
|
|
|
|
title.sprite=Util.LoadSprite(qualityBg[data.Quality].s)
|
|
|
|
|
bgQuality.sprite=Util.LoadSprite(qualityBg[data.Quality].b)
|
|
|
|
|
ResetItemView(root,reward.transform,itemList,3,0.9,orginLayer,false,data.RewardView)
|
|
|
|
|
|
|
|
|
|
--解锁状态
|
|
|
|
|
local _lv=0 --等级
|
|
|
|
|
local _point=0 --关卡
|
|
|
|
|
local _power=0--表战力
|
|
|
|
|
if data.OpenRules[1]~=nil and data.OpenRules[1][1]==1 then
|
|
|
|
|
_lv= data.OpenRules[1][2]
|
|
|
|
|
end
|
|
|
|
|
if data.OpenRules[1]~=nil and data.OpenRules[1][1]==2 then
|
|
|
|
|
_point= data.OpenRules[1][2]
|
|
|
|
|
end
|
|
|
|
|
if data.OpenRules[2][1]==3 then
|
|
|
|
|
_power= data.OpenRules[2][2]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--显示挑战或扫荡道具消耗
|
|
|
|
|
goIcon:SetActive(PlayerManager.maxForce >=_power and freeTime<=0)
|
|
|
|
|
goIconNum:SetActive( PlayerManager.maxForce >=_power and freeTime<=0)
|
|
|
|
|
|
|
|
|
|
if freeTime<=0 then
|
|
|
|
|
goIconNumText.text=storeData.Cost[2][4]
|
|
|
|
|
end
|
|
|
|
|
--表现显示
|
|
|
|
|
Util.SetGray(goBtn,PlayerManager.maxForce <_power)
|
|
|
|
|
if PlayerManager.maxForce >=_power then
|
|
|
|
|
type=1
|
|
|
|
|
goBtnText.text="挑战"
|
|
|
|
|
goBtnImage.sprite=Util.LoadSprite("s_slbz_1anniuhuangse")
|
|
|
|
|
tip.text=string.format("战力:%s",_power)
|
|
|
|
|
if dailyChallengeData~=nil then
|
|
|
|
|
for i = 1, #dailyChallengeData do
|
|
|
|
|
LogBlue(data.Id.." "..dailyChallengeData[i])
|
|
|
|
|
if data.Id==dailyChallengeData[i] then
|
|
|
|
|
type=2
|
|
|
|
|
goBtnText.text="扫荡"
|
|
|
|
|
goBtnImage.sprite=Util.LoadSprite("s_slbz_1anniuhuise")
|
|
|
|
|
tip.text="已通过"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
type=0
|
|
|
|
|
tip.text=string.format("<color=red>战力:%s</color>",_power)
|
|
|
|
|
goBtnText.text="未开启"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--点击事件
|
|
|
|
|
Util.AddOnceClick(goBtn,function()
|
|
|
|
|
if PlayerManager.level<_lv then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("玩家等级不足%s级!",_lv))
|
|
|
|
|
return
|
|
|
|
|
elseif PlayerManager.curMapId ~= 0 and FightPointPassManager.IsFightPointPass(PlayerManager.curMapId)==false then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("未通关%s",mainLevelConfig[_point].Name))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测剩余次数
|
|
|
|
|
if buyTime<=0 and freeTime<=0 then
|
|
|
|
|
PopupTipPanel.ShowTip("今日剩余次数不足!")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测妖晶数量
|
|
|
|
|
local itemId=storeData.Cost[1][1] --消耗道具
|
|
|
|
|
if BagManager.GetItemCountById(itemId)<storeData.Cost[2][4] and freeTime<=0 then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("%s不足!",itemConfig[itemId].Name))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if PlayerManager.maxForce <_power then
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--当免费次数不足 不管是挑战还是扫荡 购买次数
|
|
|
|
|
if freeTime<=0 then
|
|
|
|
|
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,storeData.Id,1,function() end)
|
|
|
|
|
end
|
|
|
|
|
NetManager.DailyChallengeRequest(data.Id,type,function(msg)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local fightData = BattleManager.GetBattleServerData(msg)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if type==1 then --挑战
|
2020-06-03 19:09:01 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.DAILY_CHALLENGE , function(result)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if result.result ==0 then
|
|
|
|
|
|
|
|
|
|
elseif result.result==1 then
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(data.PrivilegeId[2],1)
|
|
|
|
|
CarbonManager.AddDailyChallengeInfo(data.Id)
|
|
|
|
|
this.RefreshShow(carbonIndex)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
elseif type==2 then --扫荡
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(data.PrivilegeId[2],1)
|
|
|
|
|
this.RefreshShow(carbonIndex)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--设置剩余次数
|
|
|
|
|
function this.SetTimeTip()
|
|
|
|
|
local storeData=ConfigManager.GetConfigDataByDoubleKey(ConfigName.StoreConfig,"StoreId",7,"Limit",curData[1].PrivilegeId[1])--商店表数据
|
|
|
|
|
local buyTimeId= curData[1].PrivilegeId[1]
|
|
|
|
|
local freeTimeId=curData[1].PrivilegeId[2]
|
|
|
|
|
buyTime= ShopManager.GetShopItemRemainBuyTimes(SHOP_TYPE.FUNCTION_SHOP,storeData.Id) --购买次数
|
|
|
|
|
freeTime=PrivilegeManager.GetPrivilegeRemainValue(freeTimeId) --免费次数
|
|
|
|
|
local str=""
|
|
|
|
|
if freeTime>0 then
|
|
|
|
|
str=string.format("今日剩余次数:%s",tostring(freeTime))
|
|
|
|
|
else
|
|
|
|
|
str=string.format("今日剩余购买次数:%s",tostring(buyTime))
|
|
|
|
|
end
|
|
|
|
|
this.timeTip.text=str
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- tab节点显示自定义
|
|
|
|
|
function this.TabAdapter(tab, index, status)
|
|
|
|
|
-- local tabLab = Util.GetGameObject(tab, "Text")
|
|
|
|
|
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 = Util.LoadSprite(_TabData[index][status])
|
|
|
|
|
-- tabLab:GetComponent("Text").text = _TabData[index].name
|
|
|
|
|
-- tabLab:GetComponent("Text").color = _TabFontColor[status]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.TabIsLockCheck(index)
|
|
|
|
|
if not ActTimeCtrlManager.SingleFuncState(_TabData[index].type) then
|
|
|
|
|
return true,ActTimeCtrlManager.SystemOpenTip(_TabData[index].type)
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return DailyCarbonPanel
|