Exemplo n.º 1
0
        private void LoadDataTableDependencyAssetCallback(string dataTableAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GameFrameworkException("Load data table info is invalid.");
            }

            if (m_LoadDataTableDependencyAssetEventHandler != null)
            {
                m_LoadDataTableDependencyAssetEventHandler(this, new LoadDataTableDependencyAssetEventArgs(dataTableAssetName, dependencyAssetName, loadedCount, totalCount, loadDataTableInfo.UserData));
            }
        }
Exemplo n.º 2
0
        private void LoadDataTableUpdateCallback(string dataTableAssetName, float progress, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GameFrameworkException("Load data table info is invalid.");
            }

            if (m_LoadDataTableUpdateEventHandler != null)
            {
                m_LoadDataTableUpdateEventHandler(this, new LoadDataTableUpdateEventArgs(dataTableAssetName, loadDataTableInfo.LoadType, progress, loadDataTableInfo.UserData));
            }
        }
Exemplo n.º 3
0
        private void LoadAssetDependencyAssetCallback(string dataTableAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GXException("Load data table info is invalid.");
            }

            if (m_LoadDataTableDependencyAssetEventHandler != null)
            {
                LoadDataTableDependencyAssetEventArgs loadDataTableDependencyAssetEventArgs = LoadDataTableDependencyAssetEventArgs.Create(dataTableAssetName, dependencyAssetName, loadedCount, totalCount, loadDataTableInfo.UserData);
                m_LoadDataTableDependencyAssetEventHandler(this, loadDataTableDependencyAssetEventArgs);
                ReferencePool.Release(loadDataTableDependencyAssetEventArgs);
            }
        }
Exemplo n.º 4
0
        private void LoadAssetUpdateCallback(string dataTableAssetName, float progress, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GXException("Load data table info is invalid.");
            }

            if (m_LoadDataTableUpdateEventHandler != null)
            {
                LoadDataTableUpdateEventArgs loadDataTableUpdateEventArgs = LoadDataTableUpdateEventArgs.Create(dataTableAssetName, loadDataTableInfo.LoadType, progress, loadDataTableInfo.UserData);
                m_LoadDataTableUpdateEventHandler(this, loadDataTableUpdateEventArgs);
                ReferencePool.Release(loadDataTableUpdateEventArgs);
            }
        }
Exemplo n.º 5
0
        private void LoadDataTableFailureCallback(string dataTableAssetName, LoadResourceStatus status, string errorMessage, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GameFrameworkException("Load data table info is invalid.");
            }

            string appendErrorMessage = Utility.Text.Format("Load data table failure, asset name '{0}', status '{1}', error message '{2}'.", dataTableAssetName, status.ToString(), errorMessage);

            if (m_LoadDataTableFailureEventHandler != null)
            {
                m_LoadDataTableFailureEventHandler(this, new LoadDataTableFailureEventArgs(dataTableAssetName, appendErrorMessage, loadDataTableInfo.UserData));
                return;
            }

            throw new GameFrameworkException(appendErrorMessage);
        }
Exemplo n.º 6
0
        private void LoadDataTableSuccessCallback(string dataTableAssetName, object dataTableAsset, float duration, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GameFrameworkException("Load data table info is invalid.");
            }

            try
            {
                if (!m_DataTableHelper.LoadDataTable(dataTableAsset, loadDataTableInfo.LoadType, loadDataTableInfo.UserData))
                {
                    throw new GameFrameworkException(Utility.Text.Format("Load data table failure in helper, asset name '{0}'.", dataTableAssetName));
                }

                if (m_LoadDataTableSuccessEventHandler != null)
                {
                    LoadDataTableSuccessEventArgs loadDataTableSuccessEventArgs = LoadDataTableSuccessEventArgs.Create(dataTableAssetName, loadDataTableInfo.LoadType, duration, loadDataTableInfo.UserData);
                    m_LoadDataTableSuccessEventHandler(this, loadDataTableSuccessEventArgs);
                    ReferencePool.Release(loadDataTableSuccessEventArgs);
                }
            }
            catch (Exception exception)
            {
                if (m_LoadDataTableFailureEventHandler != null)
                {
                    LoadDataTableFailureEventArgs loadDataTableFailureEventArgs = LoadDataTableFailureEventArgs.Create(dataTableAssetName, loadDataTableInfo.LoadType, exception.ToString(), loadDataTableInfo.UserData);
                    m_LoadDataTableFailureEventHandler(this, loadDataTableFailureEventArgs);
                    ReferencePool.Release(loadDataTableFailureEventArgs);
                    return;
                }

                throw;
            }
            finally
            {
                ReferencePool.Release(loadDataTableInfo);
                m_DataTableHelper.ReleaseDataTableAsset(dataTableAsset);
            }
        }
