Beispiel #1
0
    private void OnDownloadState(GameAsyncResInfo resInfo, GameResDownloadState state, float progress, int downloadSize)
    {
        if (resInfo != null)
        {
            FTDebug.LogWarning($"SingleAsnycRes Download State [{resInfo.bundleName}] [{state}] [{progress}] [{downloadSize}]");
        }
        if (state == GameResDownloadState.SUCCESS && resInfo != null)
        {
            GameAsyncRes.OnAsyncResDownloadSuccess(resInfo.bundleName);
        }
        var iState = (int)state;

        if (_onDownloadState != null)
        {
            _onDownloadState(iState, progress, downloadSize);
        }
        if (_downloadEvent != null)
        {
            if (_isDetailEvent || iState >= (int)GameResDownloadState.SUCCESS || iState != _lastEventState)
            {
                _downloadEvent(iState, progress, downloadSize);
                _lastEventState = iState;
            }
        }
        if (state == GameResDownloadState.SUCCESS || state == GameResDownloadState.FAILED)
        {
            _onDownloadState = null;
        }
    }
Beispiel #2
0
    private void OnDownloadState(GameAsyncResInfo resInfo, GameResDownloadState state, int curIndex, int totalCount, int curDownloadSize, int downloadedSize, int totalSize)
    {
        switch (state)
        {
        case GameResDownloadState.SUCCESS:
        {
            if (curIndex >= totalCount)
            {
                if (_onDownloadState != null && !isPaused)
                {
                    _onDownloadState(resInfo != null ? resInfo.bundleName : "", (int)GameResDownloadState.SUCCESS, curIndex, totalCount, curDownloadSize, downloadedSize, totalSize);
                }

                // 全部下载完成
                Clear();
            }
        }
        break;

        case GameResDownloadState.FAILED:
        {
            if (_onDownloadState != null && !isPaused)
            {
                _onDownloadState(resInfo != null ? resInfo.bundleName : "", (int)GameResDownloadState.FAILED, curIndex, totalCount, curDownloadSize, downloadedSize, totalSize);
            }
        }
        break;

        default:
        {
            if (_onDownloadState != null && !isPaused)
            {
                if (_isDetail || _lastDownloadIndex != curIndex)
                {
                    _onDownloadState(resInfo != null ? resInfo.bundleName : "", (int)GameResDownloadState.DOWNLOADING, curIndex, totalCount, curDownloadSize, downloadedSize, totalSize);
                    _lastDownloadIndex = curIndex;
                }
            }
        }
        break;
        }
    }