----- 公会红包 ----- require("Base/BasePanel") local RedPacketPanel = Inherit(BasePanel) local this=RedPacketPanel local TabBox = require("Modules/Common/TabBox") local _TabImgData = {select = "r_tongyong_xiaanniu_01", default = "r_tongyong_xiaanniu_02",} local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1), select = Color.New(243 / 255, 235 / 255, 202 / 255, 1) } local _TabData = { [1]= {txt = Language[11037]}, [2]= {txt = "发福利红包"}, [3]= {txt = Language[11038]}, [4]= {txt = Language[11039]}, } --子模块脚本 this.contents = { --主面板 [1] = {view = require("Modules/Guild/RedPacketView/RedPacket_SendView"), panelName = "SendView"}, --发送福利红包 [2] = {view = require("Modules/Guild/RedPacketView/RedPacket_SendWealView"), panelName = "SendWealView"}, --天官赐福 [3] = {view = require("Modules/Guild/RedPacketView/RedPacket_GetView"), panelName = "GetView"}, --每日仙缘礼 [4] = {view = require("Modules/Guild/RedPacketView/RedPacket_RankView"), panelName = "RankView"}, } -- this.contentPanel={} this.sortingOrder = 0 this.curIndex=1 --初始化组件(用于子类重写) function RedPacketPanel:InitComponent() this.panel=Util.GetGameObject(self.gameObject, "Panel") this.backBtn=Util.GetGameObject(this.panel,"BackBtn") this.tabbox = Util.GetGameObject(this.panel, "Contents/TabBox") this.content=Util.GetGameObject(this.panel,"Contents") this.contentPanel={} --预设 for i = 1, #this.contents do this.contentPanel[i]=Util.GetGameObject(this.content,this.contents[i].panelName) end --脚本 for i = 1, #this.contents do this.contents[i].view:InitComponent(Util.GetGameObject(this.content, this.contents[i].panelName)) this.spLoader = SpriteLoader.New() end this.redPoint=Util.GetGameObject(this.content,"RedPoint") end --绑定事件(用于子类重写) function RedPacketPanel:BindEvent() for i = 1, #this.contents do this.contents[i].view:BindEvent() end Util.AddClick(this.backBtn,function() self:ClosePanel() end) end --添加事件监听(用于子类重写) function RedPacketPanel:AddListener() for i = 1, #this.contents do this.contents[i].view:AddListener() end Game.GlobalEvent:AddEvent(GameEvent.GuildRedPacket.OnCloseRedPointClick, this.CloseRedPointClick) end --移除事件监听(用于子类重写) function RedPacketPanel:RemoveListener() for i = 1, #this.contents do this.contents[i].view:RemoveListener() end Game.GlobalEvent:RemoveEvent(GameEvent.GuildRedPacket.OnCloseRedPointClick, this.CloseRedPointClick) end --界面打开时调用(用于子类重写) function RedPacketPanel:OnOpen(index) if index then this.curIndex=index end end local redPointList --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function RedPacketPanel:OnShow() -- BindRedPointObject(RedPointType.Guild_RedPacket,this.redPoint) this.tabbox:SetActive(true) this.TabCtrl = TabBox.New() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.OnTabChange) this.TabCtrl:Init(this.tabbox, _TabData,this.curIndex) redPointList = {} for i = 1, Util.GetGameObject(this.tabbox,"box").transform.childCount do redPointList[i] =Util.GetGameObject(Util.GetGameObject(this.tabbox,"box").transform:GetChild(i-1).gameObject,"RedPoint") redPointList[i]:SetActive(false) end if redPointList[2] and redPointList[3] then BindRedPointObject(RedPointType.Guid_SendPackage, redPointList[2]) BindRedPointObject(RedPointType.Guid_GetPackage, redPointList[3]) end --CheckRedPointStatus(RedPointType.Guid_SendPackage) --CheckRedPointStatus(RedPointType.Guid_GetPackage) end --重设层级 function RedPacketPanel:OnSortingOrderChange() this.sortingOrder = self.sortingOrder end --界面关闭时调用(用于子类重写) function RedPacketPanel:OnClose() for i = 1, #this.contents do this.contents[i].view:OnClose() end ClearRedPointObject(RedPointType.Guild_RedPacket,this.redPoint) if redPointList[2] and redPointList[3] then ClearRedPointObject(RedPointType.Guid_SendPackage, redPointList[2]) ClearRedPointObject(RedPointType.Guid_GetPackage, redPointList[3]) end end --界面销毁时调用(用于子类重写) function RedPacketPanel:OnDestroy() for i = 1, #this.contents do this.contents[i].view:OnDestroy() this.spLoader:Destroy() end redPointList=nil end -- tab按钮自定义显示设置 function this.TabAdapter(tab, index, status) local img = Util.GetGameObject(tab, "Image") local txt = Util.GetGameObject(tab, "Text") img:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabImgData[status]) txt:GetComponent("Text").text = _TabData[index].txt txt:GetComponent("Text").color = _TabFontColor[status] end -- tab改变回调事件 function this.OnTabChange(index, lastIndex) if lastIndex then this.CloseView(lastIndex) end this.OpenView(index) if index==2 then Game.GlobalEvent:DispatchEvent(GameEvent.GuildRedPacket.OnCloseRedPointClick) end end -- 打开View function this.OpenView(index) this.contents[index].view:OnShow(this.sortingOrder) for i = 1, #this.contentPanel do this.contentPanel[i]:SetActive(i==index) end end -- 关闭View function this.CloseView(lastIndex) --CheckRedPointStatus(RedPointType.Guild_RedPacket) --CheckRedPointStatus(RedPointType.Guid_SendPackage) --CheckRedPointStatus(RedPointType.Guid_GetPackage) MyGuildManager.ReuqsetRedPackage() this.contents[lastIndex].view:OnClose() end -- 刷新红包查看后红点点击操作 function this.CloseRedPointClick() GuildRedPacketManager.isCheck=false --CheckRedPointStatus(RedPointType.Guild_RedPacket) --CheckRedPointStatus(RedPointType.Guid_SendPackage) --CheckRedPointStatus(RedPointType.Guid_GetPackage) MyGuildManager.ReuqsetRedPackage() end return RedPacketPanel