Exemplo n.º 1
0
    private async Task <bool> TryDownLoad(string url, string patchName)
    {
        WebClient wc = new WebClient();

        FileScaner.MakeDir(TempFolder);
        if (url == null || patchName == null)
        {
            return(false);
        }

        LogAdd("Try DownLoad [" + url + " ].");
        if (FileScaner.ChkFile(TempFolder + patchName))
        {
            LogAdd("Archive Found. Skip Download.");
        }
        else
        {
            try
            {
                await wc.DownloadFileTaskAsync(new Uri(url), TempFolder + patchName);

                LogAdd("Download OK.");
            }
            catch (WebException we)
            {
                Debug.LogWarning("Error WebException : " + we.Status);
                FileScaner.RemoveFile(TempFolder + patchName);
                return(false);
            }
        }
        return(true);
    }
Exemplo n.º 2
0
    /// <summary>
    /// アイテムセット(Json)を読み込みます。Itemsの画像パスを絶対パスに書き換えます。
    /// </summary>
    /// <param name="path">Jsonファイルの保存ディレクトリパス</param>
    /// <param name="jsonFileName">Jsonのファイル名(例:config.json)</param>
    public void LoadFromJson(string path, string jsonFileName) // itemsに登録
    {
        UnityEngine.Debug.Log("Load Json as " + path + jsonFileName);
        if (!FileScaner.ChkFile(path + jsonFileName))
        {
            return;
        }
        string json;

        try
        {
            using (Stream stm = new FileStream(path + jsonFileName, FileMode.Open))
                using (StreamReader read = new StreamReader(stm, System.Text.Encoding.UTF8))
                {
                    json = read.ReadToEnd();
                }
        }
        catch { return; }
        json.Replace('/', '\\');

        var load = new List <Items>(JsonUtility.FromJson <RootItems>(json).Items);

        foreach (var v in load)
        {
            v.ImagePath = path + v.ImagePath;
        }
        items.AddRange(load);
        UnityEngine.Debug.Log("Loaded [" + load.Count + "] Items From Json.");
    }
Exemplo n.º 3
0
    /// <summary>
    /// インストール済みパッケージリストを取得します。
    /// </summary>
    public string[] GetInstalledPatches()
    {
        List <string> list = new List <string>();

        foreach (string s in FileScaner.GetFolders(LocalPath + PATCH_DIRECTRY))
        {
            list.Add(s.Replace(LocalPath + PATCH_DIRECTRY, "").Trim());
        }
        return(list.ToArray());
    }
Exemplo n.º 4
0
    private void StartQuestion() // 問題を出力します。
    {
        quizCount++;
        if (selectedItem == null)
        {
            selectedItem = piQuiz.GetItem();
        }

        if (PiQuizOpener.GameMode == PiQuizOpener.Mode.ScoreAttack)
        {
            if (quizCount > PiQuizOpener.QuestionSize)
            {
                FinishGame();
                return;
            }
        }

        if (!FileScaner.ChkFile(selectedItem.ImagePath))
        {
            if (tryNullCount < 10)
            {
                Debug.LogWarning("Error. No File." + selectedItem.ImagePath);
                selectedItem = piQuiz.GetItem();
                tryNullCount++;
            }
        }

        rawImage.color    = new Color(-0.2f, -0.2f, -0.2f);
        rawImage.texture  = FileUniTexture.PNGToUniTex(selectedItem.ImagePath);
        startQuestionTime = piQuiz.stopWatch.ElapsedMilliseconds;
        piQuiz.stopWatch.Start();

        acceptAnswer = true;
        if (IsMulti)
        {
            if (acceptAnswerPlayer == null)
            {
                acceptAnswerPlayer = new bool[PlayerNameOnMulti.Length];
            }
            for (int i = 0; i < acceptAnswerPlayer.Length; i++)
            {
                acceptAnswerPlayer[i] = true;
            }
        }

        updateAction += GameRunning;

        if (IsMulti)
        {
            if (PlayerNameOnMulti.Length >= 3)
            {
                SetRundomRotate(rawImage.rectTransform);
            }
        }
    }
Exemplo n.º 5
0
 /// <summary>
 /// 指定したパッチ(名)をアンインストールします。
 /// </summary>
 /// <returns>True:成功 False:失敗。ファイルが存在しない場合があります。</returns>
 public bool UnInstallPatch(Patch target)
 {
     try
     {
         LogAdd("Uninstall Package [" + target.PatchName + "]");
         FileScaner.RemoveFolder(PatchFolder + target.PatchName);
         FileScaner.RemoveFile(TempFolder + target.PatchName);
     }
     catch { return(false); }
     return(true);
 }
Exemplo n.º 6
0
    /// <summary>
    /// パッチをインストールします。インストール済みの場合スキップされ True が返されます。
    /// </summary>
    public async Task <bool> InstallPatch(Patch target)
    {
        int tryCount = 0;

TryAgain:

        if (!await TryDownLoad(target.Url, target.PatchName))
        {
            if (!await TryDownLoad(target.SubUrl, target.PatchName))
            {
                return(false);
            }
        }

        LogAdd("Try UnZip [" + target.PatchName + "].");

        if (FileScaner.MakeDir(PatchFolder + target.PatchName))
        {
            try
            {
                ZipFile.ExtractToDirectory(TempFolder + target.PatchName, PatchFolder + target.PatchName, Encoding.UTF8);
                LogAdd("UnZip OK.");
            }
            catch (Exception e)
            {
                Debug.LogWarning("Error Exception : " + e);
                return(false);
            }
        }
        else
        {
            int installedFileCount = FileScaner.GetCountInFolder(PatchFolder + target.PatchName);
            LogAdd("Skip unpack. Installed [" + installedFileCount + "] Files.");
            if (target.FileCount != 0 && target.FileCount != installedFileCount) // インストール済みの数が異なる
            {
                LogAdd("Different File Error. Correct [" + target.FileCount + "] Files. Try Again.");
                UnInstallPatch(target);

                if (tryCount == 0)
                {
                    tryCount++;
                    goto TryAgain;
                }
                else
                {
                    return(false);
                }
            }
        }

        InstalledPatch.Add(target);
        return(true);
    }
Exemplo n.º 7
0
    /// <summary>
    /// 指定したパッチは既にインストール済みかを確認します。
    /// </summary>
    private bool ChackInstalledPatch(Patch target)
    {
        if (!FileScaner.ChkFile(TempFolder + target.PatchName))
        {
            return(false);
        }
        int installedFileCount = FileScaner.GetCountInFolder(PatchFolder + target.PatchName);

        LogAdd("Skip unpack. Installed [" + installedFileCount + "] Files.");
        if (target.FileCount != 0 && target.FileCount != installedFileCount)
        {
            return(false);                                                                 // インストール済みの数が異なる
        }
        return(true);
    }
Exemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        FileScaner scan = new FileScaner();

        SyncManager sy = new SyncManager(@"S:\TEST\After");

        string[] ss;
        foreach (string s in sy.GetNoSyncList(@"S:\TEST\Before", out ss))
        {
            Debug.Log(s);
        }
        foreach (string s in ss)
        {
            Debug.Log("Over:" + s);
        }
    }