示例#1
0
        /**
         * 回答
         */
        public void AnswerChoice(int choiceNo)
        {
            Debug.Log("回答時間制限オーバー");
            if (choiceNo == TIME_OVER)
            {
                inCorrectAnswerExpression();
            }
            else
            {
                StopCoroutine(timeLimitCoroutine);
            }

            // 再度実行できるように再取得する
            timeLimitCoroutine = timeLimitCheck();

            Debug.Log("回答ボタン押下!!!");
            Debug.Log("クイズ出題状況:" + quizOutputStatus.ToString());
            Debug.Log("クイズ出題数: " + alreadyQuizNum);
            Debug.Log("クイズ最大数: " + QUIZ_MAX_NUM);
            if (this.quizOutputStatus == QuizOutputStatus.AnswerWait &&
                alreadyQuizNum <= QUIZ_MAX_NUM)
            {
                // 回答待ち状態から出題可能状態に変更
                this.quizOutputStatus = QuizOutputStatus.PossibleOutput;

                // ボタンの状態を更新
                buttonStateChange(choiceNo);

                if (choiceNo == currentQuiz.Answer)
                {
                    Debug.Log("正解しました!");

                    if (this.alreadyQuizNum == QUIZ_MAX_NUM && this.correctAnswerNum >= 2)
                    {
                        // 最終問題かつ正解が多い場合はアニメーションと音声を変える
                        SoundController.instance.ManyCorrectAnswer();
                        this.charactorController.CorrectAnswerAnotherTrigger();
                        this.charactorController.FaceChange("smile2");
                    }
                    else
                    {
                        SoundController.instance.CorrectAnswer();
                        this.charactorController.CorrectAnswerTrigger();
                    }

                    this.correctAnswerNum++;
                    this.correctAnswersText.text = "正解数 " + this.correctAnswerNum;
                }
                else
                {
                    Debug.Log("不正解です!");
                    inCorrectAnswerExpression();
                }
                // 出題状況チェックしてクイズを作成
                StartCoroutine(quizOutputCheck());
            }
        }
示例#2
0
        /**
         * クイズの出題
         */
        private void quizOutput()
        {
            this.charactorController.FaceChange("default");

            this.currentQuiz = quizMaker.CreateQuiz();

            if (currentQuiz == null)
            {
                Debug.Log("クイズの作成に失敗しました!!!");
                StartCoroutine(quizEnd());
                return;
            }
            // ボタンの状態を初期化
            buttonStateChange(0);
            this.questionText.text = currentQuiz.Question;
            this.choice1.GetComponentInChildren <Text>().text = currentQuiz.Choices[1];
            this.choice2.GetComponentInChildren <Text>().text = currentQuiz.Choices[2];
            this.choice3.GetComponentInChildren <Text>().text = currentQuiz.Choices[3];

            this.alreadyQuizNum++;

            this.numberOfQuestionsText.text = "出題数 " + alreadyQuizNum + " / " + QUIZ_MAX_NUM;

            this.charactorController.Wait();

            Debug.Log("クイズ出題!!!");
            Debug.Log("クイズ出題状況:" + quizOutputStatus.ToString());
            Debug.Log("クイズ出題数: " + alreadyQuizNum);
            Debug.Log("クイズ最大数: " + QUIZ_MAX_NUM);

            // TODO 回答をタップ可能にする

            // 回答待ち状態にする
            this.quizOutputStatus = QuizOutputStatus.AnswerWait;

            StartCoroutine(timeLimitCoroutine);
        }
示例#3
0
        /**
         * クイズ出題状況をチェックして出題可能ならクイズを作成
         */
        private IEnumerator quizOutputCheck()
        {
            // 演出としてゲーム画面表示後、問題を出題するまで少し待つ
            if (this.quizOutputStatus == QuizOutputStatus.QuizLoad)
            {
                while (true)
                {
                    yield return(new WaitForSeconds(0.5f));

                    if (quizMaker.IsLoadComplete())
                    {
                        break;
                    }
                }

                //TODO 初回はクイズスタート!のような文言を出したい
                yield return(new WaitForSeconds(0.5f));
            }


            Debug.Log("クイズ出題判定");
            // まだクイズ上限数まで出題していない
            if (this.alreadyQuizNum < QUIZ_MAX_NUM)
            {
                // 回答待ち状態ではない
                if (this.quizOutputStatus == QuizOutputStatus.QuizLoad ||
                    this.quizOutputStatus == QuizOutputStatus.PossibleOutput)
                {
                    if (this.quizOutputStatus == QuizOutputStatus.PossibleOutput)
                    {
                        // アニメーションがアイドル状態になるまで待つ

                        // アニメーションが回答後にすぐに切り替わってないかもしれないので少し待つ
                        yield return(new WaitForSeconds(0.5f));

                        string answerTag = CharactorController.AnimationTag.Answer.ToString();
                        if (charactorController.IsAnimation(answerTag))
                        {
                            yield return(new WaitForSeconds(0.2f));

                            while (charactorController.IsAnimation(answerTag))
                            {
                                yield return(new WaitForSeconds(0.2f));
                            }
                        }
                        else
                        {
                            // 回答後のアニメーションが取得できないので頃合いを見て抜ける(合計2秒待つ)
                            Debug.Log("回答後のアニメーションが取得できないので頃合いを見て抜ける");
                            yield return(new WaitForSeconds(1.5f));
                        }
                    }

                    // クイズ出題
                    this.quizOutput();
                }
            }
            else
            {
                Debug.Log("クイズは終了です!!!");
                StartCoroutine(quizEnd());
                this.quizOutputStatus = QuizOutputStatus.QuizEnd;
            }
        }
