173 lines
7.6 KiB
Lua
173 lines
7.6 KiB
Lua
require("Base/BasePanel")
|
||
TenRecruitPanel = Inherit(BasePanel)
|
||
local this = TenRecruitPanel
|
||
local cardList = {}
|
||
local orginLayer
|
||
local gameSetting=ConfigManager.GetConfig(ConfigName.GameSetting)
|
||
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
|
||
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
||
local privilegeConfig=ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
|
||
local type --抽卡类型
|
||
local recruitType={}--前端显示用 抽卡类型
|
||
local maxTimesId--特权id上限(今日召唤上限)
|
||
--初始化组件(用于子类重写)
|
||
function TenRecruitPanel:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
orginLayer = 0
|
||
this.sureBtn = Util.GetGameObject(self.transform, "sureBtn")
|
||
this.againBtn = Util.GetGameObject(self.transform, "againBtn")
|
||
this.againIcon=Util.GetGameObject(self.transform,"Tip/juan"):GetComponent("Image")
|
||
this.againNum=Util.GetGameObject(self.transform,"Tip/Text"):GetComponent("Text")
|
||
this.cardPre = Util.GetGameObject(self.transform, "card")
|
||
this.grid = Util.GetGameObject(self.transform, "scroll/grid")
|
||
self.effect = Util.GetGameObject(self.gameObject, "bg/effect")
|
||
|
||
this.tenTip = Util.GetGameObject(self.gameObject, "bg/TenTip")
|
||
this.tenTipText = Util.GetGameObject(this.tenTip,"Text"):GetComponent("Text")
|
||
|
||
for i = 1, 10 do
|
||
cardList[i] = SubUIManager.Open(SubUIConfig.RoleItemView, this.grid.transform)
|
||
end
|
||
-- 上部货币显示
|
||
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft})
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function TenRecruitPanel:BindEvent()
|
||
|
||
Util.AddClick(self.sureBtn, function()
|
||
-- UIManager.OpenPanel(UIName.RecruitPanel)
|
||
if PlayerManager.IsGetFiveStarHero then--and OperatingManager.IsShowFiveStarPatch then
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend, FacePanelType.GrowGift, 5)
|
||
PlayerManager.IsGetFiveStarHero = false
|
||
end
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(self.againBtn, function()
|
||
local d=RecruitManager.GetExpendData(type)
|
||
local MoneyTimes=lotterySetting[type].MoneyTimes
|
||
local needCostTime=PrivilegeManager.GetPrivilegeUsedTimes(MoneyTimes)+10
|
||
if d[1] == 16 and needCostTime>privilegeConfig[MoneyTimes].Condition[1][2] then
|
||
local lotterySettingConfig = ConfigManager.GetConfigData(ConfigName.LotterySetting,type)
|
||
local costLength=#lotterySettingConfig.CostItem
|
||
d=lotterySettingConfig.CostItem[costLength]
|
||
end
|
||
if BagManager.GetItemCountById(d[1])<d[2] then
|
||
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[d[1]].Name)..Language[10486])
|
||
return
|
||
end
|
||
if PrivilegeManager.GetPrivilegeUsedTimes(maxTimesId)+1>privilegeConfig[maxTimesId].Condition[1][2] then
|
||
PopupTipPanel.ShowTip(Language[10485])
|
||
return
|
||
end
|
||
if d[1] == 16 then
|
||
if lotterySetting[type].MoneyTimes and lotterySetting[type].MoneyTimes > 0 and PrivilegeManager.GetPrivilegeRemainValue(lotterySetting[type].MoneyTimes) < 10 then
|
||
PopupTipPanel.ShowTip(Language[11423])
|
||
return
|
||
end
|
||
end
|
||
local recruitTen = function()
|
||
RecruitManager.RecruitRequest(type, function(msg)
|
||
if d[1] == 16 and lotterySetting[type].MoneyTimes and lotterySetting[type].MoneyTimes > 0 then
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(lotterySetting[type].MoneyTimes,10)--记录妖晶限购抽卡次数
|
||
end
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(maxTimesId,10)--记录抽卡次数
|
||
UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero, type,2,recruitType)
|
||
end,maxTimesId)
|
||
end
|
||
|
||
local state = PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..recruitType[2])
|
||
if state==0 and d[1] == 16 then
|
||
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,type,recruitTen)
|
||
else
|
||
recruitTen()
|
||
end
|
||
end)
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function TenRecruitPanel:AddListener()
|
||
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function TenRecruitPanel:RemoveListener()
|
||
|
||
end
|
||
function TenRecruitPanel:OnSortingOrderChange()
|
||
Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
|
||
-- for i = 1, this.grid.transform.childCount do
|
||
-- Util.AddParticleSortLayer(this.grid.transform:GetChild(i-1).gameObject, self.sortingOrder - orginLayer)
|
||
-- end
|
||
|
||
for i = 1, 10 do
|
||
cardList[i]:SetEffectLayer(self.sortingOrder)
|
||
end
|
||
orginLayer = self.sortingOrder
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function TenRecruitPanel:OnOpen(...)
|
||
local data = { ... }
|
||
local _roleDatas = data[1]
|
||
type=data[2]
|
||
recruitType=data[3]
|
||
for i = 1, #_roleDatas do
|
||
cardList[i]:OnOpen(_roleDatas[i].id,true,false,-1,self.sortingOrder)
|
||
local heorConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig,_roleDatas[i].heroId)
|
||
-- LogBlue("heorConfig.Star:"..heorConfig.Star)
|
||
if heorConfig and heorConfig.Star >= 5 then
|
||
HeroManager.DetectionOpenFiveStarActivity(heorConfig.Star)
|
||
end
|
||
end
|
||
local d=nil
|
||
local config=ConfigManager.TryGetConfigDataByKey(ConfigName.WishActivityUp,"ActivityId",type)
|
||
if config then
|
||
local Setting= ConfigManager.GetConfigData(ConfigName.WishActivitySetting,1)
|
||
local num=PrivilegeManager.GetPrivilegeRemainValue(Setting.DiamondMaxTimes)
|
||
d=RecruitManager.GetExpendDataByCostItem(Setting.CostItemMul,2,num)
|
||
else
|
||
d=RecruitManager.GetExpendData(type)
|
||
local MoneyTimes=lotterySetting[type].MoneyTimes
|
||
local needCostTime=PrivilegeManager.GetPrivilegeUsedTimes(MoneyTimes)+10
|
||
if d[1] == 16 and needCostTime>privilegeConfig[MoneyTimes].Condition[1][2] then
|
||
local lotterySettingConfig = ConfigManager.GetConfigData(ConfigName.LotterySetting,type)
|
||
local costLength=#lotterySettingConfig.CostItem
|
||
d=lotterySettingConfig.CostItem[costLength]
|
||
end
|
||
end
|
||
|
||
this.againIcon.sprite=this.spLoader:LoadSprite(artResourcesConfig[itemConfig[d[1]].ResourceID].Name)
|
||
this.againNum.text="×"..d[2]
|
||
maxTimesId=lotterySetting[type].MaxTimes --特权上限ID
|
||
if recruitType and recruitType[1] and recruitType[1] == RecruitType.TimeLimitTen then
|
||
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.TenRecruit })
|
||
elseif recruitType and recruitType[1] and recruitType[1] == RecruitType.XiangYaoTen then
|
||
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.XiangYaoDuoBao })
|
||
else
|
||
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Recruit })
|
||
end
|
||
|
||
-- LogGreen("recruitType[1]:"..recruitType[1])
|
||
if RecruitType.Single == recruitType[1] or RecruitType.Ten == recruitType[1] then
|
||
this.tenTip.gameObject:SetActive(true)
|
||
this.tenTipText.text = string.format("剩余%s次必得五星英雄",RecruitManager.GetRecruit3MustCount())
|
||
else
|
||
this.tenTip.gameObject:SetActive(false)
|
||
end
|
||
end
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function TenRecruitPanel:OnClose()
|
||
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function TenRecruitPanel:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
SubUIManager.Close(this.UpView)
|
||
|
||
end
|
||
|
||
return TenRecruitPanel |