dezhou_client/lua_probject/base_project/Game/UIManager.lua

95 lines
3.7 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require "Game.View.init"
require "Game.View.LobbyNew.FilterData"
UIManager = {
ViewLogin = 1,
LobbyView = 2,
ViewCreateCardGame = 4,
ViewCreateUnit = 5,
ViewGameGroup = 6,
ViewMatch = 7,
ViewFilter = 8,
ViewShop = 9,
ViewWallet = 10,
ViewOther = 11,
ViewWait = 12,
ViewSetting = 13,
ViewGame = 20,
ViewToolsTip = 100 --提示
}
local _viewMap = {}
function UIManager.Init()
_viewMap[UIManager.ViewLogin] = { view = LoginViewNew, isload = false, path = "base/login/" }
_viewMap[UIManager.ViewLogin].name = "ViewLogin.prefab"
_viewMap[UIManager.LobbyView] = { view = LobbyView, isload = false, path = "base/lobby/" }
_viewMap[UIManager.LobbyView].name = "Lobby.prefab"
_viewMap[UIManager.ViewCreateCardGame] = { view = CreateCardGameView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewCreateCardGame].name = "ViewCreateCardGame.prefab"
_viewMap[UIManager.ViewCreateUnit] = { view = CreateUnitView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewCreateUnit].name = "ViewCreateUnit.prefab"
_viewMap[UIManager.ViewGameGroup] = { view = GameGroupView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewGameGroup].name = "ViewGameGroup.prefab"
_viewMap[UIManager.ViewMatch] = { view = MatchView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewMatch].name = "ViewMatch.prefab"
_viewMap[UIManager.ViewFilter] = { view = FilterView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewFilter].name = "ViewFilter.prefab"
_viewMap[UIManager.ViewShop] = { view = ShopView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewShop].name = "ViewShop.prefab"
_viewMap[UIManager.ViewWallet] = { view = WalletView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewWallet].name = "ViewWallet.prefab"
_viewMap[UIManager.ViewOther] = { view = OtherView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewOther].name = "ViewOther.prefab"
_viewMap[UIManager.ViewWait] = { view = WaitView, isload = false, path = "base/common/" }
_viewMap[UIManager.ViewWait].name = "ViewWait.prefab"
_viewMap[UIManager.ViewSetting] = { view = SettingViewNew, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewSetting].name = "ViewSetting.prefab"
_viewMap[UIManager.ViewGame] = { view = GameView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewGame].name = "ViewGame.prefab"
_viewMap[UIManager.ViewToolsTip] = { view = ToolsTipView, isload = false, path = "base/prefab/" }
_viewMap[UIManager.ViewToolsTip].name = "ViewToolsTip.prefab"
end
function UIManager.ShowUI(v, callback)
if not _viewMap[v].isload then
_viewMap[v].isload = true
local view = _viewMap[v].view.new()
print("加载UI资源" .. _viewMap[v].path .. _viewMap[v].name)
local pref = ResourcesManager.LoadObject(_viewMap[v].path .. _viewMap[v].name, typeof(UnityEngine.GameObject))
local go = UnityEngine.GameObject.Instantiate(pref, UGUIRootCanvas.transform, false)
view._view = go
_viewMap[v].view = view
_viewMap[v].view.path = _viewMap[v].path
view.callback = callback
view:InitView()
view:init()
end
_viewMap[v].view._view:SetActive(true)
LuaUIHelper:SetGameObjectLastSibling(_viewMap[v].view._view)
return _viewMap[v].view
end
function UIManager.HideUI(v)
if _viewMap[v] and _viewMap[v].view._view then
_viewMap[v].view._view:SetActive(false)
end
end
function UIManager.GetGo(path, transform)
local pref = ResourcesManager.LoadObject(path, typeof(UnityEngine.GameObject))
return UnityEngine.GameObject.Instantiate(pref, transform, false)
end