コード例 #1
0
    /// <summary>
    /// 释放
    /// </summary>
    public static void ReleaseGameKit()
    {
        Int32 nSize = ms_SingletonKitList == null ? 0 : ms_SingletonKitList.Count;

        for (Int32 i = 0; i < nSize; ++i)
        {
            IGameSingleton gameKit = ms_SingletonKitList[i];
            if (gameKit == null)
            {
                continue;
            }
            gameKit.Release();
        }
    }
コード例 #2
0
    /// <summary>
    /// 初始化
    /// </summary>
    public static void InitGameKit()
    {
        RegisterGameKit();
        Int32 nSize = ms_SingletonKitList == null ? 0 : ms_SingletonKitList.Count;

        for (Int32 i = 0; i < nSize; ++i)
        {
            IGameSingleton gameKit = ms_SingletonKitList[i];
            if (gameKit == null)
            {
                continue;
            }
            gameKit.Init();
        }
    }
コード例 #3
0
        /// <summary>
        /// 销毁所有注册单件
        /// </summary>
        public static void Release()
        {
            if (m_SingletonList == null)
            {
                return;
            }
            Int32 nSize = m_SingletonList.Count;

            for (Int32 i = 0; i < nSize; ++i)
            {
                IGameSingleton singleton = m_SingletonList[i];
                if (singleton == null)
                {
                    continue;
                }
                singleton.Release();
            }
        }
コード例 #4
0
        /// <summary>
        /// 注册单件
        /// </summary>
        /// <param name="singleton"></param>
        /// <returns></returns>
        public static bool RegisterSingleton(IGameSingleton singleton)
        {
            if (singleton == null)
            {
                return(false);
            }
            if (m_SingletonList == null)
            {
                m_SingletonList = new List <IGameSingleton>();
            }
            Int32 nSize = m_SingletonList.Count;

            for (Int32 i = 0; i < nSize; ++i)
            {
                if (m_SingletonList[i] == singleton)
                {
                    return(false);
                }
            }
            m_SingletonList.Add(singleton);
            return(true);
        }
コード例 #5
0
 public void OnGameSingletonCreated(IGameSingleton GameSingleton)
 {
     this.AllGameSingletons.Add(GameSingleton);
 }