抽卡优化

dev_chengFeng
jiaoyangna 2021-07-08 18:40:43 +08:00
parent 75b93cdff1
commit 30ab410f00
16 changed files with 76397 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 84cd6d006419056468c700880a4c8078
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 47e428b42c505dd47b6b783aaf8e87a3
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: d7895f7da1be37d4f95831b6747cc240
timeCreated: 1545973056
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2080,7 +2080,16 @@ CONGRATULATION_TYPE = {
Practice = 1,--破境成功
}
--抽卡类型
--抽卡类型(跟表对应)
TableRecruitType = {
Putong = 5,
Youqing = 4,
Shenjiang = 1,
Siyuanzhen = 2,
xianyuan = 6,
}
--抽卡类型(读取数据 ,自己定义的)
RecruitType = {
WaterTen = 1, --水属性十抽
WaterSingle = 2, --水属性单抽
@ -2604,6 +2613,13 @@ PropertyType = {
[4] = "道系",
}
PropertyTypeImageBySiYuan = {
[1] = {image3 = "y_yuansu_ren01_zh",Image1 = "y_yuansu_ren",property = ""},
[2] = {image3 = "y_yuansu_fou01_zh",Image1 = "y_yuansu_fou",property = ""},
[3] = {image3 = "y_yuansu_yao01_zh",Image1 = "y_yuansu_yao",property = ""},
[4] = {image3 = "y_yuansu_dao01_zh",Image1 = "y_yuansu_dao",property = ""},
}
NumToChinese = {
[1] = "",
[2] = "",

View File

@ -392,6 +392,7 @@ UIName = {
SurpriseBoxPanel = 401,--惊喜礼盒
JourneyWithWindPanel = 402,--缥缈之旅
TeHuiShenZhuangPanel = 403, --特惠神装
RecruitMainPanel = 405,
}
SubUIConfig = {
@ -458,4 +459,6 @@ SubUIConfig = {
[27] = {name = "TimeLimitUpHero",assetName = "TimeLimitUpHero",script = "Modules/DynamicActivity/TimeLimitUpHero"}, --限时英雄up界面
[30] = {name = "UpStarPre",assetName = "UpStarPre",script = "Modules/UpStar/UpStarPre"}, --限时英雄up界面
[29] = {name = "page15",assetName = "page15",script = "Modules/DynamicActivity/ShengXingYouLi"},--升星有礼
[31] = {name = "RecruitPanelNew",assetName = "RecruitPanelNew",script = "Modules/Recruit/RecruitPanelNew"},--
[32] = {name = "ElementDrawCardPanelNew",assetName = "ElementDrawCardPanelNew",script = "Modules/Recruit/ElementDrawCardPanelNew"},--升星有礼
}

View File

@ -407,17 +407,17 @@ function this:BindEvent()
Util.AddClick(this.btnRecruit, function()
--UIManager.OpenPanel(UIName.RecruitPanel)
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.RECURITY, function ()
UIManager.OpenPanel(UIName.RecruitPanel)
UIManager.OpenPanel(UIName.RecruitMainPanel)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.RECURITY)
end)
--元素招募
Util.AddClick(this.btnElementDrawCard, function()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.ELEMENT_RECURITY, function ()
UIManager.OpenPanel(UIName.ElementDrawCardPanel)
UIManager.OpenPanel(UIName.RecruitMainPanel,TableRecruitType.Siyuanzhen)
end)
this.ScenceBtnClick(FUNCTION_OPEN_TYPE.ELEMENT_RECURITY)
end)
end)
--秘盒
Util.AddClick(this.btnSecretBox, function()
this.FunctionClickEvent(FUNCTION_OPEN_TYPE.SECRETBOX, function ()

View File

@ -0,0 +1,159 @@
ElementDrawCardPanelNew = {}
function ElementDrawCardPanelNew:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = ElementDrawCardPanelNew })
return b
end
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
function ElementDrawCardPanelNew:InitComponent()
self.spLoader = SpriteLoader.New()
self.getCardPanel = Util.GetGameObject(self.transform, "getCardPanel")
self.buyOneBtn = Util.GetGameObject(self.getCardPanel,"content2/btn1")
self.titleImageText = Util.GetGameObject(self.getCardPanel,"content1/titleImage/Text"):GetComponent("Text")
self.Image1 = Util.GetGameObject(self.getCardPanel,"content1/Image/Image1"):GetComponent("Image")
self.Image2Text = Util.GetGameObject(self.getCardPanel,"content1/Image/Image2/Text"):GetComponent("Text")
self.Image3 = Util.GetGameObject(self.getCardPanel,"content1/Image/Image3"):GetComponent("Image")
self.detailText1=Util.GetGameObject(self.getCardPanel,"content1/Image2/detailText1"):GetComponent("Text")
self.detailText2=Util.GetGameObject(self.getCardPanel,"content1/Image2/detailText2"):GetComponent("Text")
self.btnBack=Util.GetGameObject(self.getCardPanel,"btnBack")
self.itemPre = Util.GetGameObject(self.transform, "enterCardPanel/itemPre")
self.itemPos = {}
for i = 1,4 do
self.itemPos[i] = {}
self.itemPos[i].pos = Util.GetGameObject(self.transform, "enterCardPanel/itemPos"..i)
self.itemPos[i].go = newObjToParent(self.itemPre,self.itemPos[i].pos)
self.itemPos[i].goImage = self.itemPos[i].go:GetComponent("Image")
self.itemPos[i].goImage.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[i].Image1)
self.itemPos[i].PropertyImage = Util.GetGameObject(self.itemPos[i].go, "Image"):GetComponent("Image")
self.itemPos[i].PropertyImage.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[i].image3)
end
self.effect=Util.GetGameObject(self.transform, "effect")
self.bgImage=Util.GetGameObject(self.transform, "bgImage")
self.previewBtn = Util.GetGameObject(self.transform, "enterCardPanel/previewBtn")
self.shopBtn = Util.GetGameObject(self.transform, "enterCardPanel/shopBtn")
self.helpBtn = Util.GetGameObject(self.transform, "enterCardPanel/helpBtn")
self.exchangeBtn = Util.GetGameObject(self.transform, "enterCardPanel/exchangeBtn")
screenAdapte(self.bgImage)
end
--绑定事件(用于子类重写)
function ElementDrawCardPanelNew:BindEvent()
Util.AddClick(self.buyOneBtn, function ()
local singleConfig = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.LotterySetting,"LotteryType",TableRecruitType.Siyuanzhen,"PropertyType",self.index,"PerCount",1)
local costnum = singleConfig.CostItem[1][2]
local costId = singleConfig.CostItem[1][1]
LogGreen("costnum:"..costnum.." costId:"..costId)
if BagManager.GetItemCountById(costId) < costnum then
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[costId].Name)..Language[10486])
return
end
RecruitManager.RecruitRequest(singleConfig.Id, function(msg)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,msg.drop,singleConfig.Id)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
end)
end)
Util.AddClick(self.btnBack, function ()
self.getCardPanel:SetActive(false)
self.effect:SetActive(false)
SoundManager.PlayMusic(SoundConfig.BGM_Main)
RecruitManager.recruitSubIndex = 0
self.parent.tabbox.gameObject:SetActive(true)
self.parent.btnBack.gameObject:SetActive(true)
end)
Util.AddClick(self.previewBtn, function()
UIManager.OpenPanel(UIName.HeroPreviewPanel,false)
end)
Util.AddClick(self.shopBtn, function()
JumpManager.GoJump(20008)
end)
Util.AddClick(self.helpBtn, function()
local pos = self.helpBtn.transform.localPosition
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.ElementDraw, pos.x, pos.y)
end)
Util.AddClick(self.exchangeBtn, function()
UIManager.OpenPanel(UIName.CompoundHeroPanel,2)
end)
for i = 1, #self.itemPos do
Util.AddClick(self.itemPos[i].go, function()
self.index = i
self:BtnAction(i)
end)
end
end
function ElementDrawCardPanelNew:BtnAction(index)
if not index or index < 1 or index > 4 then
return
end
self.parent.btnBack.gameObject:SetActive(false)
self.parent.tabbox.gameObject:SetActive(false)
self.getCardPanel.gameObject:SetActive(true)
self.effect:SetActive(true)
self.Image2Text.text = string.format("%s神将碎片",PropertyType[index])
SetTextVerTial(self.Image2Text,Vector3.New(134.88,-5.9,0),"MiddleLeft")
self.Image3.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[index].image3)
self.Image1.sprite = self.spLoader:LoadSprite(PropertyTypeImageBySiYuan[index].Image1)
self.titleImageText.text = string.format("阵营召唤·%s",PropertyTypeImageBySiYuan[index].property)
self.detailText1.text = string.format("必得<color=#EDB54B>%s</color>神将碎片",PropertyType[index])
end
--添加事件监听(用于子类重写)
function ElementDrawCardPanelNew:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.SecretBox.OnOpenOneReward, self.OpenOneRewardPanel)
Game.GlobalEvent:AddEvent(GameEvent.SecretBox.OnOpenTenReward, self.OpenTenRewardPanel)
end
--移除事件监听(用于子类重写)
function ElementDrawCardPanelNew:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.SecretBox.OnOpenOneReward,self.OpenOneRewardPanel)
Game.GlobalEvent:RemoveEvent(GameEvent.SecretBox.OnOpenTenReward,self.OpenTenRewardPanel)
end
function ElementDrawCardPanelNew.OpenOneRewardPanel(drop)
UIManager.OpenPanel(UIName.SecretBoxBuyOnePanel,drop)
end
function ElementDrawCardPanelNew.OpenTenRewardPanel(drop)
UIManager.OpenPanel(UIName.SecretBoxBuyTenPanel,drop)
end
function ElementDrawCardPanelNew:OnSortingOrderChange(sortingOrder)
self.sortingOrder = sortingOrder
Util.SetParticleSortLayer(self.gameObject, self.sortingOrder + 1)
end
--界面打开时调用(用于子类重写)
function ElementDrawCardPanelNew:OnOpen(_Config,_index, parent)
self.config = _Config
self.parent = parent
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ElementDrawCardPanelNew:OnShow(orginLayer)
self.sortingOrder = orginLayer
self.gameObject:SetActive(true)
self.effect:SetActive(false)
self.index = RecruitManager.recruitSubIndex
self:BtnAction(self.index)
end
--界面关闭时调用(用于子类重写)
function ElementDrawCardPanelNew:OnClose()
self.gameObject:SetActive(false)
end
--界面销毁时调用(用于子类重写)
function ElementDrawCardPanelNew:OnDestroy()
self.spLoader:Destroy()
end
return ElementDrawCardPanelNew

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d3e32bb46ce30ae4e87ffdcc064382e9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,261 @@
require("Base/BasePanel")
local RecruitMainPanel = Inherit(BasePanel)
local this = RecruitMainPanel
local GlobalActConfig = ConfigManager.GetConfig(ConfigName.GlobalActivity)
local _CurPageIndex = 0
local orginLayer
local redPointTypeList = {}
local subViewList = {}
local isEnter = 0
local lastIndex = 0
--初始化组件(用于子类重写)
function RecruitMainPanel:InitComponent()
this.spLoader = SpriteLoader.New()
orginLayer = 0
this.mask = Util.GetGameObject(self.gameObject,"mask")
this.mask:SetActive(false)
this.tabbox = Util.GetGameObject(self.gameObject, "bg/tabbox")
this.btnBack = Util.GetGameObject(self.gameObject, "bg/btnBack")
this.content = Util.GetGameObject(self.gameObject, "bg/pageContent")
this.item = Util.GetGameObject(this.tabbox, "tab")
this.grid = Util.GetGameObject(this.tabbox, "box")
this.leftBtn = Util.GetGameObject(this.tabbox, "leftAction")
this.rightBtn = Util.GetGameObject(this.tabbox, "rightAction")
this.select = Util.GetGameObject(this.tabbox, "select")
this.select.gameObject:SetActive(false)
this.upView = SubUIManager.Open(SubUIConfig.UpView,self.gameObject.transform)
this.itemList = {}
this.moveWidth = this.grid:GetComponent("RectTransform").rect.width
this.itemWidth = this.item:GetComponent("RectTransform").rect.width
this.count = 3
local off = (this.moveWidth - this.count * this.itemWidth)/(this.count - 1)
for i = 1,this.count do
if not this.itemList[i] then
this.itemList[i] = {}
this.itemList[i].go = newObjToParent(this.item,this.grid)
local tran = this.itemList[i].go:GetComponent("RectTransform")
local vec = tran.anchoredPosition
vec.x = off * (i - 1) + i * this.itemWidth
vec.y = 0
tran.anchoredPosition = vec
this.itemList[i].pos = tran.anchoredPosition
this.itemList[i].off = 0
this.itemList[i].img = Util.GetGameObject(this.itemList[i].go, "img"):GetComponent("Image")
this.itemList[i].redpot = Util.GetGameObject(this.itemList[i].go, "redpot")
end
end
self.lastPage,self.curPage,self.nextPage = 0,0,0
this.trigger = Util.GetEventTriggerListener(self.gameObject) --触摸事件
this.trigger.onBeginDrag = this.trigger.onBeginDrag + this.OnBeginDrag
this.trigger.onDrag = this.trigger.onDrag + this.OnDrag
this.trigger.onEndDrag = this.trigger.onEndDrag + this.OnEndDrag
this.moveTween = this.grid:GetComponent(typeof(UITweenSpring))
if not this.moveTween then
this.moveTween = this.grid:AddComponent(typeof(UITweenSpring))
end
this.moveTween.enabled = false
this.moveTween.OnUpdate = this.SetPos
this.moveTween.OnMoveEnd = this.MoveTo
this.moveTween.MomentumAmount = 0.5
this.moveTween.Strength = 1
end
---设置位置
function this.SetPos(v2)
if isEnter == 1 then
if v2.x > 2 then
isEnter = 0
this:RightAction()
elseif v2.x < -2 then
isEnter = 0
this:LeftAction()
end
end
end
---手指拖动结束 ui归位
function this.MoveTo()
-- local d = 1
-- local targetIdx
-- for i=1, this.count do
-- local item = this.ItemList[i]
-- local dd = math.abs(this.ItemList[i].off)
-- if dd < d then
-- targetIdx = i
-- d = dd
-- end
-- end
-- curIndex=targetIdx
-- this.MoveTween(-this.ItemList[targetIdx].off)
-- this.SetInfo(targetIdx)
end
function this.OnBeginDrag(Pointgo, data)
isEnter = 1
this.moveTween.enabled = true
this.moveTween.Momentum = Vector3.zero
this.moveTween.IsUseCallBack = false
end
function this.OnDrag(Pointgo, data)
this.moveTween:LerpMomentum(data.delta)
this.SetPos(data.delta)
end
function this.OnEndDrag(Pointgo, data)
--this.SetPos(data.delta)
isEnter = 0
this.moveTween.IsUseCallBack = true
end
--绑定事件(用于子类重写)
function RecruitMainPanel:BindEvent()
-- 关闭界面打开主城
Util.AddClick(this.btnBack, function()
this:ClosePanel()
end)
Util.AddClick(this.leftBtn, function()
this:LeftAction()
end)
Util.AddClick(this.rightBtn, function()
this:RightAction()
end)
end
--添加事件监听(用于子类重写)
function RecruitMainPanel:AddListener()
end
--移除事件监听(用于子类重写)
function RecruitMainPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function RecruitMainPanel:OnOpen(_index)
if not _index then
self.CurRecruitId = RecruitManager.CurRecruitId
else
self.CurRecruitId = _index
RecruitManager.CurRecruitId = _index
end
end
-- 打开,重新打开时回调
function RecruitMainPanel:OnShow()
orginLayer = self.sortingOrder
self.dicData = RecruitManager.GetRecruitData()
for i = 1,#self.dicData do
if self.dicData[i].ShopData[1][1] == self.CurRecruitId then
self.curPage = i
break
end
end
self.lastPage = self.curPage - 1 > 0 and self.curPage - 1 or #self.dicData
self.nextPage = self.curPage + 1 > #self.dicData and 1 or self.curPage + 1
lastIndex = self.curPage
this:RefreshTabData()
end
function this:RefreshTabData()
local curIndex = 0
for i = 1,#this.itemList do
if i == 1 then
curIndex = self.lastPage
elseif i == 2 then
curIndex = self.curPage
else
curIndex = self.nextPage
end
this.itemList[i].img.sprite = this.spLoader:LoadSprite(self.dicData[curIndex].Icon[1])
this.itemList[i].redpot.gameObject:SetActive(false)
end
this.select.gameObject:SetActive(true)
this:PageOnChange()
end
function this:PageOnChange()
RecruitManager.CurRecruitId = self.CurRecruitId
if subViewList[lastIndex] and subViewList[lastIndex].config and subViewList[lastIndex].sub then
subViewList[lastIndex].sub:OnClose()
end
if subViewList[self.curPage] and subViewList[self.curPage].config and subViewList[self.curPage].sub then
subViewList[self.curPage].sub:OnShow(orginLayer)
else
subViewList[self.curPage] = {}
if self.dicData[self.curPage].UIName then
subViewList[self.curPage].config = SubUIConfig[self.dicData[self.curPage].UIName[1]]
subViewList[self.curPage].sub = SubUIManager.Open(subViewList[self.curPage].config,this.content.transform,self.dicData[self.curPage],self.curPage,this)
subViewList[self.curPage].sub:OnShow(orginLayer)
end
end
if self.dicData[self.curPage].UpView and #self.dicData[self.curPage].UpView > 0 then
this.upView:OnOpen({showType = self.dicData[self.curPage].UpView[1][1], panelType = self.dicData[self.curPage].UpView[2] })
this.upView.gameObject:SetActive(true)
else
this.upView.gameObject:SetActive(false)
end
end
function this:LeftAction()
lastIndex = self.curPage
this.select.gameObject:SetActive(false)
self.CurRecruitId = self.dicData[self.nextPage].ShopData[1][1]
self.lastPage = self.curPage
self.curPage = self.nextPage
self.nextPage = self.curPage + 1 > #self.dicData and 1 or self.curPage + 1
this:RefreshTabData()
end
function this:RightAction()
lastIndex = self.curPage
this.select.gameObject:SetActive(false)
self.CurRecruitId = self.dicData[self.lastPage].ShopData[1][1]
self.nextPage = self.curPage
self.curPage = self.lastPage
self.lastPage = self.curPage - 1 > 0 and self.curPage - 1 or #self.dicData
this:RefreshTabData()
end
function this:OnSortingOrderChange()
orginLayer = self.sortingOrder
for k,v in pairs(subViewList) do
v.sub:OnSortingOrderChange(self.sortingOrder)
end
end
--界面关闭时调用(用于子类重写)
function RecruitMainPanel:OnClose()
--清除红点
for k,v in pairs(redPointTypeList) do
ClearRedPointObject(k,v)
end
redPointTypeList = {}
end
--界面销毁时调用(用于子类重写)
function RecruitMainPanel:OnDestroy()
--清除红点
for k,v in pairs(redPointTypeList) do
ClearRedPointObject(k,v)
end
redPointTypeList = {}
--关闭弹窗界面
for k,v in pairs(subViewList) do
--UIManager.ClosePanel(k)
v.sub:OnDestroy()
this.spLoader:Destroy()
SubUIManager.Close(v.sub)
end
subViewList = {}
self.dicData = {}
SubUIManager.Close(this.upView)
this.upView = nil
self.dicData = {}
end
return this

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 939672a8188afb54699f7515bf95d075
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,6 +7,9 @@ local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local dailyRewardConfig = ConfigManager.GetConfig(ConfigName.DialRewardConfig)
this.CurRecruitId = 1
this.recruitSubIndex = 0
--活动抽卡类型(动态的数据)
local drawtType={
FindFairySingle=0,
@ -507,6 +510,7 @@ function this.ChangeHero(type,_heroTid,func)
end
end
NetManager.ChoiceWishHeroRequest(this.WishCardData,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.Recruit.OnRecruitRefreshData)
if func then
func()
end
@ -535,4 +539,27 @@ function this.CheckIndex()
return num2[1]
end
function this.GetRecruitData()
local dicData = {}
local allConfigs = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityGroups, "PageType",1)
for i = 1,#allConfigs do
if allConfigs[i].ActiveType and allConfigs[i].ActiveType > 0 then
elseif allConfigs[i].FunType and allConfigs[i].FunType > 0 then
if allConfigs[i].IfBack == 1 then
if ActTimeCtrlManager.SingleFuncState(allConfigs[i].FunType) then
table.insert(dicData,allConfigs[i])
end
else
if ActTimeCtrlManager.IsQualifiled(allConfigs[i].FunType) then
table.insert(dicData,allConfigs[i])
end
end
end
end
table.sort(dicData,function(a,b)
return a.Sort < b.Sort
end)
return dicData
end
return this

