miduo_client/Assets/ManagedResources/~Lua/Modules/Recruit/TenRecruitPanel.lua

158 lines
6.7 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
TenRecruitPanel = Inherit(BasePanel)
local this = TenRecruitPanel
local cardList = {}
local orginLayer
local gameSetting=ConfigManager.GetConfig(ConfigName.GameSetting)
2020-05-25 19:16:23 +08:00
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={}--前端显示用 抽卡类型
2020-05-25 19:16:23 +08:00
local maxTimesId--特权id上限今日召唤上限
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function TenRecruitPanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
orginLayer = 0
this.sureBtn = Util.GetGameObject(self.transform, "sureBtn")
this.againBtn = Util.GetGameObject(self.transform, "againBtn")
2020-05-25 19:16:23 +08:00
this.againIcon=Util.GetGameObject(self.transform,"Tip/juan"):GetComponent("Image")
this.againNum=Util.GetGameObject(self.transform,"Tip/Text"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
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")
2020-05-09 13:31:21 +08:00
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})
2020-05-09 13:31:21 +08:00
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
2020-05-09 13:31:21 +08:00
self:ClosePanel()
end)
Util.AddClick(self.againBtn, function()
2020-05-25 19:16:23 +08:00
local d=RecruitManager.GetExpendData(type)
if BagManager.GetItemCountById(d[1])<d[2] then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[d[1]].Name)..Language[10486])
2020-05-25 19:16:23 +08:00
return
end
if PrivilegeManager.GetPrivilegeUsedTimes(maxTimesId)+1>privilegeConfig[maxTimesId].Condition[1][2] then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10485])
2020-05-09 13:31:21 +08:00
return
end
2020-12-23 10:34:47 +08:00
if d[1] == 16 then
if lotterySetting[type].MoneyTimes and lotterySetting[type].MoneyTimes > 0 and PrivilegeManager.GetPrivilegeRemainValue(lotterySetting[type].MoneyTimes) < 10 then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11423])
2020-12-23 10:34:47 +08:00
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
2020-05-09 13:31:21 +08:00
end)
end
--添加事件监听(用于子类重写)
function TenRecruitPanel:AddListener()
end
--移除事件监听(用于子类重写)
function TenRecruitPanel:RemoveListener()
end
function TenRecruitPanel:OnSortingOrderChange()
Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
2020-09-25 14:11:05 +08:00
-- 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)
2020-05-09 13:31:21 +08:00
end
2020-07-28 15:06:47 +08:00
orginLayer = self.sortingOrder
2020-05-09 13:31:21 +08:00
end
2020-07-28 15:06:47 +08:00
2020-05-09 13:31:21 +08:00
--界面打开时调用(用于子类重写)
function TenRecruitPanel:OnOpen(...)
local data = { ... }
local _roleDatas = data[1]
2020-05-25 19:16:23 +08:00
type=data[2]
recruitType=data[3]
2020-05-09 13:31:21 +08:00
for i = 1, #_roleDatas do
cardList[i]:OnOpen(_roleDatas[i].id,false,false,-1,self.sortingOrder)
local heorConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig,_roleDatas[i].heroId)
-- LogBlue("heorConfig.Star:"..heorConfig.Star)
2020-08-22 19:40:14 +08:00
if heorConfig and heorConfig.Star >= 5 then
2020-05-09 13:31:21 +08:00
HeroManager.DetectionOpenFiveStarActivity(heorConfig.Star)
end
end
2021-05-28 10:36:55 +08:00
local d=nil
local config=ConfigManager.TryGetConfigDataByKey(ConfigName.WishActivityUp,"ActivityId",type)
2021-05-28 10:36:55 +08:00
if config then
local Setting= ConfigManager.GetConfigData(ConfigName.WishActivitySetting,1)
local num=PrivilegeManager.GetPrivilegeRemainValue(Setting.DiamondMaxTimes)
d=RecruitManager.GetExpendDataByCostItem(Setting.CostItemMul,2,num)
2021-05-28 10:36:55 +08:00
else
d=RecruitManager.GetExpendData(type)
end
2021-04-21 13:12:04 +08:00
this.againIcon.sprite=this.spLoader:LoadSprite(artResourcesConfig[itemConfig[d[1]].ResourceID].Name)
2020-05-25 19:16:23 +08:00
this.againNum.text="×"..d[2]
2020-06-28 17:48:49 +08:00
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
2021-07-01 17:30:20 +08:00
-- 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
2020-05-09 13:31:21 +08:00
end
--界面关闭时调用(用于子类重写)
function TenRecruitPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function TenRecruitPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
SubUIManager.Close(this.UpView)
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return TenRecruitPanel