using Cysharp.Threading.Tasks; using System; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.U2D; public static class Game { public static bool isEnterGame = false; public static long enterRoomId = 0; /// /// 用户基础信息 /// // public static user_base_info_reply userInfo; /// /// 用户账号 /// public static long account; /// /// 服务器配置 string /// public static Dictionary serverConfig_string = new Dictionary(); /// /// 服务器配置 int /// public static Dictionary serverConfig_int = new Dictionary(); /// /// 游戏管理器 /// public static GameManager gameMgr { get; private set; } = new GameManager(); /// /// 时间管理器 /// public static TimeManager timeMgr { get; private set; } = new TimeManager(); /// /// 计时器管理器 /// public static TimerManager timerMgr { get; private set; } = new TimerManager(); /// /// 网络管理器 /// public static NetworkManager netMgr { get; private set; } = new NetworkManager(); /// /// 配置管理器 /// public static ConfigManager config { get; private set; } = new ConfigManager(); /// /// 多语言管理器 /// public static LanguageManager language { get; private set; } = new LanguageManager(); /// /// 服务器管理器 /// public static ServerModel server = new ServerModel(); /// /// 预加载管理器 /// public static PreloadManager preload { get; private set; } = new PreloadManager(); /// /// ui 事件管理器 /// public static UIEventManager uiEvent { get; private set; } = new UIEventManager(); /// /// ui 事件管理器 /// public static AtlasManager atlasMgr { get; private set; } = new AtlasManager(); public static SoundManager sound = new SoundManager(); public static PoolManager pool { get; private set; } = new PoolManager(); public static BackpackManager backpack = new BackpackManager(); public static MonoBehaviour mono; internal static Texture2D userHead; /// /// 启动游戏 /// public static async void Init(MonoBehaviour ga) { mono = ga; // 同一账号互踢下线弹窗通知 // Framework.network.Register(CusProtobuf.client_msg_enum.kick_account_tips_notify, //OnKickAccount); // 服务器配置下发 // Framework.network.Register(CusProtobuf.client_msg_enum.server_config_notify, // OnServerConfig); pool.Init(GameObject.Find("Gui/Canvas/Pool").transform); sound.InitializePool(); config.Init(); uiEvent.Init(); language.Init(); timeMgr.Init(); timerMgr.Init(); netMgr.Init(); // 初始化图集 await InitSpriteAtlas(); await preload.Init(); await gameMgr.InitAsync(); } /// /// 初始化图集 /// private static async UniTask InitSpriteAtlas() { try { // 初始化选服界面图集 await Framework.res.LoadAtlas("Assets/Art/UI/Picture/SelectServer/atlas_SelcetServer"); } catch (Exception e) { } } /// /// 同一账号被踢下线 /// // private static async void OnKickAccount(kick_account_tips_notify notify) // { // Framework.uiMgr.CloseAllPanel(); // // UI_Tips tips = await Framework.uiMgr.OpenPanel(); // //tips.OnShowTips("Already logged into this account on another device."); // // tips.onOk = () => Application.Quit(); // } /// /// 服务器配置下发 /// // private static void OnServerConfig(server_config_notify notify) // { // for (int i = 0; i < notify.str_list.Count; i++) // { // var item = notify.str_list[i]; // if (serverConfig_string.ContainsKey(item.key)) // { // Debug.Log($"有重复的key{item.key}"); // serverConfig_string[item.key] = item.value; // } // else // serverConfig_string.Add(item.key, item.value); // } // // for (int i = 0; i < notify.int_list.Count; i++) // { // var item = notify.int_list[i]; // if (serverConfig_int.ContainsKey(item.key)) // { // Debug.Log($"有重复的key{item.key}"); // serverConfig_int[item.key] = item.value; // } // else // serverConfig_int.Add(item.key, item.value); // } // } }