示例#4
0
        /**
         * クイズ種類選択
         */
        private async UniTask SelectQuizType(int selectType)
        {
            // 階級挑戦問題説明文の初期化
            statusPanelController.OutputCareerDescription("");

            // RemoteConfigのFetch日時が古い場合はFetchを行う
            if (OshiroRemoteConfig.Instance().IsNeedFetch())
            {
                UnityAction     callback        = () => OshiroRemoteConfig.Instance().RemoteConfigFetch();
                OshiroFirebases oshiroFirebases = new OshiroFirebases();
                oshiroFirebases.FirebaseAsyncAction(callback);
            }

            // 強制アップデートチェック
            if (OshiroUtil.IsForceUpdate())
            {
                var modalWindow = GameObject.FindWithTag("Modal");

                if (modalWindow == null)
                {
                    var canvas      = GameObject.Find("Canvas");
                    var forceUpdate = Instantiate(this.forceUpdatePrefab);
                    forceUpdate.tag = "Modal";
                    forceUpdate.transform.SetParent(canvas.transform, false);
                }

                return;
            }

            // 階級挑戦クイズはメンテナンス中は実施不可
            if (OshiroRemoteConfig.Instance().IsMaintenance)
            {
                if ((int)GamePlayInfo.QuizType.CareerQuiz == selectType)
                {
                    statusPanelController.OutputCareerDescription("メンテナンス中のため階級挑戦問題で遊ぶことができません");
                    return;
                }
            }

            SoundController.instance.QuizStart();
            // Loading表示
            loadingText.Display();

            // ロード中状態に変更
            this.quizOutputStatus = QuizOutputStatus.QuizLoad;

            // 選択したクイズ種類を設定
            if ((int)GamePlayInfo.QuizType.RegularQuiz == selectType)
            {
                // レギュラークイズ
                GamePlayInfo.PlayQuizType = GamePlayInfo.QuizType.RegularQuiz;
                quizMaker = new RegularQuizMaker();

                // クイズ情報ロード
                ((RegularQuizMaker)quizMaker).QuizDataLoad();
            }
            else
            {
                // 身分クイズ
                GamePlayInfo.PlayQuizType = GamePlayInfo.QuizType.CareerQuiz;
                quizMaker = new CareerQuizMaker();

                // クイズ情報ロード
                bool isSuccess = await this.apiController.CareerQuizLoad((CareerQuizMaker)quizMaker, GamePlayInfo.BeforeCareer);

                // 失敗時は1回だけリトライ
                if (!isSuccess)
                {
                    await UniTask.Delay(2500);

                    isSuccess = await this.apiController.CareerQuizLoad((CareerQuizMaker)quizMaker, GamePlayInfo.BeforeCareer);
                }

                // ロードリトライも失敗時
                if (!isSuccess)
                {
                    statusPanelController.OutputCareerDescription("サーバーとの通信に失敗しました。");
                    // Loading表示の解除
                    loadingText.Hidden();
                    // ステータスをクイズ開始前に戻す
                    quizOutputStatus = QuizOutputStatus.BeforeQuiz;

                    return;
                }
            }
            // Loading表示の解除
            loadingText.Hidden();

            // パネルを切り替え
            this.selectUIPanel.SetActive(false);
            this.statusPanelController.DisplayChange(false);
            this.gameUIPanel.SetActive(true);
            this.questionPanel.SetActive(true);

            // 出題状況チェックしてクイズを作成
            StartCoroutine(quizOutputCheck());

            this.charactorController.QuizStartTrigger();
        }