public void OnClick() { this.gameObject.AddComponent <AudioSource>(); if (countObj.Update() > 0) { countObj.stop(); AudioSource timerClip = timer.GetComponent <AudioSource>(); if (timerClip.isPlaying) { timerClip.Stop(); } if (isCorrect) { //Color32 myNewColor = new Color32(0,126,40,255); //RBGA in bytes //buttonPanel.BackgroundColor = myNewColor; GetComponent <AudioSource>().clip = rightAnswerClip; GetComponent <AudioSource>().Play(); //audio.PlayOneShot(rightAnswerClip, 0.7F); countTexture.Texture = Resources.Load("check") as Texture2D; countTexture.GetComponentInChildren <dfLabel>().IsVisible = false; GameConstant.CurrentScore += GameConstant.CorrectAnswer; GameConstant.CorrectAnswerCount += GameConstant.CorrectAnswer; if (CountDown.seconds >= 7) { GameConstant.CurrentScore += GameConstant.CorrectAnswerInSevenToTenSec; GameConstant.SpeedAnswerCount += GameConstant.CorrectAnswerInSevenToTenSec; } else if (CountDown.seconds >= 4) { GameConstant.CurrentScore += GameConstant.CorrectAnswerInSixToFourSec; GameConstant.SpeedAnswerCount += GameConstant.CorrectAnswerInSixToFourSec; } else if (CountDown.seconds < 4) { GameConstant.CurrentScore += GameConstant.CorrectAnswerInThreeToZeroSec; GameConstant.SpeedAnswerCount += GameConstant.CorrectAnswerInThreeToZeroSec; } if (questionDifficulty.Equals("EASY")) { GameConstant.CurrentScore += GameConstant.CorrectEasyAnswer; GameConstant.DifficultyAnswerCount += GameConstant.CorrectEasyAnswer; } else if (questionDifficulty.Equals("MEDIUM")) { GameConstant.CurrentScore += GameConstant.CorrectMediumAnswer; GameConstant.DifficultyAnswerCount += GameConstant.CorrectMediumAnswer; } else if (questionDifficulty.Equals("DIFFICULT")) { GameConstant.CurrentScore += GameConstant.CorrectHardAnswer; GameConstant.DifficultyAnswerCount += GameConstant.CorrectHardAnswer; } } else { //Color32 myNewColor = new Color32(255,0,0,255); //RBGA in bytes //buttonPanel.BackgroundColor = myNewColor; //audio.PlayOneShot(wrongAnswerClip, 0.7F); GetComponent <AudioSource>().clip = wrongAnswerClip; GetComponent <AudioSource>().Play(); countTexture.Texture = Resources.Load("cross") as Texture2D; countTexture.GetComponentInChildren <dfLabel>().IsVisible = false; } Color32 myNewColor = new Color32(118, 118, 118, 255); //RBGA in bytes other1.IsEnabled = false; other1.Texture = Resources.Load("gray_field_bg") as Texture2D; other_icon1.Texture = Resources.Load("gray_num_bg") as Texture2D; other_icon1.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor; other2.IsEnabled = false; other2.Texture = Resources.Load("gray_field_bg") as Texture2D; other_icon2.Texture = Resources.Load("gray_num_bg") as Texture2D; other_icon2.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor; other3.IsEnabled = false; other3.Texture = Resources.Load("gray_field_bg") as Texture2D; other_icon3.Texture = Resources.Load("gray_num_bg") as Texture2D; other_icon3.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor; StartCoroutine(Wait(4.0f)); } //Color32 myNewColor = new Color32(128,128,128,255); //RBGA in bytes //buttonPanel.BackgroundColor = myNewColor; /*float cur_sec = playGame.Seconds; * * if(cur_sec >= 0){ * playGame.Seconds = 0; * Debug.Log(questionOption); * playGame.Seconds = 9; * }*/ }
public void StartRound() { Color32 myNewColor = new Color32(196, 115, 7, 255); //RBGA in bytes //answer1.BackgroundColor = myNewColor; //answer2.BackgroundColor = myNewColor; //answer3.BackgroundColor = myNewColor; //answer4.BackgroundColor = myNewColor; if (questionCounter < totalQuestion) { int showNumber = questionCounter + 1; question_no.Text = "Question " + showNumber + " of 10"; answer1.IsEnabled = true; answer2.IsEnabled = true; answer3.IsEnabled = true; answer4.IsEnabled = true; answer1.Texture = Resources.Load("checked_field_bg") as Texture2D; answer2.Texture = Resources.Load("checked_field_bg") as Texture2D; answer3.Texture = Resources.Load("checked_field_bg") as Texture2D; answer4.Texture = Resources.Load("checked_field_bg") as Texture2D; //string aaa = catReply.data[questionCounter].qu_text;//text to decode. //string b = aaa.Replace("'", "'"); //questionLable.Text = b.Replace(""", "\""); questionLable.Text = DecodeString(catReply.data[questionCounter].qu_text); countTexture1.Texture = Resources.Load("yellow_num_bg") as Texture2D; countTexture2.Texture = Resources.Load("yellow_num_bg") as Texture2D; countTexture3.Texture = Resources.Load("yellow_num_bg") as Texture2D; countTexture4.Texture = Resources.Load("yellow_num_bg") as Texture2D; countTexture1.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor; countTexture2.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor; countTexture3.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor; countTexture4.GetComponentInChildren <dfLabel>().OutlineColor = myNewColor; countTexture1.GetComponentInChildren <dfLabel>().IsVisible = true; countTexture2.GetComponentInChildren <dfLabel>().IsVisible = true; countTexture3.GetComponentInChildren <dfLabel>().IsVisible = true; countTexture4.GetComponentInChildren <dfLabel>().IsVisible = true; answer_text1.Text = DecodeString(catReply.data[questionCounter].qu_option1); answer_text2.Text = DecodeString(catReply.data[questionCounter].qu_option2); answer_text3.Text = DecodeString(catReply.data[questionCounter].qu_option3); answer_text4.Text = DecodeString(catReply.data[questionCounter].qu_option4); // check if answer 1 if (catReply.data[questionCounter].qu_answer == 1) { answer1.GetComponent <answerQuestion>().isCorrect = true; } else { answer1.GetComponent <answerQuestion>().isCorrect = false; } // check if answer 2 if (catReply.data[questionCounter].qu_answer == 2) { answer2.GetComponent <answerQuestion>().isCorrect = true; } else { answer2.GetComponent <answerQuestion>().isCorrect = false; } // check if answer 3 if (catReply.data[questionCounter].qu_answer == 3) { answer3.GetComponent <answerQuestion>().isCorrect = true; } else { answer3.GetComponent <answerQuestion>().isCorrect = false; } // check if answer 4 if (catReply.data[questionCounter].qu_answer == 4) { answer4.GetComponent <answerQuestion>().isCorrect = true; } else { answer4.GetComponent <answerQuestion>().isCorrect = false; } // end answer1.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty; answer2.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty; answer3.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty; answer4.GetComponent <answerQuestion>().questionDifficulty = catReply.data[questionCounter].qu_difficulty; //Debug.Log(catReply.data[questionCounter].qu_text); //Debug.Log(catReply.data[questionCounter].qu_answer); countObj.start(); } else { Debug.Log("Game Over"); catReply = null; questionCounter = 0; totalQuestion = 0; SceneManager.LoadScene("TriviaResult"); } }