예제 #1
0
        public void Update(float deltaTime)
        {
            if (!IsStart)
            {
                return;
            }

            if (mCurLoader == null)
            {
                if (WebLoaders.Count > 0)
                {
                    mCurLoader = WebLoaders[0];
                    WebLoaders.RemoveAt(0);
                    mCurLoader.Start();
                    AlreadyLoaders.Add(mCurLoader);
                }
            }
            if (mCurLoader != null)
            {
                mCurLoader.Loop(deltaTime);
                if (mCurLoader.IsDone)
                {
                    mCurLoader.Close();
                    mCurLoader = null;
                }
            }
        }
예제 #2
0
 private void SingleLoading(HttpLoad loader)
 {
     try
     {
         OnSingleLoading?.Invoke(loader);
     }
     catch (Exception e)
     {
         App.Error(e);
     }
     AllLoading(loader);
 }
예제 #3
0
 public void UnloadAll()
 {
     WebLoaders.Clear();
     for (int i = 0; i < AlreadyLoaders.Count; i++)
     {
         HttpLoad oLoader = AlreadyLoaders[i];
         if (oLoader.IsStart)
         {
             oLoader.Close();
         }
         oLoader.Clear();
     }
 }
예제 #4
0
 public void LoadAll(HttpPaths[] dirs)
 {
     LoadNum   = dirs.Length;
     Urls      = new string[LoadNum];
     SavePaths = new string[LoadNum];
     for (int i = 0; i < dirs.Length; i++)
     {
         HttpPaths dir = dirs[i];
         Urls[i]      = dir.Url;
         SavePaths[i] = dir.SavePath;
         HttpLoad oLoader = new HttpLoad(Urls[i], SavePaths[i]);
         oLoader.SetEventLoading(SingleLoading);
         oLoader.SetEventLoaded(SingleLoaded);
         WebLoaders.Add(oLoader);
     }
 }
예제 #5
0
        private void SingleLoaded(HttpLoad loader)
        {
            if (!string.IsNullOrEmpty(loader.Error))
            {
                loader.Close(); // 下载失败则关闭
                Error = Error + "\n" + loader.Error;
            }
            OnSingleLoaded?.Invoke(loader);

            if (LoadIndex == LoadNum)
            {
                IsDone = true;
            }
            if (IsDone)
            {
                OnAllLoaded?.Invoke(this);
            }
        }
예제 #6
0
 private void AllLoading(HttpLoad loader)
 {
     try
     {
         SingleProgress = loader.Progress;
         mTotalProgress = LoadIndex + SingleProgress;
         FinalProgress  = mTotalProgress / LoadNum;
         if (loader.IsDone)
         {
             LoadIndex = LoadIndex + 1;
         }
         OnAllLoading?.Invoke(this);
     }
     catch (Exception e)
     {
         App.Error(e);
     }
     if (IsDone)
     {
         Close();
     }
 }
예제 #7
0
        public HttpLoad GetLoader(string url, string savePath)
        {
            HttpLoad oLoader = WebLoaders.Find((t) => { return(t.Url == url && t.SavePath == savePath); });

            return(oLoader);
        }