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

153 lines
4.9 KiB
Lua

require("Base/BasePanel")
HarmonyPanel = Inherit(BasePanel)
local contents = {
[1] = {view = require("Modules/Harmony/View/HarmonyScrllow"), panelName = "HarmonyPanel"},
}
--初始化组件(用于子类重写)
function HarmonyPanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.prefab = {}
self.btnBack = Util.GetGameObject(self.gameObject, "Back/BackBtn")
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.GradeText = Util.GetGameObject(self.gameObject, "Panel/HarmonyPanel/GradeText"):GetComponent("Text")
self.NumText = Util.GetGameObject(self.panel,"HarmonyPanel/itemNumText"):GetComponent("Text")
self.parent = Util.GetGameObject(self.gameObject,"MiddleView")
--初始化格子中的数据
HarmonyManager:InitGongMingDataList()
for i = 1, #contents do
self.prefab[i]=Util.GetGameObject(self.panel,contents[i].panelName);
contents[i].view:InitComponent(self.panel, BagManager.GetTotalItemNum(UpViewRechargeType.XuanHuangZhiQi),BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal),1)
end
end
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
--绑定事件(用于子类重写)
function HarmonyPanel:BindEvent()
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
Util.AddClick(self.helpBtn,function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.HongMengZhen,self.helpPosition.x,self.helpPosition.y+900)
end)
Util.AddClick(self.AddBtn,function()
--二级弹窗界面
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OpenBoxTips)
end)
--共鸣按钮
Util.AddClick(self.GongMingBtn,function()
local count = HarmonyManager:IsEnvoyCount()
if count > 6 then
-- body
UIManager.OpenPanel(UIName.GongMingResultTips)
else
PopupTipPanel.ShowTip(Language[12188])
end
--二级共鸣弹窗
end)
end
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
--添加事件监听(用于子类重写)
function HarmonyPanel:AddListener()
for i = 1, #contents do
contents[i].view:AddListener()
end
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.OnlyRefeshText,self.ReFeshTextFun,self)
end
--移除事件监听(用于子类重写)
function HarmonyPanel:RemoveListener()
for i = 1, #contents do
contents[i].view:RemoveListener()
end
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.OnlyRefeshText,self.ReFeshTextFun,self)
end
--界面打开时调用(用于子类重写)
function HarmonyPanel:OnOpen()
-- NetManager.PlayerInfoRequest(LoadingPanel.OnStep)
--格子
self.GradeText.text="鸿蒙阵等级:"..string.format("%d/%d", HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value, 330)
for i = 1, #contents do
contents[i].view:OnOpen(self.sortingOrder)
end
--金币
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
--鸿蒙守卫
self.HarmonyView = SubUIManager.Open(SubUIConfig.HarmonyView,self.parent.transform,self.sortingOrder)
self.HarmonyView.transform.localScale = Vector3.one * 0.95
--对选人列表的刷新
HarmonyManager:SetInitList()
self:InitTextMum()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function HarmonyPanel:OnShow()
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.HongMengProp})
self.HarmonyView:SetEffectLayer(self.sortingOrder)
for i = 1, #contents do
contents[i].view:SetEffectLayer(self.sortingOrder)
end
end
function HarmonyPanel:OnSortingOrderChange()
for i = 1, #contents do
contents[i].view:SetEffectLayer(self.sortingOrder)
end
end
--界面关闭时调用(用于子类重写)
function HarmonyPanel:OnClose()
for i = 1, #contents do
contents[i].view:OnClose()
end
end
--界面销毁时调用(用于子类重写)
function HarmonyPanel:OnDestroy()
self.spLoader:Destroy()
SubUIManager.Close(self.UpView)
end
return HarmonyPanel