Ejemplo n.º 1
0
    public void Begin(int p, string url)
    {
        mVersion = p;
        int v = PlayerPrefs.GetInt("UnPackVersion", 0);

        if (mVersion > v)
        {
            TextAsset ta = (TextAsset)Resources.Load("Game");

            using (MemoryStream ms = new MemoryStream(ta.bytes))
            {
                ZipStorer zip = ZipStorer.Open(ms, FileAccess.Read);
                List <ZipStorer.ZipFileEntry> dir = zip.ReadCentralDir();
                foreach (ZipStorer.ZipFileEntry entry in dir)
                {
                    string outPath = Application.persistentDataPath + "/" + entry.FilenameInZip;
                    zip.ExtractFile(entry, outPath);
                }
                zip.Close();
            }
            PlayerPrefs.SetInt("UnPackVersion", mVersion);
            GameObject dGo = new GameObject("Downloader");
            mDownloader = dGo.AddComponent <PatcherDownloader>();
            mDownloader.BeginDownload(url, delegate(PatcherElem e)
            {
                mCurElems = e;
                GameObject.Destroy(dGo);
                mDownloader = null;
            });
        }
    }
Ejemplo n.º 2
0
        public static PatcherElem DeSerialize(string txt)
        {
            PatcherElem ret = Json.Deserialize <PatcherElem>(txt);

            ret.CreatDic();
            return(ret);
        }
Ejemplo n.º 3
0
    void LoadLocalPatcher(System.Action <PatcherElem> onfinish)
    {
        string      path    = Application.dataPath + "/Patcher/ABs/" + GetABsPath(RuntimePlatform.WindowsPlayer) + "/Pather";
        string      content = File.ReadAllText(path);
        PatcherElem e       = Json.Deserialize <PatcherElem>(content);

        if (null != onfinish)
        {
            onfinish(e);
        }
    }
Ejemplo n.º 4
0
        List <PatcherElem.Elem> Compare(PatcherElem elem)
        {
            List <PatcherElem.Elem> ret = new List <Elem>();

            foreach (var d in elem.mDic)
            {
                if (IsChange(d.Value))
                {
                    ret.Add(d.Value);
                }
            }
            return(ret);
        }
Ejemplo n.º 5
0
 public void BeingDownload(string url, bool debug, System.Action onfinish, System.Action <string> onerror)
 {
     mOnError = onerror;
     if (!debug)
     {
         GameObject dGo = new GameObject("Downloader");
         mDownloader = dGo.AddComponent <PatcherDownloader>();
         mDownloader.BeginDownload(url, delegate(PatcherElem e)
         {
             mCurElems        = e;
             mCurElems.mDebug = false;
             if (null != dGo)
             {
                 GameObject.Destroy(dGo);
             }
             mDownloader = null;
             if (null != onfinish)
             {
                 onfinish();
             }
         }, onerror);
     }
     else
     {
         LoadLocalPatcher(delegate(PatcherElem e)
         {
             mCurElems        = e;
             mCurElems.mDebug = true;
             mDownloader      = null;
             if (null != onfinish)
             {
                 onfinish();
             }
         }
                          );
     }
 }