Esempio n. 1
0
    /*
     * void MakeRankAndHighlight()
     * {
     *
     *  if (InstanceCommonGameCanvasManagerScript.GetTotalRestSeconds() < 0f)
     *  {
     *
     *      if (NewScoreDataSavedFlg == false)
     *      {
     *
     *          //ランキングを計算
     *
     *          if (ScoreInt < OldScoreRanking[4])
     *          {
     *              NewScoreRanking[0] = OldScoreRanking[0];
     *              NewScoreRanking[1] = OldScoreRanking[1];
     *              NewScoreRanking[2] = OldScoreRanking[2];
     *              NewScoreRanking[3] = OldScoreRanking[3];
     *              NewScoreRanking[4] = OldScoreRanking[4];
     *
     *          }
     *
     *          if (ScoreInt > OldScoreRanking[4])
     *          {
     *              RankInt = 5;
     *              NewScoreRanking[0] = OldScoreRanking[0];
     *              NewScoreRanking[1] = OldScoreRanking[1];
     *              NewScoreRanking[2] = OldScoreRanking[2];
     *              NewScoreRanking[3] = OldScoreRanking[3];
     *              NewScoreRanking[4] = ScoreInt;
     *          }
     *
     *          if (ScoreInt > OldScoreRanking[3])
     *          {
     *              RankInt = 4;
     *              NewScoreRanking[0] = OldScoreRanking[0];
     *              NewScoreRanking[1] = OldScoreRanking[1];
     *              NewScoreRanking[2] = OldScoreRanking[2];
     *              NewScoreRanking[3] = ScoreInt;
     *              NewScoreRanking[4] = OldScoreRanking[3];
     *          }
     *
     *          if (ScoreInt > OldScoreRanking[2])
     *          {
     *              RankInt = 3;
     *              NewScoreRanking[0] = OldScoreRanking[0];
     *              NewScoreRanking[1] = OldScoreRanking[1];
     *              NewScoreRanking[2] = ScoreInt;
     *              NewScoreRanking[3] = OldScoreRanking[2];
     *              NewScoreRanking[4] = OldScoreRanking[3];
     *          }
     *
     *          if (ScoreInt > OldScoreRanking[1])
     *          {
     *              RankInt = 2;
     *              NewScoreRanking[0] = OldScoreRanking[0];
     *              NewScoreRanking[1] = ScoreInt;
     *              NewScoreRanking[2] = OldScoreRanking[1];
     *              NewScoreRanking[3] = OldScoreRanking[2];
     *              NewScoreRanking[4] = OldScoreRanking[3];
     *          }
     *
     *          if (ScoreInt > OldScoreRanking[0])
     *          {
     *              RankInt = 1;
     *              NewScoreRanking[0] = ScoreInt;
     *              NewScoreRanking[1] = OldScoreRanking[0];
     *              NewScoreRanking[2] = OldScoreRanking[1];
     *              NewScoreRanking[3] = OldScoreRanking[2];
     *              NewScoreRanking[4] = OldScoreRanking[3];
     *          }
     *
     *          //ランキングへの書込み(-1で書き込むとランキング表示なし)
     *          InstanceCommonGameCanvasManagerScript.SetGameScoreRank1(NewScoreRanking[0]);
     *          InstanceCommonGameCanvasManagerScript.SetGameScoreRank2(NewScoreRanking[1]);
     *          InstanceCommonGameCanvasManagerScript.SetGameScoreRank3(NewScoreRanking[2]);
     *          InstanceCommonGameCanvasManagerScript.SetGameScoreRank4(NewScoreRanking[3]);
     *          InstanceCommonGameCanvasManagerScript.SetGameScoreRank5(NewScoreRanking[4]);
     *
     *
     *
     *
     *
     *          //ランクに入っていればハイライト
     *          InstanceCommonGameCanvasManagerScript.SetHighlightRank(RankInt);
     *          //            Debug.Log("ハイライト済み");
     *
     *
     *          //今回スコアをランキング画面にセット
     *          InstanceCommonGameCanvasManagerScript.SetThisTimeScoreText(ScoreInt.ToString());
     *          //            Debug.Log("スコアセット済み");
     *
     *
     *          //今回スコアに資したアクションをセット
     *          InstanceCommonGameCanvasManagerScript.SetThisTimeScoreMainActionText(CorrectAnswerCount.ToString());
     *          //            Debug.Log("アクションセット済み");
     *
     *
     *          //ボーナスポイント回数をセット
     *          InstanceCommonGameCanvasManagerScript.SetThisTimeBonusCountText(BonusPointCount.ToString());
     *          //            Debug.Log("ボーナスポイントセット済み");
     *
     *
     *          //今回スコアをデータセーブ
     *
     *          ES3.Save<List<int>>(ScoreKeyName, ScoreList);
     *          NewScoreDataSavedFlg = true;
     *
     *
     *      }
     *
     *  }
     *
     *
     *
     * }
     *
     */



    //各ゲームにおける正答処理はそれぞれ作成
    public void AnswerOnClickButton()
    {
        //タッチした時刻の記録
        TouchButtonTime[CountButtonTouch] = DateTime.Now;

        //回答数カウントアップ
        CountButtonTouch++;


        string BtnName = AnswerByButton.currentSelectedGameObject.gameObject.name;


        //解答欄クリア
        AnswerText.text = null;
        CorrectAnswerMark.SetActive(false);
        WrongAnswerMark.SetActive(false);


        //ボタン押下
        if (BtnName == "Btn1")
        {
            AnswerText.text += "1";
        }
        else if (BtnName == "Btn2")
        {
            AnswerText.text += "2";
        }
        else if (BtnName == "Btn3")
        {
            AnswerText.text += "3";
        }
        else if (BtnName == "Btn4")
        {
            AnswerText.text += "4";
        }
        else if (BtnName == "Btn5")
        {
            AnswerText.text += "5";
        }
        else if (BtnName == "Btn6")
        {
            AnswerText.text += "6";
        }
        else if (BtnName == "Btn7")
        {
            AnswerText.text += "7";
        }
        else if (BtnName == "Btn8")
        {
            AnswerText.text += "8";
        }
        else if (BtnName == "Btn9")
        {
            AnswerText.text += "9";
        }
        else if (BtnName == "Btn0")
        {
            AnswerText.text += "0";
        }
        if (BtnName == "BtnDlt")
        {
            AnswerText.text = "";
        }

        Debug.Log("AnswerText.text: " + AnswerText.text);

//        Debug.Log("Answerdigit: "+Answerdigit);
//        Debug.Log("(AnswerText.text).Length: " + (AnswerText.text).Length);


        if (Answerdigit == (AnswerText.text).Length)
        {
            if (Answer.ToString() == AnswerText.text)
            {
                //○を表示
                CorrectAnswerMark.SetActive(true);

                //正解音を出す
                InstanceCommonSFXControllerScript.DoSoundCorrectAnswer();

                //点数をつける
                //正答時刻の記録
                CorrectTouchButtonTime[CorrectAnswerCount] = DateTime.Now;

                //平均正答時間の更新
                //ゲーム終了時に時間をタッチボタン数で割ってやれば良いので
                //ここでは記載しない


                //連続正答数カウントアップ
                ConsectiveCorrectAnswers++;


                //スコア加算1(単純累積)
                ScoreInt += 200;
                InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
                InstanceCommonGameCanvasManagerScript.SetAddRealTimeScore(200);

                DebugText.text += ">SetScore1";

                //スコア加算2(ボーナス1:10連続ミスなし)
                if (ConsectiveCorrectAnswers == 10)
                {
                    ScoreInt += 400;
                    ConsectiveCorrectAnswers = 0;
                    BonusPointCount++;
                    InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
                    InstanceCommonGameCanvasManagerScript.SetAddRealTimeBonusScore(400);
                    DebugText.text += ">SetBonus1";
                }


                TimeSpan ElapsedTime;

                //スコア加算3(ボーナス2:即反応0.3秒以内)
                if (CorrectAnswerCount > 0)
                {
                    ElapsedTime = CorrectTouchButtonTime[CorrectAnswerCount] - CorrectTouchButtonTime[CorrectAnswerCount - 1];

                    Debug.Log("CorrectTouchButtonTime[CorrectAnswerCount]: " + CorrectTouchButtonTime[CorrectAnswerCount]);
                    Debug.Log("CorrectTouchButtonTime[CorrectAnswerCount - 1]: " + CorrectTouchButtonTime[CorrectAnswerCount - 1]);
                    Debug.Log("ElapsedTime.Milliseconds: " + ElapsedTime.Milliseconds);
                    Debug.Log("DateTime.Now: " + DateTime.Now);
                }

                //正解カウントアップ
                CorrectAnswerCount++;
                Debug.Log("CorrectAnswerCount: " + CorrectAnswerCount);



                if (ElapsedTime.Milliseconds < 300)
                {
                    ScoreInt += 300;
                    BonusPointCount++;
                    InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
                    InstanceCommonGameCanvasManagerScript.SetAddRealTimeBonusScore(300);
                    DebugText.text += ">SetBonus2";
                }



                //コメントプレフィックス1
                string comment1 = "Great Responce!";

                //コメントサフィックス2
                string comment2 = "You Can Do Better Next Time!";


                //リザルトをテキストに変換
                string ScoreText  = ScoreInt.ToString() + "pt!";
                string ResultText = comment1 + "\n" + ScoreText + "\n" + comment2;


                //リザルトへ書込み
                InstanceCommonGameCanvasManagerScript.SetResultText(ResultText);

                DebugText.text += ">SetResult";



                //過去スコアリストに今回スコアを追加するため過去スコア要素数+1のインデックスを
                //Start()で準備して使う
                ScoreList[NewScoreDataIndex] = ScoreInt;
            }
            else
            {
                //×を表示
                WrongAnswerMark.SetActive(true);
                //不正解音を出す
//                InstanceCommonGameCanvasManagerScript.DoSoundWrongAnswer();
                InstanceCommonSFXControllerScript.DoSoundWrongAnswer();
            }
        }
    }
    public bool TouchButton(string id)
    {
        DebugText.text = ">TouchButtonCorrect";


        //タッチした時刻の記録
        TouchButtonTime[CountButtonTouch] = DateTime.Now;


        //回答数カウントアップ
        CountButtonTouch++;


        //正否判定
        if (TargetId.ToString() == id)
        {
            //あっていたら
            //デバッグ用に画面にログを出す
            DebugText.text += ">TouchButtonCorrect";

            //正解音を出す
            InstanceCommonGameCanvasManagerScript.DoSoundCorrectAnswer();

            //正答時刻の記録
            CorrectTouchButtonTime[CountButtonTouch] = DateTime.Now;

            //平均正答時間の更新
            //ゲーム終了時に時間をタッチボタン数で割ってやれば良いので
            //ここでは記載しない

            //正解カウントアップ
            CorrectAnswerCount++;

            //連続正答数カウントアップ
            ConsectiveCorrectAnswers++;

            //スコア加算1(単純累積)
            ScoreInt += 200;
            InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
            InstanceCommonGameCanvasManagerScript.SetAddRealTimeScore(200);

            DebugText.text += ">SetScore1";

            //スコア加算2(ボーナス1:10連続ミスなし)
            if (ConsectiveCorrectAnswers == 10)
            {
                ScoreInt += 400;
                ConsectiveCorrectAnswers = 0;
                BonusPointCount++;
                InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
                InstanceCommonGameCanvasManagerScript.SetAddRealTimeBonusScore(400);
            }

            DebugText.text += ">SetBonus1";



            //スコア加算3(ボーナス2:即反応0.5秒以内)
            TimeSpan ElapsedTime = CorrectTouchButtonTime[CountButtonTouch] - CorrectTouchButtonTime[CountButtonTouch - 1];
            Debug.Log("ElapsedTime.Milliseconds: " + ElapsedTime.Milliseconds);


            if (ElapsedTime.Milliseconds < 300)
            {
                ScoreInt += 300;
                ConsectiveCorrectAnswers = 0;
                BonusPointCount++;
                InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
                InstanceCommonGameCanvasManagerScript.SetAddRealTimeBonusScore(300);
            }

            DebugText.text += ">SetBonus2";



            //コメントプレフィックス1
            string comment1 = "Great Responce!";

            //コメントサフィックス2
            string comment2 = "You Can Do Better Next Time!";


            //リザルトをテキストに変換
            string ScoreText  = ScoreInt.ToString() + "pt!";
            string ResultText = comment1 + "\n" + ScoreText + "\n" + comment2;


            //リザルトへ書込み
            InstanceCommonGameCanvasManagerScript.SetResultText(ResultText);

            DebugText.text += ">SetResult";



            //過去スコアリストに今回スコアを追加するため過去スコア要素数+1のインデックスを
            //Start()で準備して使う
            ScoreList[NewScoreDataIndex] = ScoreInt;



            //ボタン再生成管理カウントアップ
            CountForReCreateButtons++;


            //正答ボタン番号更新(+1)
            TargetId++;


            //デバッグ用に画面にログを出す
            DebugText.text += ">TouchButtonOut";


            //Trueを返却して呼び出し元でボタン消す
            return(true);
        }
        else
        {
            //デバッグ用に画面にログを出す
            DebugText.text += ">MisTouchButtonIn";


            //間違っていたら

            //不正解音を出す
            InstanceCommonGameCanvasManagerScript.DoSoundWrongAnswer();


            //誤答時間の記録
            WrongTouchButtonTime[CountButtonTouch] = DateTime.Now;


            //不正解カウントアップ
            WrongAnswerCount++;


            //連続正答数リセット
            ConsectiveCorrectAnswers = 0;


            //Falseを返却して呼び出し元では何もしない
            return(false);
        }
    }
