Esempio n. 1
0
 /// <summary>
 /// Checks the file list.
 /// </summary>
 public IEnumerator CheckFileList()
 {
     if (!downloadInProgress)
     {
         LogGenerator.GenerateDownloadLog("File List Download started...");
         vFile = new WWW(FileListUrl);
         while (!vFile.isDone)
         {
             downloadInProgress      = true;
             progressFill.fillAmount = vFile.progress;
             DownloadStatus          = LocalizationManager.LangStrings [8];
             yield return(null);
         }
         if (!string.IsNullOrEmpty(vFile.error))
         {
             LogGenerator.GenerateDownloadLog(vFile.text + vFile.error);
             Debug.Log(vFile.text + vFile.error);
             LogGenerator.GenerateDownloadLog(vFile.text + vFile.error);
             DownloadStatus = vFile.text + vFile.error;
         }
         else
         {
             downloadInProgress = false;
             Debug.Log("File List Downloaded.");
             LogGenerator.GenerateDownloadLog("File List Downloaded.");
             File.WriteAllBytes(Application.dataPath + "/vT.flamacore", vFile.bytes);
             DownloadStatus = LocalizationManager.LangStrings [9];
             CompareFileList();
             progressFill.fillAmount = 0;
         }
     }
 }
Esempio n. 2
0
    /// <summary>
    /// Compares files with the file list at the server.
    /// </summary>
    public void CompareFileList()
    {
        string pth = Application.dataPath;

#if UNITY_EDITOR
        pth += "/..";
#endif
        string        filePath  = pth + "/" + GameName + "/";
        string        filePath2 = pth + "/v.thln";
        string[]      Files     = null;
        List <byte[]> bts       = new List <byte[]>();
        try
        {
            Files = Directory.GetFiles(filePath, "*.*", SearchOption.AllDirectories);
            for (int i = 0; i < Files.Length; i++)
            {
                bts.Add(File.ReadAllBytes(Files[i]));
            }
        }
        catch (DirectoryNotFoundException)
        {
            return;
        }
        if (File.Exists(filePath2))
        {
            FileStream fs = new FileStream(filePath2, FileMode.Truncate, FileAccess.Write);
            fs.Close();
        }
        StreamWriter writer = new StreamWriter(filePath2, true);
        for (int i = 0; i < Files.Length; i++)
        {
            //Debug.Log(Files[i]);
            if (!Files[i].Substring(filePath.Length).Contains("output_log"))
            {
                if (Files[i].Substring(filePath.Length).Contains(GameName) || Files[i].Substring(filePath.Length).Contains("Unity") || Files[i].Substring(filePath.Length).Contains("Mono"))
                {
                    writer.WriteLine(Encrypt.EncryptRJ256(Files[i].Substring(filePath.Length) + ":" + bts[i].Length), true);
                }
            }
        }
        writer.Close();
        string[] lines     = File.ReadAllLines(pth + "/v.thln");
        string[] lines2    = File.ReadAllLines(pth + "/vT.thln");
        bool     filesGood = lines.SequenceEqual(lines2);
        if (!filesGood)
        {
            gameDownloaded = false;
            Debug.Log("File integrity problem. Needs redownload.");
            LogGenerator.GenerateDownloadLog("File integrity problem. Needs redownload.");
            DownloadStatus = LocalizationManager.LangStrings[11];
        }
        else
        {
            updateRequired = false;
            gameDownloaded = true;
            Debug.Log("File Check Complete.");
            LogGenerator.GenerateDownloadLog("File Check Complete.");
            DownloadStatus = LocalizationManager.LangStrings[10];
        }
    }
