Esempio n. 1
0
    void OnGUI()
    {
        if (!Helper.gameOver)
        {
            GUI.DrawTexture(new Rect(Screen.width - Screen.width / 10, 10, Screen.width / 10, Screen.width / 10), sound_on_off);
            if (GUI.Button(new Rect(Screen.width - Screen.width / 10, 10, Screen.width / 10, Screen.width / 10), "", style_Audio_button))
            {
                if (isMusicPlaying())
                {
                    sound_on_off = sound_off;
                    sound_option = 0;
                    stopMusic();
                    SaveLoadScript.Save_sound(sound_option);
                }
                else
                {
                    sound_on_off = sound_on;
                    sound_option = 1;
                    playMusic();
                    SaveLoadScript.Save_sound(sound_option);
                }
            }
        }
        if (Helper.gameOver && displaygameOverPopup)
        {
            float box_width     = Screen.width - 50;
            float box_height    = Screen.height / 2;
            float button_width  = box_width / 6;
            float button_height = button_width;

            float label_score_x = 0;
            float label_score_y = 40;
            float label_score_w = box_width;
            float label_score_h = label_score.fontSize;

            float label_Bscore_x = 0;
            float label_Bscore_y = label_score_y + label_score_h;
            float label_Bscore_w = box_width;
            float label_Bscore_h = label_scoreBest.fontSize;

            float image_x = 10;
            float image_y = label_Bscore_y + label_Bscore_h + 10;
            float image_w = box_width / 3;
            float image_h;



            box_height = label_score_y + label_score_h + label_Bscore_h + (2 * button_height) + 80;

            image_h = box_height / 2;
            image_w = image_h;
            image_x = ((box_width / 2) - image_w) / 2;

            float button_home_y  = label_Bscore_y + label_Bscore_h + ((box_height - (label_Bscore_y + label_Bscore_h)) - button_height) / 2;
            float button_retry_y = button_home_y;

            float button_home_x  = box_width / 2;         //(box_width - button_width)/2;
            float button_retry_x = button_home_x + button_width + button_width / 2;
            //layout start
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "");
            GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "");

            GUI.BeginGroup(new Rect((Screen.width - box_width) / 2, (Screen.height - box_height) / 2, box_width, box_height));
            //GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));
            //the menu background box


            GUI.Box(new Rect(0, 0, box_width, box_height), "", bg_scoreBox);

            //GUI.Label(new Rect(0,10,box_width, 40),"Game Over",label_gameover);

            GUI.Label(new Rect(label_score_x, label_score_y, label_score_w, label_score_h), "Your Score: " + MainMenu.current_score, label_score);
            GUI.Label(new Rect(label_Bscore_x, label_Bscore_y, label_Bscore_w, label_Bscore_h), "Best Score: " + best_score, label_scoreBest);

            GUI.DrawTexture(new Rect(image_x, image_y, image_w, image_h), score_image);

            //GUI.DrawTexture (new Rect (button_width, box_width/2, box_width/6, box_width/6), homeTexture);
            if (GUI.Button(new Rect(button_home_x, button_home_y, button_width, button_height), "", style_home_button))
            {
                loadMainMenu();
            }

            //GUI.DrawTexture (new Rect (box_width - button_width*2, box_width/2, box_width/6, box_width/6), retryTexture);
            if (GUI.Button(new Rect(button_retry_x, button_retry_y, button_width, button_height), "", style_retry_button))
            {
                Helper.isRetry = true;
                restartGame();
            }

            //layout end
            GUI.EndGroup();
        }

        /*thumbStyle.fixedHeight = Screen.height / 40;
         * touchSensitivity = GUI.VerticalSlider (new Rect (Screen.width - Screen.width/20,
         *                                               15 + Screen.width/10, Screen.width/20, Screen.height/4),
         *                                     touchSensitivity, 1.0f, 10.0f, sliderStyle, thumbStyle);
         * Helper.touchsense = touchSensitivity;
         * //Debug.Log ("touchSensitivity: "+touchSensitivity);
         */
    }