miduo_client/Assets/ManagedResources/~Lua/Modules/Harmony/HarmonyPanel.lua

145 lines
4.4 KiB
Lua
Raw Normal View History

2021-02-20 16:55:28 +08:00
require("Base/BasePanel")
2020-11-27 17:59:25 +08:00
HarmonyPanel = Inherit(BasePanel)
HarmonyPanel.contents = {
[1] = {view = require("Modules/Harmony/View/HarmonyScrllow"), panelName = "HarmonyPanel"},
}
HarmonyPanel.prefab={}
--初始化组件(用于子类重写)
function HarmonyPanel:InitComponent()
self.btnBack = Util.GetGameObject(self.gameObject, "Back/BackBtn")
2020-12-15 11:03:34 +08:00
self.helpBtn = Util.GetGameObject(self.gameObject,"HelpBtn")
self.AddBtn = Util.GetGameObject(self.gameObject,"Panel/HarmonyPanel/AddBtn")
self.GongMingBtn = Util.GetGameObject(self.gameObject,"Panel/HarmonyPanel/KnowGongMing")
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
self.panel = Util.GetGameObject(self.gameObject,"Panel")
self.NumText = Util.GetGameObject(self.panel,"HarmonyPanel/itemNumText"):GetComponent("Text")
self.parent = Util.GetGameObject(self.gameObject,"MiddleView")
--初始化格子中的数据
HarmonyManager:InitGongMingDataList()
2020-11-27 17:59:25 +08:00
for i = 1, #self.contents do
self.prefab[i]=Util.GetGameObject(self.panel,self.contents[i].panelName);
2020-12-22 19:27:49 +08:00
self.contents[i].view:InitComponent(self.panel, BagManager.GetTotalItemNum(UpViewRechargeType.XuanHuangZhiQi),BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal),1)
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
function HarmonyPanel:InitTextMum()
local HeroCount = 0
local Box = #HarmonyManager.hongmengHeroInfos;
for i = 1, #HarmonyManager.hongmengHeroInfos do
-- body
if HarmonyManager.hongmengHeroInfos[i].heroId ~="" then
HeroCount = HeroCount + 1
end
end
self.NumText.text = string.format("%d/%d",HeroCount,Box)
end
2020-11-27 17:59:25 +08:00
--绑定事件(用于子类重写)
function HarmonyPanel:BindEvent()
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
2020-12-15 11:03:34 +08:00
Util.AddClick(self.helpBtn,function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.HongMengZhen,self.helpPosition.x,self.helpPosition.y+900)
2020-12-15 11:03:34 +08:00
end)
Util.AddClick(self.AddBtn,function()
--二级弹窗界面
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OpenBoxTips)
end)
--共鸣按钮
Util.AddClick(self.GongMingBtn,function()
2020-12-17 10:41:00 +08:00
local count = HarmonyManager:IsEnvoyCount()
2020-12-29 20:36:37 +08:00
if count > 6 then
2020-12-17 10:41:00 +08:00
-- body
UIManager.OpenPanel(UIName.GongMingResultTips)
else
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[12188])
2020-12-17 10:41:00 +08:00
end
--二级共鸣弹窗
2020-12-15 11:03:34 +08:00
end)
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
function HarmonyPanel:ReFeshTextFun(data)
local HeroCount = 0
local Box = 0
-- body
HeroCount = data[1]
Box = data[2]
self.NumText.text = string.format("%d/%d",HeroCount,Box)
end
2020-11-27 17:59:25 +08:00
--添加事件监听(用于子类重写)
function HarmonyPanel:AddListener()
2020-12-15 11:03:34 +08:00
for i = 1, #self.contents do
2020-11-27 17:59:25 +08:00
self.contents[i].view:AddListener()
2020-12-15 11:03:34 +08:00
end
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.OnlyRefeshText,self.ReFeshTextFun,self)
2020-11-27 17:59:25 +08:00
end
--移除事件监听(用于子类重写)
function HarmonyPanel:RemoveListener()
for i = 1, #self.contents do
self.contents[i].view:RemoveListener()
end
2020-12-15 11:03:34 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.OnlyRefeshText,self.ReFeshTextFun,self)
2020-11-27 17:59:25 +08:00
end
--界面打开时调用(用于子类重写)
2020-12-15 11:03:34 +08:00
function HarmonyPanel:OnOpen()
2020-12-22 19:27:49 +08:00
-- NetManager.PlayerInfoRequest(LoadingPanel.OnStep)
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
--格子
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
for i = 1, #self.contents do
self.contents[i].view:OnOpen()
end
--金币
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
--鸿蒙守卫
self.HarmonyView = SubUIManager.Open(SubUIConfig.HarmonyView,self.parent.transform)
self.HarmonyView.transform.localScale = Vector3.one * 0.95
2020-12-15 11:03:34 +08:00
--对选人列表的刷新
HarmonyManager:SetInitList()
self:InitTextMum()
2020-11-27 17:59:25 +08:00
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function HarmonyPanel:OnShow()
2020-12-22 19:27:49 +08:00
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.HongMengProp})
2020-11-27 17:59:25 +08:00
end
--界面关闭时调用(用于子类重写)
function HarmonyPanel:OnClose()
2020-12-15 11:03:34 +08:00
for i = 1, #self.contents do
self.contents[i].view:OnClose()
end
2020-11-27 17:59:25 +08:00
end
--界面销毁时调用(用于子类重写)
function HarmonyPanel:OnDestroy()
SubUIManager.Close(self.UpView)
end
return HarmonyPanel