예제 #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);
    }
예제 #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.");
    }
예제 #3
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);
            }
        }
    }
예제 #4
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);
    }