Пример #1
0
    // Update is called once per frame
    void Update()
    {
        // Listens in on GameState for the number of rounds
        if ((GameState.Singleton.CurrentState == State.Win ||
             GameState.Singleton.CurrentState == State.Lose) &&
            (!drawGUI && surveyRoundState != SurveyRoundState.SurveyResultsSent))
        {
            // That last clause fixes a bug where the score window can pop up again by accident.
            drawGUI = true;
            if (totalScore == 0)
            {
                totalScore = (int)GameState.Singleton.score + GameRoundCounter.GetTotalScore();
            }
        }

        if (surveyObject != null)
        {
            LikertGUI lc2     = surveyObject.GetComponent <LikertGUI>();
            string    results = lc2.GetResults();
            if (results != null && !surveySent)
            {
                // SEND THE SURVEY RESULTS OFF....
                this.gameObject.GetComponent <DBGameStateManager>().SendSurveyResults(results);
                surveyRoundState = SurveyRoundState.SurveyResultsSent;
                surveySent       = true;
            }
        }
    }
Пример #2
0
    private void DisplayContinueOrQuitDialogue(string text)
    {
        // Otherwise, spawn a box that lets the player quit or continue
        GUILayout.BeginArea(new Rect((Screen.width - width) / 2.0f, (Screen.height - height) / 2.0f, width, height), GUI.skin.box);

        scrollPosition = GUILayout.BeginScrollView(scrollPosition, boxStyle);
        GUILayout.Label(text, textStyle);
        GUILayout.EndScrollView();

        // BUTTONS
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Continue!", buttonStyle))
        {
            drawGUI = false;
            GameRoundCounter.AdvanceRound();
            GameRoundCounter.AddScore((int)GameState.Singleton.score);
            Application.LoadLevel(gameSceneName);
        }
        if (GUILayout.Button("Finish!", buttonStyle))
        {
            surveyObject = new GameObject();
            surveyObject.transform.position = new Vector3(0, 0, -5f);
            surveyObject.AddComponent <LikertGUI>();
            LikertGUI lc = surveyObject.GetComponent <LikertGUI>();
            SetupLikertGUI(ref lc);
            surveyRoundState = SurveyRoundState.SurveyObjectSpawned;
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Пример #3
0
    void OnGUI()
    {
        if (drawGUI)
        {
            if (boxStyle == null)
            {
                boxStyle = new GUIStyle(GUI.skin.box);
                boxStyle.normal.background = GUIUtils.MakeBlankTexture(width, height, fontBackground);
                buttonStyle          = new GUIStyle(GUI.skin.button);
                buttonStyle.font     = font;
                buttonStyle.fontSize = fontSize;
            }

            string scoreText = GenerateScoreText();

            if (GameRoundCounter.GetCurrentRound() < surveyRound)
            {
                // Draw continue dialogue
                GUILayout.BeginArea(new Rect((Screen.width - width) / 2.0f, (Screen.height - height) / 2.0f, width, height), GUI.skin.box);

                scrollPosition = GUILayout.BeginScrollView(scrollPosition, boxStyle);
                GUILayout.Label(scoreText, textStyle);
                GUILayout.EndScrollView();

                // BUTTONS
                if (GUILayout.Button("Continue!", buttonStyle))
                {
                    drawGUI = false;
                    GameRoundCounter.AdvanceRound();
                    GameRoundCounter.AddScore((int)GameState.Singleton.score);
                    // The following line is a hack to keep the survey from drawing after the round changes.
                    surveyRoundState = SurveyRoundState.SurveyObjectSpawned;
                    Application.LoadLevel(gameSceneName);
                }
                GUILayout.EndArea();
            }
            else
            {
                // Spawn the survey object
                switch (surveyRoundState)
                {
                case SurveyRoundState.WaitingToSpawn:
                    string text = '\n' + "Feel free to continue or finish up with the post-game survey.";
                    // Otherwise, spawn a box that lets the player quit or continue
                    DisplayContinueOrQuitDialogue(scoreText + text);
                    break;

                case SurveyRoundState.SurveyObjectSpawned:
                case SurveyRoundState.SurveyResultsSent:
                    // Draw nothing
                    break;
                }
            }
        }
    }