void ClickAnswer(int no) { if (!quizOn) { return; } quizOn = false; QuizData item = quizList[quizIndex]; // Is answer correct? if (item.correct == no) { // Display good Effect Instantiate(goodEffect); // Display soul trail effect GameObject go = Instantiate(soulEffect) as GameObject; go.GetComponent <SoulEffect>().posX = -1f; // Display Happy Effect StartCoroutine(DelayActoin(0.6f, () => { go = Instantiate(happyEffect, new Vector3(-0.7f, 1f, 0f), Quaternion.identity) as GameObject; enemyHpMan.DoDamageHp(10); })); // Display Actor's motion friendAnimator.CrossFade("Good", 0.2f); enemyAnimator.CrossFade("Bad", 0.2f); } else { // Display Bad Effect Instantiate(badEffect); // Display soul trail effect GameObject go = Instantiate(soulEffect) as GameObject; go.GetComponent <SoulEffect>().posX = 1f; // Display Happy Effect StartCoroutine(DelayActoin(0.6f, () => { go = Instantiate(happyEffect, new Vector3(0.7f, 1f, 0f), Quaternion.identity) as GameObject; friendHpMan.DoDamageHp(10); })); // Display Actor's motion friendAnimator.CrossFade("Bad", 0.2f); enemyAnimator.CrossFade("Good", 0.2f); } StartCoroutine(DelayActoin(3f, () => { DrawQuiz(); })); }
/// ///////////////////////////////////////////////////////////////////////////////// public void ClickAnswer(int no) { if (!quizOn) { return; } quizOn = false; QuizData item = quizList[quizIndex]; // Is answer collect? if (item.correct == no) { // Display good Effect Instantiate(goodEffect); // Display soul trail effect GameObject go = Instantiate(soulEffect) as GameObject; go.GetComponent <SoulEffect>().posX = -1f; // Display Happy Effect StartCoroutine(DelayActoin(0.6f, () => { go = Instantiate(happyEffect, new Vector3(-0.7f, 1f, 0f), Quaternion.identity) as GameObject; })); // Display Actor's motion friendAnimator.CrossFade("Good", 0.2f); enemyAnimator.CrossFade("Bad", 0.2f); SumScore.Add(10); SumScore.SaveHighScore(); } else { // Display Bad Effect Instantiate(badEffect); // Display soul trail effect GameObject go = Instantiate(soulEffect) as GameObject; go.GetComponent <SoulEffect>().posX = 1f; // Display Happy Effect StartCoroutine(DelayActoin(0.6f, () => { go = Instantiate(happyEffect, new Vector3(0.7f, 1f, 0f), Quaternion.identity) as GameObject; friendHpMan.DoDamageHp(30); })); // Display Actor's motion friendAnimator.CrossFade("Bad", 0.2f); enemyAnimator.CrossFade("Good", 0.2f); SumScore.SaveHighScore(); // Add to result data. string questionKey = "question" + wrongCnt.ToString(); string correctKey = "correct" + wrongCnt.ToString(); string questionVal = item.question; string correctVal = answerLabels[item.correct].text; Debug.Log("Save : " + questionKey); Debug.Log("Save : " + questionVal); PlayerPrefs.SetString(questionKey, questionVal); PlayerPrefs.SetString(correctKey, correctVal); wrongCnt++; } StartCoroutine(DelayActoin(3f, () => { DrawQuiz(); })); }