示例#1
0
    public void MenuAction(int _action)
    {
        switch (_action)
        {
        case 1:     //go to calibration scene
            print("Calibrate Selected");
            SceneManager.LoadScene("Play");
            break;

        case 2:     // instantiate scoreboard
            print("Scoreboard selected");
            #region HIGHSCORE BEHAVIOUR
            if (!online.gameObject.activeSelf)
            {
                online.gameObject.SetActive(true);
                MenuCanvas.SetActive(false);
            }
            // SHOW ONLINE HIGHSCORES
            online.startGetScores();

            #endregion
            break;

        case 3:     // go to tutorial scene
            SceneManager.LoadScene("Tutorial");
            print("Tutorial Selected");
            break;

        case 4:     //quit
            print("Exit Selected");
            Application.Quit();
            break;

        default:
            Debug.LogError("NO ACTION ASSIGNED");
            break;
        }
    }
    void Update()
    {
        if (startNotificationTimer)
        {
            notificationTimer += Time.deltaTime;
        }
        if (notificationTimer >= notificationThreshold)
        {
            notificationBox.text   = "";
            startNotificationTimer = false;
            notificationTimer      = 0f;
        }
        if (Input.GetKeyDown(KeyCode.Return))
        {
            SubmitLeaderboardScore();
        }
        if (startLoading)
        {
            loadTimer += Time.deltaTime;
        }
        if (loadTimer >= loadThreshold)
        {
            HSController.startGetScores();
            startLoading = false;
            loadTimer    = 0f;
        }


        if (setTheScore)
        {
            if (!startLoading)
            {
                if (localPassword == HSController.retrievedID || HSController.retrievedID == "" || HSController.retrievedID == null)
                {
                    HSController.startGetCurrentScore();
                    startLoading = true;
                    startScoring = true;
                }
                else
                {
                    notificationBox.text = "WRONG PASSWORD!";
                    ClearNotificationBox();
                    //  Debug.Log("WRONG PASSWORD!");
                }
                setTheScore = false;
            }
        }

        if (startScoring && !startLoading)
        {
            // Debug.Log("LOCAL SCORE: " + localScore);
            //Debug.Log("RETRIEVED SCORE: " + HSController.retrievedScore);

            if (localScore < HSController.retrievedScore)
            {
                HSController.startPostScores();
                scoresPosted = true;
                startLoading = true;
            }
            else
            {
                notificationBox.text = "your best is higher or equal!";
                ClearNotificationBox();
                //  Debug.Log("SCORE IS LOWER");
            }
            startScoring = false;
        }
        if (scoresPosted && !startLoading && successStarted)
        {
            HSController.startGetScores();

            successText = "SUCCESS!";

            scoresPosted   = false;
            successStarted = false;
            setSuccessText = true;
            rememberMe.shouldUserBeRemembered = true;
        }
        if (setSuccessText)
        {
            //setting the text like this because setting the text after HSController.startGetScores() caused a null reference exception.
            notificationBox.text = successText;
            ClearNotificationBox();
        }
    }