View File

@ -0,0 +1,352 @@
RecruitPanelNew = {}
function RecruitPanelNew:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = RecruitPanelNew })
return b
end
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
local AllActSetConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
local privilegeConfig=ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
function RecruitPanelNew:InitComponent()
self.spLoader = SpriteLoader.New()
self.panel = Util.GetGameObject(self.gameObject,"Panel")
self.title=Util.GetGameObject(self.panel,"title"):GetComponent("Image")
self.root=Util.GetGameObject(self.panel,"root")
self.rewardBox = Util.GetGameObject(self.panel, "rewardBox")
self.boxIcon = Util.GetGameObject(self.panel, "boxIcon")
self.slider = Util.GetGameObject(self.rewardBox,"Bg/Slider"):GetComponent("Image")
self.sliderText = Util.GetGameObject(self.rewardBox, "progress/Text"):GetComponent("Text")
self.boxBtn=Util.GetGameObject(self.rewardBox,"Btn")
self.UI_effect_RecruitPanel_box_normal = Util.GetGameObject(self.rewardBox,"UI_effect_RecruitPanel_box_normal")
effectAdapte(Util.GetGameObject(self.UI_effect_RecruitPanel_box_normal, "quan01"))
self.UI_effect_RecruitPanel_box_open = Util.GetGameObject(self.rewardBox,"UI_effect_RecruitPanel_box_open")
effectAdapte(Util.GetGameObject(self.UI_effect_RecruitPanel_box_open, "quan01"))
effectAdapte(Util.GetGameObject(self.UI_effect_RecruitPanel_box_open, "quan02"))
self.UI_effect_RecruitPanel_particle = Util.GetGameObject(self.gameObject,"UI_effect_RecruitPanel_particle")
self.previewBtn = Util.GetGameObject(self.panel, "PreviewBtn")
self.helpBtn = Util.GetGameObject(self.panel, "helpBtn")
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
self.wish = Util.GetGameObject(self.panel,"wishBtn")
self.wishNoOpen = Util.GetGameObject(self.wish,"noOpen")
self.wishBtn = Util.GetGameObject(self.wishNoOpen,"Img")
self.wishTextImg = Util.GetGameObject(self.wishNoOpen,"ImgText")
self.wishText = Util.GetGameObject(self.wishTextImg,"Text"):GetComponent("Text")
self.wishTipIma = Util.GetGameObject(self.wishNoOpen,"tip")
self.wishTip = Util.GetGameObject(self.wishNoOpen,"tip/text"):GetComponent("Text")
self.wishOpen = Util.GetGameObject(self.wish,"upHeroGrid")
self.wishPre = Util.GetGameObject(self.wish,"upHeroPre")
self.tip = Util.GetGameObject(self.panel, "tip/text"):GetComponent("Text")
self.tenTip = Util.GetGameObject(self.panel, "TenTip")
self.tenTipText = Util.GetGameObject(self.panel, "TenTip/Text"):GetComponent("Text")
self.upper = Util.GetGameObject(self.panel,"Upper/Num"):GetComponent("Text")--"今日召唤上限:"
if not self.upHeroPreList then
self.upHeroPreList = {}
end
for i = 1,3 do
self.upHeroPreList[i] = {}
self.upHeroPreList[i].go = Util.GetGameObject(self.wishOpen,"upHeroPre"..i)
self.upHeroPreList[i].pos = Util.GetGameObject(self.upHeroPreList[i].go,"di")
self.upHeroPreList[i].item = SubUIManager.Open(SubUIConfig.ItemView,self.upHeroPreList[i].pos.transform)
self.upHeroPreList[i].item.transform:SetSiblingIndex(1)
self.upHeroPreList[i].item.transform:GetComponent("RectTransform").anchoredPosition = Vector3.New(32,-25.5,0)
self.upHeroPreList[i].choosed = Util.GetGameObject(self.upHeroPreList[i].go,"state")
end
self.btns = {}
for i = 1,2 do
self.btns[i] = {}
self.btns[i].btn = Util.GetGameObject(self.gameObject,"btngroup/btn"..i)
self.btns[i].red = Util.GetGameObject(self.btns[i].btn.gameObject,"redPoint")
self.btns[i].info = Util.GetGameObject(self.btns[i].btn.gameObject,"layout/Text"):GetComponent("Text")
self.btns[i].icon = Util.GetGameObject(self.btns[i].btn.gameObject,"layout/icon"):GetComponent("Image")
self.btns[i].num = Util.GetGameObject(self.btns[i].btn.gameObject,"layout/num"):GetComponent("Text")
self.btns[i].time = Util.GetGameObject(self.btns[i].btn.gameObject,"time"):GetComponent("Text")
end
end
function RecruitPanelNew:BindEvent()
--帮助按钮
Util.AddClick(self.helpBtn, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.WishCard,self.helpPosition.x,self.helpPosition.y)
end)
--宝箱按钮
Util.AddClick(self.boxBtn,function()
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitBox)
self.boxIcon:GetComponent("Animator").enabled = false
self.UI_effect_RecruitPanel_box_normal:SetActive(true)
end)
--奖池预览按钮
Util.AddClick(self.previewBtn, function()
UIManager.OpenPanel(UIName.HeroPreviewPanel,true)
end)
--心愿抽卡界面
Util.AddClick(self.wish, function()
local data = tonumber(specialConfig[119].Value)
if RecruitManager.drawTimes[1] then
if RecruitManager.drawTimes[1] >= data then
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.WishDraw)
else
PopupTipPanel.ShowTip(string.format("%s次神将召唤后开启心愿抽卡",data - RecruitManager.drawTimes[1]))
end
else
PopupTipPanel.ShowTip(string.format("%s次神将召唤后开启心愿抽卡",data))
end
end)
end
function RecruitPanelNew:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Recruit.OnRecruitRefreshData, self.UpdataPanel,self)
end
function RecruitPanelNew:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Recruit.OnRecruitRefreshData, self.UpdataPanel,self)
end
function RecruitPanelNew:OnSortingOrderChange(sortingOrder)
self.sortingOrder = sortingOrder
Util.SetParticleSortLayer(self.UI_effect_RecruitPanel_box_normal, self.sortingOrder + 1)
Util.SetParticleSortLayer(self.UI_effect_RecruitPanel_box_open, self.sortingOrder + 1)
Util.SetParticleSortLayer(self.UI_effect_RecruitPanel_particle, self.sortingOrder + 1)
end
--界面打开时调用(用于子类重写)
function RecruitPanelNew:OnOpen(_Config,_index, parent)
self.config = _Config
self.parent = parent
end
function RecruitPanelNew:OnShow(sortingOrder)
self.sortingOrder = sortingOrder
self:OnSortingOrderChange(sortingOrder)
self.gameObject:SetActive(true)
self.singleConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"LotteryType",self.config.ShopData[1][1],"PerCount",1)
self.tenConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.LotterySetting,"LotteryType",self.config.ShopData[1][1],"PerCount",10)
self.XianZhaoConfig = ConfigManager.GetConfigDataByKey(ConfigName.LotterySetting,"LotteryType",TableRecruitType.xianyuan)
self:UpdataPanel()
SoundManager.PlayMusic(SoundConfig.BGM_Recruit)
if self.liveNode then
poolManager:UnLoadLive(self.liveNode.name, self.liveNode)
end
if self.config.ShopData[2][1] == 1 then
local name = GetResourcePath(self.config.ShopData[2][2])
self.liveNode = poolManager:LoadLive(name, self.root.transform, Vector3.one *0.45, Vector3.New(253,-586,0))
self.liveNode.name = name
end
end
function RecruitPanelNew:UpdataPanel()
self.title.sprite = self.spLoader:LoadSprite(self.config.Icon[2])
self.tip.text = self.config.TitleText
self:UpdataWishPanel()
self:UpdataBoxReward()
self.upper.text=PrivilegeManager.GetPrivilegeUsedTimes(self.singleConfig.MaxTimes).."/"..privilegeConfig[self.singleConfig.MaxTimes].Condition[1][2]--特权上限
self:UpdatePanelData()
self:TimeCountDown()
end
function RecruitPanelNew:UpdataWishPanel()
if self.config.ShopData[1][1] ~= TableRecruitType.Shenjiang then
self.wish.gameObject:SetActive(false)
self.tenTip.gameObject:SetActive(false)
return
end
self.wish = Util.GetGameObject(self.panel,"wishBtn")
self.wishNoOpen = Util.GetGameObject(self.wish,"noOpen")
self.wishBtn = Util.GetGameObject(self.wishNoOpen,"Img")
self.wishTextImg = Util.GetGameObject(self.wishNoOpen,"ImgText")
self.wishTipIma = Util.GetGameObject(self.wishNoOpen,"tip")
self.wishTip = Util.GetGameObject(self.wishNoOpen,"tip/text"):GetComponent("Text")
self.wishOpen = Util.GetGameObject(self.wish,"upHeroGrid")
self.wishPre = Util.GetGameObject(self.wish,"upHeroPre")
self.wish.gameObject:SetActive(true)
--如果没有达到150抽按钮置灰
local data = tonumber(specialConfig[119].Value)
if RecruitManager.drawTimes[1] then
if RecruitManager.drawTimes[1] < data then
self.wishNoOpen.gameObject:SetActive(true)
self.wishOpen.gameObject:SetActive(false)
Util.SetGray(self.wishBtn,true)
self.wishText.text = string.format("%s/%s",RecruitManager.drawTimes[1],data)
self.wishTip.text = "开启心愿功能,将有更高概率获得心愿神将~"
else
self.wishNoOpen.gameObject:SetActive(false)
self.wishOpen.gameObject:SetActive(true)
NetManager.ChoiceWishHeroRequest(nil,function ()
LogGreen("#self.upHeroPreList:"..#self.upHeroPreList)
for i = 1,3 do
local data = RecruitManager.WishCardData[i]
local id = data.heroTid
if id > 0 then
self.upHeroPreList[i].item.gameObject:SetActive(true)
self.upHeroPreList[i].item:OnOpen(false, {id,0}, 0.7, false, false, false, self.sortingOrder)
self.upHeroPreList[i].choosed:SetActive(data.status == 1)
else
self.upHeroPreList[i].item.gameObject:SetActive(false)
self.upHeroPreList[i].choosed.gameObject:SetActive(false)
end
end
end)
end
else
self.wishNoOpen.gameObject:SetActive(true)
self.wishOpen.gameObject:SetActive(false)
Util.SetGray(self.wishBtn,true)
self.wishText.text = string.format("%s/%s",0,data)
self.wishTip.text = "开启心愿功能,将有更高概率获得心愿神将~"
end
self.tenTip:SetActive(true)
if RecruitManager.isTenRecruit == 0 then
self.tenTipText.text = Language[11708]
else
self.tenTipText.text = string.format("剩余%s次必得五星神将",RecruitManager.GetRecruit3MustCount())
end
end
function RecruitPanelNew:UpdataBoxReward()
local num = BagManager.GetItemCountById(self.XianZhaoConfig.CostItem[1][1])
RecruitManager.isCanOpenBox = num >= self.XianZhaoConfig.CostItem[1][2]
self.slider.fillAmount = num/self.XianZhaoConfig.CostItem[1][2]
self.sliderText.text = string.format("%s/%s", num, self.XianZhaoConfig.CostItem[1][2])
self.boxIcon:GetComponent("Animator").enabled = RecruitManager.isCanOpenBox
self.UI_effect_RecruitPanel_box_normal:SetActive(not RecruitManager.isCanOpenBox)
self.UI_effect_RecruitPanel_box_open:SetActive(RecruitManager.isCanOpenBox)
end
function RecruitPanelNew:OnClose()
self.gameObject:SetActive(false)
if self.timer then
self.timer:Stop()
self.timer = nil
end
end
function RecruitPanelNew:OnDestroy()
self.spLoader:Destroy()
if self.timer then
self.timer:Stop()
self.timer = nil
end
for i = 1,3 do
if self.upHeroPreList[i] then
SubUIManager.Close(self.upHeroPreList[i].item)
end
end
self.upHeroPreList = {}
end
--刷新剩余次数
function RecruitPanelNew:UpdatePanelData()
local freeTime = 0
if self.singleConfig.FreeTimes and self.singleConfig.FreeTimes > 0 then
freeTime = PrivilegeManager.GetPrivilegeRemainValue(self.singleConfig.FreeTimes)
RecruitManager.freeUseTimeList[self.singleConfig.FreeTimes] = freeTime
end
--按钮赋值
for n, m in ipairs(self.btns) do
--存在免费次数 并且 免费>=1 并且是1按钮
local isFree = freeTime >= 1 and n == 1
m.red.gameObject:SetActive(isFree)
m.icon.gameObject:SetActive(not isFree)
m.num.gameObject:SetActive(not isFree)
local itemId=0
local itemNum=0
local type = 0
if n == 1 then
type = self.singleConfig.Id
m.info.text = "1次"
m.time.gameObject:SetActive(true)
else
m.time.gameObject:SetActive(false)
type = self.tenConfig.Id
m.info.text = "10次"
end
if self.config.ShopData[1][1] == TableRecruitType.Youqing then
m.time.gameObject:SetActive(false)
end
local d = {}
if (isFree) then
m.time.gameObject:SetActive(false)
m.info.text="免费召唤"
else
local d = RecruitManager.GetExpendData(type)
itemId=d[1]
itemNum=d[2]
m.icon.sprite=self.spLoader:LoadSprite(artResourcesConfig[itemConfig[itemId].ResourceID].Name)
m.num.text= tostring(itemNum)
end
Util.AddOnceClick(m.btn,function()
if not isFree then
if BagManager.GetItemCountById(itemId)<itemNum then
PopupTipPanel.ShowTip(itemConfig[itemId].Name.."数量不足!")
return
end
end
local state = PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..self.config.ShopData[3][2])
LogGreen("self.config.ShopData[3][2]:"..self.config.ShopData[3][2].." state:"..state)
local recrutId = n == 1 and self.singleConfig.Id or self.tenConfig.Id
local recrutNum = n == 1 and 1 or 10
if state==0 and itemId == 16 and not isFree then
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,recrutId,function()
self:Recruit(recrutNum,recrutId,n)
end)
else
self:Recruit(recrutNum,recrutId,n)
end
end)
end
end
function RecruitPanelNew:Recruit(recrutType,recrutId,bType)
if PrivilegeManager.GetPrivilegeUsedTimes(self.singleConfig.MaxTimes)+recrutType>privilegeConfig[self.singleConfig.MaxTimes].Condition[1][2] then
PopupTipPanel.ShowTip("无法超出每日召唤次数上限!")
return
end
RecruitManager.RecruitRequest(recrutId, function(msg)
PrivilegeManager.RefreshPrivilegeUsedTimes(self.singleConfig.MaxTimes,recrutType)--记录抽卡次数
if bType == 1 then
UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero[1],recrutId,bType,{self.config.ShopData[3][1],self.config.ShopData[3][2]})
else
UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero,recrutId,bType,{self.config.ShopData[3][1],self.config.ShopData[3][2]})
end
CheckRedPointStatus(self.config.RpType)
end,self.singleConfig.FreeTimes)
end
function RecruitPanelNew:TimeCountDown()
if self.timer then
self.timer:Stop()
self.timer = nil
end
local timeDown=CalculateSecondsNowTo_N_OClock(0)
self.btns[1].time.text = Language[10023]..TimeToHMS(timeDown)
self.timer = Timer.New(function()
if timeDown < 1 then
self.timer:Stop()
self.timer = nil
return
end
timeDown = timeDown - 1
self.btns[1].time.text = Language[10023]..TimeToHMS(timeDown)
end, 1, -1, true)
self.timer:Start()
end
return RecruitPanelNew

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ed017772db2f0e6468af2ad6a45f0d20
timeCreated: 1545976476
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: