Пример #1
0
    public static void initialize(string path)
    {
        Config.path = path;
        string folder = ShaCache.ToContaingFolder(path);

        if (!Directory.Exists(folder))
        {
            Directory.CreateDirectory(folder);
        }
        if (File.Exists(path) == false)
        {
            File.Create(path).Close();
        }
        string txtString = File.ReadAllText(path);

        string[] lines = txtString.Replace("\r", "").Split("\n");
        for (int i = 0; i < lines.Length; i++)
        {
            if (!lines[i].Contains("->"))
            {
                continue;
            }
            string[] mats = lines[i].Split("->");
            if (mats.Length == 2)
            {
                oneString s = new oneString();
                s.original   = mats[0];
                s.translated = mats[1];
                translations.Add(s);
            }
        }
    }
Пример #2
0
    private void DownloadGitFile(string id, GitNode file, string folderPath)
    {
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            throw new Exception("Internet error");
        }
        GitFile download = RequestFromGit <GitFile>(id, file.path);

        byte[] bytes        = Convert.FromBase64String(download.content);
        string downloadFile = Path.Combine(folderPath, file.path);
        string downloadDir  = ShaCache.ToContaingFolder(downloadFile);

        if (!Directory.Exists(downloadDir))
        {
            Directory.CreateDirectory(downloadDir);
        }
        File.WriteAllBytes(downloadFile, bytes);
        localSha.UpdateInsertCache(downloadFile, file.id);
    }
Пример #3
0
    IEnumerator Download(string url, string targetFile)
    {
        WWW request = new WWW(url);

        while (!request.isDone)
        {
            yield return(null);
        }
        string folder = ShaCache.ToContaingFolder(targetFile);

        if (!Directory.Exists(folder))
        {
            Directory.CreateDirectory(folder);
        }
        if (request.error == null || request.error == "")
        {
            File.WriteAllBytes(targetFile, request.bytes);
        }
        if (DownloadCardCompleted != null)
        {
            DownloadCardCompleted(this, null);
        }
    }
Пример #4
0
    void initialize()
    {
        go(1, () =>
        {
            UIHelper.iniFaces();
            initializeALLcameras();
            fixALLcamerasPreFrame();
            backGroundPic = new BackGroundPic();
            servants.Add(backGroundPic);
            backGroundPic.fixScreenProblem();
        });
        go(300, () =>
        {
            Config.initialize("Assets/essential/config/config.conf");
            localSha = new ShaCache();
            try
            {
                UpdateClient("Assets/essential/cdb/", cdbID);
                UpdateClient("Assets/essential/config/", configID);
            }
            catch
            {
                // TODO: I would like to log to the chat log but that doesn't get initalized till initializeALLservants
                // book.add("Auto Update Failed...\nCheck your network connection and relaunch the game...");
            }

            InterString.initialize("Assets/essential/config/translation.conf");
            InterString.initialize("Assets/essential/config" + AppLanguage.LanguageDir() + "/translation.conf");   //System Language
            GameTextureManager.initialize();
            GameStringManager.initialize("Assets/essential/config/strings.conf");
            if (File.Exists("Assets/essential/config/strings.conf"))
            {
                GameStringManager.initialize("Assets/essential/config/strings.conf");
            }

            if (File.Exists("expansions/strings.conf"))
            {
                GameStringManager.initialize("expansions/strings.conf");
            }

            YGOSharp.BanlistManager.initialize("Assets/essential/config/lflist.conf");
            if (File.Exists("expansions/lflist.conf"))
            {
                YGOSharp.BanlistManager.initialize("expansions/lflist.conf");
            }
            FileInfo[] fileInfos;

            if (Directory.Exists("expansions"))
            {
                fileInfos = (new DirectoryInfo("expansions")).GetFiles().Where(x => x.Extension == ".cdb").OrderBy(x => x.Name).ToArray();
                if (Directory.Exists("expansions" + AppLanguage.LanguageDir()))
                {
                    fileInfos = (new DirectoryInfo("expansions" + AppLanguage.LanguageDir())).GetFiles().Where(x => x.Extension == ".cdb").OrderBy(x => x.Name).ToArray();
                }

                for (int i = 0; i < fileInfos.Length; i++)
                {
                    if (fileInfos[i].Name.Length > 4)
                    {
                        if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".cdb")
                        {
                            YGOSharp.CardsManager.initialize("expansions/" + fileInfos[i].Name);
                            YGOSharp.CardsManager.initialize("expansions" + AppLanguage.LanguageDir() + "/" + fileInfos[i].Name);
                        }
                    }
                }
            }

            fileInfos = (new DirectoryInfo("Assets/essential/cdb")).GetFiles().OrderByDescending(x => x.Name).ToArray();
            for (int i = 0; i < fileInfos.Length; i++)
            {
                if (fileInfos[i].Name.Length > 4)
                {
                    if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".cdb")
                    {
                        YGOSharp.CardsManager.initialize("Assets/essential/cdb/" + fileInfos[i].Name);
                        YGOSharp.CardsManager.initialize("Assets/essential/cdb" + AppLanguage.LanguageDir() + "/" + fileInfos[i].Name);//System Language
                    }
                }
            }

            fileInfos = (new DirectoryInfo("Assets/essential/pack")).GetFiles();
            fileInfos = (new DirectoryInfo("Assets/essential/pack" + AppLanguage.LanguageDir())).GetFiles();
            for (int i = 0; i < fileInfos.Length; i++)
            {
                if (fileInfos[i].Name.Length > 3)
                {
                    if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 3, 3) == ".db")
                    {
                        YGOSharp.PacksManager.initialize("Assets/essential/pack/" + fileInfos[i].Name);
                        YGOSharp.PacksManager.initialize("Assets/essential/pack" + AppLanguage.LanguageDir() + "/" + fileInfos[i].Name);
                    }
                }
            }

            YGOSharp.PacksManager.initializeSec();
            initializeALLservants();
            loadResources();
        });
    }