require("Base/BasePanel") RecruitPanel = Inherit(BasePanel) local this = RecruitPanel --local preList local i = 0 local canDrag = true local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting) local AllActSetConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig) local orginLayer = 0 --初始化组件(用于子类重写) function RecruitPanel:InitComponent() self.BtnBack = Util.GetGameObject(self.transform, "btnBack/btnBack") self.box1btn1 = Util.GetGameObject(self.transform, "rewardBox/btn1") self.box1btn10 = Util.GetGameObject(self.transform, "rewardBox/btn10") this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft, panelType = PanelType.Recruit }) --this.BtView = SubUIManager.Open(SubUIConfig.BtView, self.gameObject.transform) this.slider = Util.GetGameObject(self.transform, "rewardBox/Slider"):GetComponent("Slider") this.sliderText = Util.GetGameObject(self.transform, "rewardBox/Slider/Fill Area/Text"):GetComponent("Text") this.boxOpenBtn = Util.GetGameObject(self.transform, "openBoxShow/boxIcon") self.openBoxShow = Util.GetGameObject(self.transform, "openBoxShow") self.chooseBoxImage = Util.GetGameObject(self.transform, "scrollRect/bgImage") self.imageList = { "y_yuansu_yuansu", "y_yuansu_qunying", "y_yuansu_mihe", "y_yuansu_yuansu", "y_yuansu_qunying", "y_yuansu_mihe" } self.detailText = Util.GetGameObject(self.transform, "rewardBox/content/detailText"):GetComponent("Text") self.bgImage = Util.GetGameObject(self.transform, "bgImage") --self.grid = Util.GetGameObject(self.transform, "scrollRect/grid") this.conten1 = Util.GetGameObject(self.transform, "rewardBox/btn1/content1") this.conten2 = Util.GetGameObject(self.transform, "rewardBox/btn1/content2") self.showImage = Util.GetGameObject(self.transform, "showImage") self.previewBtn = Util.GetGameObject(self.transform, "previewBtn") -- RecruitManager.GetRewardPreviewData() screenAdapte(self.bgImage) self.UI_effect_RecruitPanel_box_normal = Util.GetGameObject(self.transform, "rewardBox/content/UI_effect_RecruitPanel_box_normal") effectAdapte(Util.GetGameObject(self.UI_effect_RecruitPanel_box_normal, "quan01")) self.UI_effect_RecruitPanel_box_open = Util.GetGameObject(self.transform, "rewardBox/content/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.transform, "UI_effect_RecruitPanel_particle") end --绑定事件(用于子类重写) function RecruitPanel:BindEvent() Util.AddClick(self.BtnBack, function() self:ClosePanel() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) --UIManager.OpenPanel(UIName.MainPanel) end) Util.AddClick(this.boxOpenBtn, function() for i, v in ipairs(RecruitManager.boxReward) do UIManager.OpenPanel(UIName.RewardItemPopup, RecruitManager.boxReward[i], 1) table.remove(RecruitManager.boxReward, i) break end if (#RecruitManager.boxReward <= 0) then RecruitManager.boxReward = {} self.openBoxShow:SetActive(false) RecruitManager.isCanOpenBox = false end Util.GetGameObject(self.transform, "rewardBox/content/boxIcon"):GetComponent("Animator").enabled = false self.UI_effect_RecruitPanel_box_normal:SetActive(true) end) Util.AddClick(self.box1btn1, function() if (RecruitManager.recruitFreeUseTime < 1) then if PopQuickPurchasePanel(UpViewRechargeType.SpiritTicket, 1) then return end end RecruitManager.RecruitRequest(RecruitType.Single, function(msg) UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero[1], 12) RecruitManager.randCount = RecruitManager.randCount + 1 if (#msg.extraBox.Hero ~= 0) then RecruitManager.randCount = 0 RecruitManager.isCanOpenBox = true table.insert(RecruitManager.boxReward, msg.extraBox) end self:UpdatePanelData() end) end) Util.AddClick(self.box1btn10, function() if PopQuickPurchasePanel(UpViewRechargeType.SpiritTicket, 10) then return end RecruitManager.RecruitRequest(RecruitType.Ten, function(msg) UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero, 11) RecruitManager.randCount = RecruitManager.randCount + 10 RecruitManager.isTenRecruit = 1 if (#msg.extraBox.Hero ~= 0) then RecruitManager.randCount = RecruitManager.randCount - gameSetting[1].LotterySecurityReward[1] RecruitManager.isCanOpenBox = true table.insert(RecruitManager.boxReward, msg.extraBox) --RecruitManager.boxReward=msg.extraBox end self:UpdatePanelData() end) end) Util.AddClick(self.previewBtn, function() UIManager.OpenPanel(UIName.HeroPreviewPanel,RecruitManager.previewHeroData,true) end) end -- 刷新红点显示 function RecruitPanel:RefreshRedPointShow() if (RecruitManager.recruitFreeUseTime < 1) then this.conten1:SetActive(true) this.conten2:SetActive(false) else this.conten1:SetActive(false) this.conten2:SetActive(true) end end --添加事件监听(用于子类重写) function RecruitPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Recruit.OnRecruitRefreshData, this.RefreshRedPointShow) end --移除事件监听(用于子类重写) function RecruitPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Recruit.OnRecruitRefreshData, this.RefreshRedPointShow) end function RecruitPanel:OnSortingOrderChange() Util.AddParticleSortLayer(self.UI_effect_RecruitPanel_box_normal, self.sortingOrder - orginLayer) Util.AddParticleSortLayer(self.UI_effect_RecruitPanel_box_open, self.sortingOrder - orginLayer) Util.AddParticleSortLayer(self.UI_effect_RecruitPanel_particle, self.sortingOrder - orginLayer) orginLayer = self.sortingOrder end --界面打开时调用(用于子类重写) function RecruitPanel:OnShow(...) self:UpdatePanelData() this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Recruit }) --this.BtView:OnOpen({ sortOrder = self.sortingOrder, panelType = PanelTypeView.RecruitPanel }) self.openBoxShow.transform:SetSiblingIndex(7) SoundManager.PlayMusic(SoundConfig.BGM_Recruit) self.detailText.text = "非酋气息达到" .. gameSetting[1].LotterySecurityReward[1] .. "后可开启" if (RecruitManager.isCanOpenBox == true) then self.openBoxShow:SetActive(true) else self.openBoxShow:SetActive(false) end end function RecruitPanel:UpdatePanelData() if (RecruitManager.recruitFreeUseTime < 1) then this.conten1:SetActive(true) this.conten2:SetActive(false) else this.conten1:SetActive(false) this.conten2:SetActive(true) end this.slider.value = RecruitManager.randCount / gameSetting[1].LotterySecurityReward[1] this.sliderText.text = string.format("%s/%s", RecruitManager.randCount, gameSetting[1].LotterySecurityReward[1]) Util.GetGameObject(self.transform, "rewardBox/content/boxIcon"):GetComponent("Animator").enabled = RecruitManager.isCanOpenBox --self.UI_effect_RecruitPanel_box_open:SetActive(RecruitManager.isCanOpenBox) self.UI_effect_RecruitPanel_box_normal:SetActive(not RecruitManager.isCanOpenBox) if (RecruitManager.isTenRecruit == 0) then self.showImage:SetActive(true) else self.showImage:SetActive(false) end end --跳转显示新手提示圈 function this.ShowGuideGo(_index) if _index == 1 then JumpManager.ShowGuide(UIName.RecruitPanel, this.box1btn1) elseif _index == 10 then JumpManager.ShowGuide(UIName.RecruitPanel, this.box1btn10) end end --界面关闭时调用(用于子类重写) function RecruitPanel:OnClose() end --界面销毁时调用(用于子类重写) function RecruitPanel:OnDestroy() SubUIManager.Close(this.UpView) --SubUIManager.Close(this.BtView) end return RecruitPanel