//---------------------------------------------------------------------
        public bool IsDone()
        {
            while (QueCopyFile.Count > 0 && MapWWW.Count < 5)
            {
                string s1 = QueCopyFile.Dequeue();
                var    s2 = CasinosContext.Instance.PathMgr.CombineWWWStreamingAssetsPath(s1);
                MapWWW[s1] = new WWW(s2);
            }

            foreach (var i in MapWWW)
            {
                if (!i.Value.isDone)
                {
                    continue;
                }
                ListFinished.Add(i.Key);

                var    str = CasinosContext.Instance.PathMgr.CombinePersistentDataPath(i.Key);
                string d   = Path.GetDirectoryName(str);
                if (!Directory.Exists(d))
                {
                    Directory.CreateDirectory(d);
                }

                using (FileStream fs = new FileStream(str, FileMode.Create))
                {
                    fs.Write(i.Value.bytes, 0, i.Value.bytes.Length);
                }

                i.Value.Dispose();
            }

            foreach (var i in ListFinished)
            {
                MapWWW.Remove(i);
            }
            ListFinished.Clear();

            if (!string.IsNullOrEmpty(DataFileListContent))
            {
                var f = CasinosContext.Instance.PathMgr.CombinePersistentDataPath("DataFileList.txt");
                File.WriteAllText(f, DataFileListContent);
            }

            LeftCount = QueCopyFile.Count;

            return(QueCopyFile.Count > 0 || MapWWW.Count > 0 ? false : true);
        }
Exemple #2
0
        //---------------------------------------------------------------------
        public bool IsDone()
        {
            while (QueUpdateFile.Count > 0 && MapWWW.Count < 5)
            {
                string          s1          = QueUpdateFile.Dequeue();
                var             s2          = Path.Combine(RemoteDataRootUrl, s1);
                UnityWebRequest web_request = UnityWebRequest.Get(s2);
                MapWWW[s1] = web_request;
                web_request.SendWebRequest();
            }

            foreach (var i in MapWWW)
            {
                if (!i.Value.isDone)
                {
                    continue;
                }

                ListFinished.Add(i.Key);

                var    str = PersistentDataRootDir + i.Key;
                string d   = Path.GetDirectoryName(str);
                if (!Directory.Exists(d))
                {
                    Directory.CreateDirectory(d);
                }

                using (FileStream fs = new FileStream(str, FileMode.Create))
                {
                    DownloadHandler dh = i.Value.downloadHandler;
                    fs.Write(dh.data, 0, dh.data.Length);
                }

                i.Value.Dispose();
            }

            foreach (var i in ListFinished)
            {
                MapWWW.Remove(i);
            }
            ListFinished.Clear();

            LeftCount = QueUpdateFile.Count;

            return(QueUpdateFile.Count > 0 || MapWWW.Count > 0 ? false : true);
        }
        //---------------------------------------------------------------------
        public bool IsDone()
        {
            while (QueUpdateFile.Count > 0 && MapWWW.Count < 5)
            {
                string s1 = QueUpdateFile.Dequeue();
                var    s2 = Path.Combine(RemoteDataRootUrl, s1);
                MapWWW[s1] = new WWW(s2);
            }

            foreach (var i in MapWWW)
            {
                if (!i.Value.isDone)
                {
                    continue;
                }
                ListFinished.Add(i.Key);

                var    str = RemoteDataRootDir + i.Key;
                string d   = Path.GetDirectoryName(str);
                if (!Directory.Exists(d))
                {
                    Directory.CreateDirectory(d);
                }

                using (FileStream fs = new FileStream(str, FileMode.Create))
                {
                    fs.Write(i.Value.bytes, 0, i.Value.bytes.Length);
                }

                i.Value.Dispose();
            }

            foreach (var i in ListFinished)
            {
                MapWWW.Remove(i);
            }
            ListFinished.Clear();

            LeftCount = QueUpdateFile.Count;

            return(QueUpdateFile.Count > 0 || MapWWW.Count > 0 ? false : true);
        }
Exemple #4
0
    //-------------------------------------------------------------------------
    public void update(float tm)
    {
        foreach (var i in MapWWW)
        {
            WWW www = i.Value;
            if (www != null)
            {
                if (www.isDone)
                {
                    MapWWWIsDone[i.Key] = i.Value;
                }
            }
        }

        foreach (var i in MapWWWIsDone)
        {
            MapWWW.Remove(i.Key);
            Action <string, WWW> ticketandcallback = null;
            if (MapLoaderTicketAndCallBack.TryGetValue(i.Key, out ticketandcallback))
            {
                ticketandcallback(i.Key, i.Value);
                MapLoaderTicketAndCallBack.Remove(i.Key);

                //foreach (var ticket in map_ticketandcallback)
                //{
                //    ticket.Value(i.Key, i.Value);
                //    ListCallBackDoneTicket.Add(ticket.Key);
                //}

                //foreach (var callback_done_ticket in ListCallBackDoneTicket)
                //{
                //    map_ticketandcallback[callback_done_ticket] = null;
                //}
                //ListCallBackDoneTicket.Clear();
            }
            i.Value.Dispose();
        }

        MapWWWIsDone.Clear();
    }