Esempio n. 3
0
 /// <summary>
 /// Gets the version file.
 /// </summary>
 public IEnumerator GetVersionFile()
 {
     if (!downloadInProgress)
     {
         LogGenerator.GenerateDownloadLog("Version File Download started...");
         versionFile = new WWW(versionFileUrl);
         while (!versionFile.isDone)
         {
             downloadInProgress      = true;
             progressFill.fillAmount = versionFile.progress;
             DownloadStatus          = LocalizationManager.LangStrings [0];
             yield return(null);
         }
         if (!string.IsNullOrEmpty(versionFile.error))
         {
             LogGenerator.GenerateDownloadLog(versionFile.text + versionFile.error);
             Debug.Log(versionFile.text + versionFile.error);
         }
         else
         {
             downloadInProgress = false;
             Debug.Log("Version File Downloaded.");
             LogGenerator.GenerateDownloadLog("Version File Downloaded.");
             File.WriteAllBytes(Application.dataPath + "/version.flamacore", versionFile.bytes);
             string[] lines = File.ReadAllLines(Application.dataPath + "/version.flamacore");
             currentVer     = lines [4];
             DownloadStatus = LocalizationManager.LangStrings [1];
             StartCoroutine(CheckFileList());
             progressFill.fillAmount = 0;
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Starts the download.
 /// </summary>
 public IEnumerator StartDownload()
 {
     if (!downloadInProgress)
     {
         string totalSize          = "";
         System.Net.WebRequest req = System.Net.HttpWebRequest.Create(HTTPGameFileLocation + "upload_" + currentVer + ".flamacore");
         req.Method = "HEAD";
         using (System.Net.WebResponse resp = req.GetResponse())
         {
             long ContentLength;
             if (long.TryParse(resp.Headers.Get("Content-Length"), out ContentLength))
             {
                 totalSize = GetBytesReadable(ContentLength);
             }
         }
         DownloadStatus = LocalizationManager.LangStrings [5];
         LogGenerator.GenerateDownloadLog("Download started: " + HTTPGameFileLocation + "upload_" + currentVer + ".flamacore");
         CompFileToDownload = new WWW(HTTPGameFileLocation + "upload_" + currentVer + ".flamacore");
         while (!CompFileToDownload.isDone)
         {
             downloadInProgress      = true;
             progressFill.fillAmount = CompFileToDownload.progress;
             DownloadProgress        = (CompFileToDownload.progress * 100).ToString("F2") + "%/100% --- " + totalSize;
             yield return(null);
         }
         DownloadProgress        = (CompFileToDownload.progress * 100).ToString("F2") + "%/100% --- " + totalSize;
         progressFill.fillAmount = CompFileToDownload.progress;
         if (!string.IsNullOrEmpty(CompFileToDownload.error))
         {
             Debug.Log(CompFileToDownload.text + CompFileToDownload.error);
         }
         else
         {
             downloadInProgress = false;
             LogGenerator.GenerateDownloadLog("Download done.");
             Debug.Log("done");
             File.WriteAllBytes(Application.dataPath + "/upload_" + currentVer + ".flamacore", CompFileToDownload.bytes);
             downloadInProgress      = true;
             progressFill.fillAmount = 0;
             string pth = Application.dataPath;
             //Decompressor.DecompressToDirectory (pth + "/upload_" + currentVer + ".flamacore", pth + "/" + GameName + "/");
             t2_ = new Thread(() => Decompressor.DecompressToDirectory(pth + "/upload_" + currentVer + ".flamacore", pth + "/" + GameName + "/"));
             if (!t2_.IsAlive)
             {
                 t2_.Start();
             }
             LogGenerator.GenerateLog("Decompression Thread Launched");
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Starts download Coroutine.
 /// </summary>
 public void StartMe()
 {
     if (startButtonText.text == LocalizationManager.LangStrings [4])
     {
                     #if UNITY_STANDALONE_WIN
         System.Diagnostics.Process.Start(Application.dataPath + "/" + GameName + "/" + GameName + ".exe", "hac4e7kjahf93zdv");
                     #endif
                     #if UNITY_STANDALONE
         System.Diagnostics.Process.Start(Application.dataPath + "/" + GameName + "/" + GameName + ".app", "hac4e7kjahf93zdv");
                     #endif
     }
     if (startButtonText.text == LocalizationManager.LangStrings [3])
     {
         System.IO.Directory.CreateDirectory(Application.dataPath + "/" + GameName + "/");
         LogGenerator.GenerateDownloadLog("Begin Application");
         StartCoroutine(StartDownload());
     }
 }
Esempio n. 6
0
    /// <summary>
    /// Compares files with the file list at the server.
    /// </summary>
    public void CompareFileList()
    {
        string filePath  = Application.dataPath + "/" + GameName + "/";
        string filePath2 = Application.dataPath + "/v.flamacore";

        string[] Files = null;
        try{
            Files = Directory.GetFiles(filePath, "*.*", SearchOption.AllDirectories);
        }
        catch (DirectoryNotFoundException) {
            return;
        }
        if (File.Exists(filePath2))
        {
            FileStream fs = new     FileStream(filePath2, FileMode.Truncate, FileAccess.Write);
            fs.Close();
        }
        StreamWriter writer = new StreamWriter(filePath2, true);

        foreach (string file in Files)
        {
            writer.WriteLine(Encrypt.EncryptRJ256(file.Substring(filePath.Length)), true);
        }
        writer.Close();
        string[] lines     = File.ReadAllLines(Application.dataPath + "/v.flamacore");
        string[] lines2    = File.ReadAllLines(Application.dataPath + "/vT.flamacore");
        bool     filesGood = lines.SequenceEqual(lines2);

        if (!filesGood)
        {
            gameDownloaded = false;
            Debug.Log("File integrity problem. Needs redownload.");
            LogGenerator.GenerateDownloadLog("File integrity problem. Needs redownload.");
            DownloadStatus = LocalizationManager.LangStrings [11];
        }
        else
        {
            updateRequired = false;
            gameDownloaded = true;
            Debug.Log("File Check Complete.");
            LogGenerator.GenerateDownloadLog("File Check Complete.");
            DownloadStatus = LocalizationManager.LangStrings [10];
        }
    }
Esempio n. 7
0
    /// <summary>
    /// Gets news text from a page. Reads the WWW.text property directly.
    /// Can be formatted using Unity's rich text formatting options.
    /// </summary>
    public IEnumerator GetNewsText()
    {
        LogGenerator.GenerateDownloadLog("Getting News Text");
        WWW news = new WWW(newsTextUrl);

        yield return(news);

        if (!string.IsNullOrEmpty(news.error))
        {
            LogGenerator.GenerateDownloadLog(news.text + news.error);
            Debug.Log(news.text + news.error);
            newsText.text = news.text + news.error;
        }
        else
        {
            Debug.Log("Got the news text.");
            LogGenerator.GenerateDownloadLog("Got the news text.");
            newsText.text = news.text;
        }
    }
Esempio n. 8
0
    /// <summary>
    /// Starts download Coroutine.
    /// </summary>
    public void StartMe()
    {
        if (startButtonText.text == LocalizationManager.LangStrings[4])
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();

#if UNITY_EDITOR
            Debug.Log(Application.dataPath + "/../" + GameName + "/" + GameName + ".exe");
            process.StartInfo.FileName         = Application.dataPath + "/../" + GameName + "/" + GameName + ".exe";
            process.StartInfo.Arguments        = "hac4e7kjahf93zdv";
            process.StartInfo.WorkingDirectory = Application.dataPath + "/../" + GameName + "/";
            process.Start();
#endif
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
            Debug.Log(Application.dataPath + "/" + GameName + "/" + GameName + ".exe");
            process.StartInfo.FileName         = Application.dataPath + "/" + GameName + "/" + GameName + ".exe";
            process.StartInfo.Arguments        = "hac4e7kjahf93zdv";
            process.StartInfo.WorkingDirectory = Application.dataPath + "/../" + GameName + "/";
            process.Start();
#endif
#if UNITY_STANDALONE_MAC && !UNITY_EDITOR
            process.StartInfo.FileName         = Application.dataPath + "/" + GameName + "/" + GameName + ".app";
            process.StartInfo.Arguments        = "hac4e7kjahf93zdv";
            process.StartInfo.WorkingDirectory = Application.dataPath + "/../" + GameName + "/";
            process.Start();
#endif
        }
        if (startButtonText.text == LocalizationManager.LangStrings[3])
        {
            string pth = Application.dataPath;
#if UNITY_EDITOR
            pth += "/..";
#endif
            System.IO.Directory.CreateDirectory(pth + "/" + GameName + "/");
            LogGenerator.GenerateDownloadLog("Begin Application");
            StartCoroutine(StartDownload());
        }
    }