示例#1
0
 /// <summary>
 /// 创建一个 下载节点;
 /// </summary>
 /// <param name="exData">追加内容,对应类型解;</param>
 public DownLoadPack(string strUrl, DownLoadAssetInfo downLoadInfo, DownLoadAssetType assetType, DownLoadCallBack funCallBack, object exData, bool debugError)
 {
     m_DownLoadAssetInfo = downLoadInfo;
     m_AssetType         = assetType;
     m_CallBack          = funCallBack;
     m_exData            = exData;
     m_strUrl            = strUrl;
     m_AssetRefer        = 1;
     m_DebugError        = debugError;
 }
示例#2
0
 static public void InsertDownLoadImmediate(string strName, string strURL, DownLoadAssetType assetType, Callback <object> callBack, object exData, bool debugError)
 {
     AddDownLoadAssetPack(strName, strURL, assetType, callBack, exData, debugError);
     if (m_AssetPackNameList.Contains(strName))            //重复情况,重新插入队首;
     {
         m_AssetPackNameList.Remove(strName);
         Debug.LogError("WWWDownLoader InsertDownLoadImmediate, Something Error, Has Same :" + strName);
     }
     m_AssetPackNameList.Insert(0, strName);
     StartAll();
 }
示例#3
0
        /// <summary>
        /// 下载任务;
        /// </summary>
        /// <param name="strName">资源唯一key;</param>
        /// <param name="strURL">资源下载完整URL(包含资源名,由外部组合. 不包含服务器IP地址)</param>
        /// <param name="assetType">资源类型;</param>
        /// <param name="callBack">外部的回调;</param>
        /// <param name="exData">附加信息(音效提取有附加参数);</param>
        static public DownLoadPack InsertDownLoad(string strName, string strURL, DownLoadAssetType assetType, Callback <object> callBack, object exData, DownLoadOrderType downLoadOrderType, bool debugError)
        {
            DownLoadPack pack = null;

            if (!m_IgnoreDownLoad)
            {
                pack = AddDownLoadAssetPack(strName, strURL, assetType, callBack, exData, debugError);

                switch (downLoadOrderType)
                {
                case DownLoadOrderType.Head:
                {
                    if (m_AssetPackNameList.Contains(strName))                                    //重复情况,重新插入队首;
                    {
                        m_AssetPackNameList.Remove(strName);
                    }
                    m_AssetPackNameList.Insert(0, strName);
                }
                break;

                case DownLoadOrderType.AfterRunning:
                {
                    int          nIndex     = 0;                        //第一个等待下载的资源索引;
                    DownLoadPack curResPack = null;

                    for (nIndex = 0; nIndex < m_AssetPackNameList.Count; nIndex++)
                    {
                        if (m_AssetPackMap.ContainsKey(strName))
                        {
                            DownLoadPack gtPack = m_AssetPackMap[m_AssetPackNameList[nIndex]];
                            if (gtPack == null)
                            {
                                Debug.LogWarning("WWWDownLoader InsertDownLoadToWaittingBegin, gtPack can not be null.");
                                continue;
                            }
                            else
                            {
                                //获取第一个等待下载的资源的索引;
                                if (gtPack.State == AssetState.Waitting || gtPack.State == AssetState.HasRelease)
                                {
                                    break;
                                }

                                //从下载队列里面获取目标资源;
                                if (gtPack.AssetInfo.m_strName.Equals(strName))
                                {
                                    curResPack = gtPack;
                                }
                            }
                        }
                    }

                    if (curResPack == null || curResPack.State != AssetState.DownLoading)
                    {
                        if (m_AssetPackNameList.Contains(strName))
                        {
                            m_AssetPackNameList.Remove(strName);
                        }
                        m_AssetPackNameList.Insert(nIndex, strName);
                    }
                }
                break;

                default:
                    Debug.LogError("WWWDownLoader InsertDownLoad, error name : " + strName + " ,downLoadOrderType: " + downLoadOrderType);
                    break;
                }

                if (m_IsShowTipsBox)
                {
                    m_WaittingAssetPackList.Add(strName);
                    Messenger <Callback, Callback> .Broadcast(MessangerEventDef.DOWNLOAD_MOBILE_TIPSBOX, TipBoxCallBackYes, TipBoxCallBackNo);
                }
                else
                {
                    StartAll();
                }
            }

            return(pack);
        }
示例#4
0
 static public DownLoadPack InsertDownLoad(string strName, string strURL, DownLoadAssetType assetType, Callback <object> callBack, object exData, DownLoadOrderType downLoadOrderType)
 {
     return(InsertDownLoad(strName, strURL, assetType, callBack, exData, downLoadOrderType, false));
 }
示例#5
0
        static private DownLoadPack AddDownLoadAssetPack(string strName, string strURL, DownLoadAssetType assetType, Callback <object> callBack, object exData, bool debugError)
        {
            DownLoadPack gtAssetPack = null;

            if (m_AssetPackMap.ContainsKey(strName))            //如果存在上一个if的情况,此步等同于下载不销毁,重置回调 or 正常流程重复请求;
            {
                gtAssetPack = m_AssetPackMap[strName];
                if (gtAssetPack != null)
                {
                    gtAssetPack.AssetInfo.m_callBack += callBack;
                    gtAssetPack.m_AssetRefer++;
                }
            }
            else
            {
                DownLoadAssetInfo gtInfo = null;
                if (assetType == DownLoadAssetType.ConfigVersion)                //配置文件 特殊处理;
                {
                    gtInfo           = new DownLoadAssetInfo();
                    gtInfo.m_strName = strName;
                }
                else
                {
                    gtInfo = WWWDownLoaderConfig.GetAssetDownLoadInfo(strName);
                }

                if (gtInfo == null)
                {
                    Debug.LogError("WWWLoader LoadAsset, DownLoadInfo can not be null. \n" + strName);
                }
                else
                {
                    gtInfo.m_callBack   = callBack;
                    gtInfo.m_strFileUrl = strURL;                    //for组装下载路径 and 保存路径;

                    //gtAssetPack = new DownLoadPack(m_strWWWDownLoadUrl, gtInfo, assetType, DownLoadFinish, exData, debugError);
                    gtAssetPack = new DownLoadPack(m_strWWWDownLoadUrl, gtInfo, assetType, null, exData, debugError);

                    m_AssetPackMap.Add(strName, gtAssetPack);
                }
            }

            return(gtAssetPack);
        }