Esempio n. 3
0
    public bool TouchButton(string id)
    {
        //デバッグ用に画面にログを出す
        InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("TouchButtonIn");


        //タッチした時刻の記録
        TouchButtonTime[CountButtonTouch] = DateTime.Now;


        //回答数カウントアップ
        CountButtonTouch++;


        //正否判定
        if (TargetId.ToString() == id)
        {
            //あっていたら
            //デバッグ用に画面にログを出す
            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("TouchButtonCorrect");

            //正解音を出す
            InstanceCommonGameCanvasManagerScript.DoSoundCorrectAnswer();

            //正答時刻の記録
            CorrectTouchButtonTime[CountButtonTouch] = DateTime.Now;

            //平均正答時間の更新
            //ゲーム終了時に時間をタッチボタン数で割ってやれば良いので
            //ここでは記載しない

            //正解カウントアップ
            CorrectAnswerCount++;

            //連続正答数カウントアップ
            ConsectiveCorrectAnswers++;

            //スコア加算1(単純累積)
            ScoreInt += 200;
            InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
            InstanceCommonGameCanvasManagerScript.SetAddRealTimeScore(200);

            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("スコア1加算済み");

            //スコア加算2(ボーナス1:10連続ミスなし)
            if (ConsectiveCorrectAnswers == 10)
            {
                ScoreInt += 400;
                ConsectiveCorrectAnswers = 0;
                BonusPointCount++;
                InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
                InstanceCommonGameCanvasManagerScript.SetAddRealTimeBonusScore(400);
            }

            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("ボーナス1設定済み");


            //スコア加算3(ボーナス2:即反応0.5秒以内)
            TimeSpan ElapsedTime = CorrectTouchButtonTime[CountButtonTouch] - CorrectTouchButtonTime[CountButtonTouch - 1];
            Debug.Log("ElapsedTime.Milliseconds: " + ElapsedTime.Milliseconds);


            if (ElapsedTime.Milliseconds < 300)
            {
                ScoreInt += 300;
                ConsectiveCorrectAnswers = 0;
                BonusPointCount++;
                InstanceCommonGameCanvasManagerScript.SetRealTimeScore(ScoreInt.ToString());
                InstanceCommonGameCanvasManagerScript.SetAddRealTimeBonusScore(300);
            }

            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("ボーナス2設定済み");



            //コメントプレフィックス1
            string comment1 = "Great Responce!";

            //コメントサフィックス2
            string comment2 = "You Can Do Better Next Time!";


            //リザルトをテキストに変換
            string ScoreText = ScoreInt.ToString() + "pt!";

            string ResultText = comment1 + "\n" + ScoreText + "\n" + comment2;


            //リザルトへ書込み
            InstanceCommonGameCanvasManagerScript.SetResultText(ResultText);

            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("リザルト書込み済み");


            //過去スコアリストに今回スコアを追加するため過去スコア要素数+1のインデックスを
            //Start()で準備して使う
            ScoreRankingList[NewScoreDataIndex] = ScoreInt;



            //スコアリストに今回スコアを入れてもすぐにソートはしない
            //本クラスで終了判定を行っていないため
            //どの時点のスコアが最終スコアとなるか不明なため
            //ただし今回スコアは得点が伸びるたびに当該変数を
            //過去スコアと比較してランキングに反映する
            //ソートは次回呼出し時に行う

            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("ランキング設定前");


            //ランキングへの書込み
            if (ScoreInt < ScoreRankingList[4])
            {
                Debug.Log("5位以下");
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank1(ScoreRankingList[0]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank2(ScoreRankingList[1]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank3(ScoreRankingList[2]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank4(ScoreRankingList[3]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank5(ScoreRankingList[4]);
            }
            if (ScoreInt > ScoreRankingList[4])
            {
                Debug.Log("5位");
                RankInt = 5;
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank1(ScoreRankingList[0]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank2(ScoreRankingList[1]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank3(ScoreRankingList[2]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank4(ScoreRankingList[3]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank5(ScoreInt);
            }
            if (ScoreInt > ScoreRankingList[3])
            {
                Debug.Log("4位");

                RankInt = 4;
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank1(ScoreRankingList[0]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank2(ScoreRankingList[1]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank3(ScoreRankingList[2]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank4(ScoreInt);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank5(ScoreRankingList[3]);
            }
            if (ScoreInt > ScoreRankingList[2])
            {
                Debug.Log("3位");
                RankInt = 3;
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank1(ScoreRankingList[0]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank2(ScoreRankingList[1]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank3(ScoreInt);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank4(ScoreRankingList[2]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank5(ScoreRankingList[3]);
            }
            if (ScoreInt > ScoreRankingList[1])
            {
                Debug.Log("2位");

                RankInt = 2;
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank1(ScoreRankingList[0]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank2(ScoreInt);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank3(ScoreRankingList[1]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank4(ScoreRankingList[2]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank5(ScoreRankingList[3]);
            }
            if (ScoreInt > ScoreRankingList[0])
            {
                Debug.Log("1位");

                RankInt = 1;
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank1(ScoreInt);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank2(ScoreRankingList[0]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank3(ScoreRankingList[1]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank4(ScoreRankingList[2]);
                InstanceCommonGameCanvasManagerScript.SetGameScoreRank5(ScoreRankingList[3]);
            }



            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("ランキング設定済み");


            //ランクに入っていればハイライト
            InstanceCommonGameCanvasManagerScript.SetHighlightRank(RankInt);
//            Debug.Log("ハイライト済み");


            //今回スコアをランキング画面にセット
            InstanceCommonGameCanvasManagerScript.SetThisTimeScoreText(ScoreInt.ToString());
//            Debug.Log("スコアセット済み");


            //今回スコアに資したアクションをセット
            InstanceCommonGameCanvasManagerScript.SetThisTimeScoreMainActionText(CorrectAnswerCount.ToString());
//            Debug.Log("アクションセット済み");


            //ボーナスポイント回数をセット
            InstanceCommonGameCanvasManagerScript.SetThisTimeBonusCountText(BonusPointCount.ToString());
//            Debug.Log("ボーナスポイントセット済み");


            //ボタン再生成管理カウントアップ
            CountForReCreateButtons++;


            //正答ボタン番号更新(+1)
            TargetId++;


            //デバッグ用に画面にログを出す
            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("TouchButtonOut");

            //Trueを返却して呼び出し元でボタン消す
            return(true);
        }
        else
        {
            //デバッグ用に画面にログを出す
            InstanceCommonGameCanvasManagerScript.SetGameDescriptionText("MisTouchButtonIn");

            //間違っていたら

            //不正解音を出す
            InstanceCommonGameCanvasManagerScript.DoSoundWrongAnswer();


            //誤答時間の記録
            WrongTouchButtonTime[CountButtonTouch] = DateTime.Now;


            //不正解カウントアップ
            WrongAnswerCount++;


            //連続正答数リセット
            ConsectiveCorrectAnswers = 0;


            //Falseを返却して呼び出し元では何もしない
            return(false);
        }
    }