Exemple #1
0
    public void start()
    {
        leaderBtn.GetComponent <goToTriviaLeaderBoard>().prizeID      = Data.prize_id;
        playBtn.GetComponent <goToTriviaPlayCategory>().prizeID       = Data.prize_id;
        playBtn.GetComponent <goToTriviaPlayCategory>().prizeTopScore = Data.score;

        menu_text.Text  = Data.prize_title;
        date_text.Text  = "Expires: " + Data.prize_date.ToString();
        score_text.Text = Data.score.ToString();
        StartCoroutine(DownloadImg());
    }
    private IEnumerator handleMomentum(dfGestureBase gesture)
    {
        isMouseDown = false;

        const float SPEED = 10f;

        var direction = (Vector3)(gesture.CurrentPosition - gesture.StartPosition) * control.PixelsToUnits();
        var planes    = GeometryUtility.CalculateFrustumPlanes(control.GetCamera());

        var startTime = Time.realtimeSinceStartup;

        while (!isMouseDown)
        {
            var timeNow = Time.realtimeSinceStartup;
            var elapsed = timeNow - startTime;
            if (elapsed > 1f)
            {
                break;
            }

            control.transform.position += direction * Time.deltaTime * SPEED * (1f - elapsed);

            yield return(null);
        }

        if (!GeometryUtility.TestPlanesAABB(planes, control.GetComponent <Collider>().bounds))
        {
            control.enabled = false;
            DestroyImmediate(gameObject);
        }
    }
Exemple #3
0
    public void OnClick()
    {
        AudioSource backgroundClip = mainpanel.GetComponent <AudioSource>();

        GetComponent <AudioSource>().clip = clickBtn;
        GetComponent <AudioSource>().Play();
        if (backgroundClip.isPlaying)
        {
            backgroundClip.Stop();
            progress.Pause();
        }
    }
Exemple #4
0
    public void OnClick()
    {
        CategoryConstant.GameType = "fun";
        AudioSource backgroundClip = mainpanel.GetComponent <AudioSource>();

        GetComponent <AudioSource>().clip = clickBtn;
        GetComponent <AudioSource>().Play();

        if (!backgroundClip.isPlaying)
        {
            backgroundClip.Play();
            progress.Resume();
        }
        else
        {
            backgroundClip.Stop();
            progress.Stop();
            //  start game play

            if (CategoryConstant.GameType.Equals("fun"))
            {
                HTTP.Client.Instance.Configure(new HTTP.Settings(TriviaService.GetHostAddress()).Protocol(HTTP.Protocol.HTTP));

                new HTTP.Request(TriviaService.GetHttpFolderPath() + "get_player_fun_points.php?prize_id=" + CategoryConstant.PrizeId + "&th_cat_id=" + CategoryConstant.MainCategoryId + "&sec_cat_id=" + CategoryConstant.SubCategoryId + "&cat_id=" + CategoryConstant.GrandCategoryId + "&game_user_id=" + GameConstant.UserId + "&game_user_type=" + GameConstant.UserType)
                .OnReply((reply) => {
                    pointReply = JsonConvert.DeserializeObject <PointReply>(reply.DataAsString);

                    if (pointReply.success == 1)
                    {
                        GameConstant.FunHighScore = pointReply.points;
                    }
                    else
                    {
                        GameConstant.FunHighScore = 0;
                    }
                }).Send();
            }

            GameConstant.CurrentScore = 0;
            SceneManager.LoadScene("TriviaStratPlay");
        }
    }
Exemple #5
0
    public int Update()
    {
        AudioSource timerClip = timer.GetComponent <AudioSource>();

        if (seconds <= 0)
        {
            //Application.LoadLevel("Defeat");
            if (timerClip.isPlaying)
            {
                timerClip.Stop();
            }
        }
        if (seconds <= 5 && seconds > 0)
        {
            if (!timerClip.isPlaying)
            {
                timerClip.Play();
            }
        }
        return(seconds);
    }
Exemple #6
0
    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;
         * }*/
    }
Exemple #7
0
    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("&#039;", "'");
            //questionLable.Text = b.Replace("&quot;", "\"");

            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");
        }
    }