Exemplo n.º 7
0
        private void LoadAssetOrBinaryFailureCallback(string dataTableAssetName, LoadResourceStatus status, string errorMessage, object userData)
        {
            LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData;

            if (loadDataTableInfo == null)
            {
                throw new GXException("Load data table info is invalid.");
            }

            string appendErrorMessage = Utility.Text.Format("Load data table failure, asset name '{0}', status '{1}', error message '{2}'.", dataTableAssetName, status.ToString(), errorMessage);

            if (m_LoadDataTableFailureEventHandler != null)
            {
                LoadDataTableFailureEventArgs loadDataTableFailureEventArgs = LoadDataTableFailureEventArgs.Create(dataTableAssetName, loadDataTableInfo.LoadType, appendErrorMessage, loadDataTableInfo.UserData);
                m_LoadDataTableFailureEventHandler(this, loadDataTableFailureEventArgs);
                ReferencePool.Release(loadDataTableFailureEventArgs);
                return;
            }

            throw new GXException(appendErrorMessage);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 加载数据表。
        /// </summary>
        /// <param name="dataTableAssetName">数据表资源名称。</param>
        /// <param name="loadType">数据表加载方式。</param>
        /// <param name="priority">加载数据表资源的优先级。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void LoadDataTable(string dataTableAssetName, LoadType loadType, int priority, object userData)
        {
            if (m_ResourceManager == null)
            {
                throw new GXException("You must set resource manager first.");
            }

            if (m_DataTableHelper == null)
            {
                throw new GXException("You must set data table helper first.");
            }

            LoadDataTableInfo loadDataTableInfo = LoadDataTableInfo.Create(loadType, userData);

            if (loadType == LoadType.TextFromAsset || loadType == LoadType.BytesFromAsset || loadType == LoadType.StreamFromAsset)
            {
                m_ResourceManager.LoadAsset(dataTableAssetName, priority, m_LoadAssetCallbacks, loadDataTableInfo);
            }
            else
            {
                m_ResourceManager.LoadBinary(dataTableAssetName, m_LoadBinaryCallbacks, loadDataTableInfo);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 加载数据表。
        /// </summary>
        /// <param name="dataTableAssetName">数据表资源名称。</param>
        /// <param name="loadType">数据表加载方式。</param>
        /// <param name="priority">加载数据表资源的优先级。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void LoadDataTable(string dataTableAssetName, LoadType loadType, int priority, object userData)
        {
            if (m_ResourceManager == null)
            {
                throw new GameFrameworkException("You must set resource manager first.");
            }

            if (m_DataTableHelper == null)
            {
                throw new GameFrameworkException("You must set data table helper first.");
            }

            m_ResourceManager.LoadAsset(dataTableAssetName, priority, m_LoadAssetCallbacks, LoadDataTableInfo.Create(loadType, userData));
        }
Exemplo n.º 10
0
 public void LoadDataTable(ResourceLoadInfo resourceLoadInfo, LoadDataTableInfo loadDataTableInfo)
 {
     dataTableManager.LoadDataTable(resourceLoadInfo, loadDataTableInfo);
 }