require("Base/BasePanel") local GuildCreatePopup = Inherit(BasePanel) local this = GuildCreatePopup --初始化组件(用于子类重写) function GuildCreatePopup:InitComponent() this.btnBack = Util.GetGameObject(self.transform, "btnClose") this.btnCreate = Util.GetGameObject(self.transform, "tipImage/btnCreate") this.inputName = Util.GetGameObject(self.transform, "tipImage/name"):GetComponent("InputField") this.inputAnnounce = Util.GetGameObject(self.transform, "tipImage/content"):GetComponent("InputField") this.costTip = Util.GetGameObject(self.transform, "tipImage/costTips"):GetComponent("Text") this.creatTips = Util.GetGameObject(self.transform, "tipImage/Tips"):GetComponent("Text") this.money = 0 end --绑定事件(用于子类重写) function GuildCreatePopup:BindEvent() Util.AddClick(this.btnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) this:ClosePanel() end) -- 搜索 Util.AddClick(this.btnCreate, function() local name = this.inputName.text local announce = this.inputAnnounce.text if name == "" then PopupTipPanel.ShowTipByLanguageId(10851) return end -- if this.money ~= 0 then -- if FirstRechargeManager.GetAccumRechargeValue() < this.money then -- PopupTipPanel.ShowTipByLanguageId("gun dan") -- return -- end -- end local config = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1) local minLen, maxLen = config.NameSize[1], config.NameSize[2] local len = StringWidth(name) if len < minLen or len > maxLen then PopupTipPanel.ShowTipByLanguageId(10852) return end local cost = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).CreatCost CostConfirmPopup.Show(cost[1][1], cost[1][2], GetLanguageStrById(10853), nil, function() local haveNum = BagManager.GetItemCountById(cost[1][1]) if haveNum < cost[1][2] then PopupTipPanel.ShowTipByLanguageId(10854) return end GuildManager.RequestCreateGuild(name, announce, function() this:ClosePanel() if this.successFunc then this.successFunc() end UIManager.OpenPanel(UIName.GuildMainCityPanel) PopupTipPanel.ShowTipByLanguageId(10855) end) end) end) end --添加事件监听(用于子类重写) function GuildCreatePopup:AddListener() end --移除事件监听(用于子类重写) function GuildCreatePopup:RemoveListener() end --界面打开时调用(用于子类重写) function GuildCreatePopup:OnOpen(successFunc) local defaultAnnounce = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).DefaultDeclaration this.inputName.text = "" this.inputAnnounce.text = GetLanguageStrById(defaultAnnounce) this.successFunc = successFunc -- 创建消耗 local cost = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).CreatCost local costName = ConfigManager.GetConfigData(ConfigName.ItemConfig, cost[1][1]).Name -- this.costTip.text = string.format(GetLanguageStrById(10856), cost[1][2], costName) this.costTip.text = cost[1][2] end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function GuildCreatePopup:OnShow() this.money = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).CreatRechargeNum if this.money == 0 then this.creatTips.gameObject:SetActive(false) else this.creatTips.gameObject:SetActive(true) local str = FirstRechargeManager.GetAccumRechargeValue().."/"..this.money if FirstRechargeManager.GetAccumRechargeValue() >= this.money then str = string.format("%s", str) else str = string.format("%s", str) end this.creatTips.text = string.format(GetLanguageStrById(50408),str) -- end if FirstRechargeManager.GetAccumRechargeValue() >= this.money then this.btnCreate:GetComponent("Button").enabled = true Util.SetGray(this.btnCreate, false) else this.btnCreate:GetComponent("Button").enabled = false Util.SetGray(this.btnCreate, true) end end --界面关闭时调用(用于子类重写) function GuildCreatePopup:OnClose() end --界面销毁时调用(用于子类重写) function GuildCreatePopup:OnDestroy() end return GuildCreatePopup