188 lines
5.1 KiB
C#
188 lines
5.1 KiB
C#
|
|
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;
|
|
|
|
/// <summary>
|
|
/// 用户基础信息
|
|
/// </summary>
|
|
// public static user_base_info_reply userInfo;
|
|
|
|
/// <summary>
|
|
/// 用户账号
|
|
/// </summary>
|
|
public static long account;
|
|
|
|
/// <summary>
|
|
/// 服务器配置 string
|
|
/// </summary>
|
|
public static Dictionary<long, string> serverConfig_string = new Dictionary<long, string>();
|
|
|
|
/// <summary>
|
|
/// 服务器配置 int
|
|
/// </summary>
|
|
public static Dictionary<long, long> serverConfig_int = new Dictionary<long, long>();
|
|
|
|
/// <summary>
|
|
/// 游戏管理器
|
|
/// </summary>
|
|
public static GameManager gameMgr { get; private set; } = new GameManager();
|
|
|
|
/// <summary>
|
|
/// 时间管理器
|
|
/// </summary>
|
|
public static TimeManager timeMgr { get; private set; } = new TimeManager();
|
|
|
|
/// <summary>
|
|
/// 计时器管理器
|
|
/// </summary>
|
|
public static TimerManager timerMgr { get; private set; } = new TimerManager();
|
|
|
|
/// <summary>
|
|
/// 网络管理器
|
|
/// </summary>
|
|
public static NetworkManager netMgr { get; private set; } = new NetworkManager();
|
|
|
|
/// <summary>
|
|
/// 配置管理器
|
|
/// </summary>
|
|
public static ConfigManager config { get; private set; } = new ConfigManager();
|
|
|
|
/// <summary>
|
|
/// 多语言管理器
|
|
/// </summary>
|
|
public static LanguageManager language { get; private set; } = new LanguageManager();
|
|
|
|
/// <summary>
|
|
/// 服务器管理器
|
|
/// </summary>
|
|
public static ServerModel server = new ServerModel();
|
|
|
|
/// <summary>
|
|
/// 预加载管理器
|
|
/// </summary>
|
|
public static PreloadManager preload { get; private set; } = new PreloadManager();
|
|
|
|
/// <summary>
|
|
/// ui 事件管理器
|
|
/// </summary>
|
|
public static UIEventManager uiEvent { get; private set; } = new UIEventManager();
|
|
|
|
/// <summary>
|
|
/// ui 事件管理器
|
|
/// </summary>
|
|
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;
|
|
|
|
/// <summary>
|
|
/// 启动游戏
|
|
/// </summary>
|
|
public static async void Init(MonoBehaviour ga)
|
|
{
|
|
mono = ga;
|
|
|
|
// 同一账号互踢下线弹窗通知
|
|
// Framework.network.Register<kick_account_tips_notify>(CusProtobuf.client_msg_enum.kick_account_tips_notify,
|
|
//OnKickAccount);
|
|
|
|
// 服务器配置下发
|
|
// Framework.network.Register<server_config_notify>(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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化图集
|
|
/// </summary>
|
|
private static async UniTask InitSpriteAtlas()
|
|
{
|
|
try
|
|
{
|
|
// 初始化选服界面图集
|
|
await Framework.res.LoadAtlas("Assets/Art/UI/Picture/SelectServer/atlas_SelcetServer");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 同一账号被踢下线
|
|
/// </summary>
|
|
// private static async void OnKickAccount(kick_account_tips_notify notify)
|
|
// {
|
|
// Framework.uiMgr.CloseAllPanel();
|
|
// // UI_Tips tips = await Framework.uiMgr.OpenPanel<UI_Tips>();
|
|
// //tips.OnShowTips("Already logged into this account on another device.");
|
|
// // tips.onOk = () => Application.Quit();
|
|
// }
|
|
|
|
/// <summary>
|
|
/// 服务器配置下发
|
|
/// </summary>
|
|
// 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);
|
|
// }
|
|
// }
|
|
} |