Пример #1
0
    void SaveHighScore(float score)
    {
        //create a variable to hold the current high score
        float currentHighScore;

        //check if we have a saved high score
        if (PlayerPrefs.HasKey("HighScore"))
        {
            //if we do save it to our holder variable
            currentHighScore = PlayerPrefs.GetFloat("HighScore");
        }
        //if we don't, set our holder variable to the max value
        //for an int. We do this so that we have a current high score is
        //initialized but the value will always be higher than the players
        //score
        else
        {
            currentHighScore = int.MaxValue;
        }

        //if our current high score is greater (lower time is better)
        //than our score we update the saved high score
        if (currentHighScore > score)
        {
#if UNITY_METRO
            //if we are on Windows 8.1 we call our Share function
            //and update our Live Tile
            WindowsGateway.ShareHighScore();
            UpdateTile(score);
#endif
            PlayerPrefs.SetFloat("HighScore", score);
        }
    }
Пример #2
0
    void OnGUI()
    {
        #region LOGIN KEYBOARD
        if (mLoginState == LoginState.Default)
        {
            // Only show the Login Success message when LoginState.Default mode.
            if (isLoginSuccess)
            {
                GUI.Label(new Rect(xCancelBtn, INPUT_OFFSET, WELCOME_LABEL_WIDTH, INPUT_HEIGHT), successMessage, mGUIStyleLabel);
            }

            if (GUI.Button(new Rect(xLoginBtn, INPUT_OFFSET, INPUT_WIDTH, INPUT_HEIGHT), INPUT_BTN_LOGIN, mGUIStyleBtnInput))
            {
                mLoginState = LoginState.LoginAndCancel;
                if (mKeyboard == null)
                {
                    mKeyboard        = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, true, false, false, false);
                    mKeyboard.active = true;
                }
                else if (!mKeyboard.active)
                {
                    mInputUserName   = "";
                    mKeyboard.active = true;
                }
            }
        }
        else if (mLoginState == LoginState.LoginAndCancel)
        {
            //mInputUserName = GUI.TextField(new Rect(xTextField, INPUT_OFFSET, TEXTFIELD_WIDTH, INPUT_HEIGHT), mInputUserName, 16, mGUIStyleTextField);

            GUI.Label(mRectTextField, mInputUserName, mGUIStyleTextField);
            if (!isMouseDownOnInputField && !mKeyboard.active && mRectTextField.Contains(Event.current.mousePosition) && Input.GetMouseButtonDown(0))
            {
                isMouseDownOnInputField = true;
            }

            if (GUI.Button(new Rect(xLoginBtn, INPUT_OFFSET, INPUT_WIDTH, INPUT_HEIGHT), INPUT_BTN_CONFIRM, mGUIStyleBtnInput))
            {
                // TODO: Check database for login information.


                // RETURN: When user confirms login, check login information is correct
                isLoginSuccess = true;
                successMessage = "Welcome, " + mInputUserName + "!";
                mLoginState    = LoginState.Default;
            }

            if (GUI.Button(new Rect(xCancelBtn, INPUT_OFFSET, INPUT_WIDTH, INPUT_HEIGHT), INPUT_BTN_CANCEL, mGUIStyleBtnInput))
            {
                mLoginState = LoginState.Default;
            }
        }
        #endregion // LOGIN KEYBOARD

        if (GUI.Button(new Rect(xPos, yPos, BUTTON_SIZE, BUTTON_SIZE), "", mGUIStyleBtnPlay))
        {
            WindowsGateway.OnClickPlay();
            Application.LoadLevel("Level");
        }
    }
Пример #3
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(xPos, yPos, BUTTON_SIZE, BUTTON_SIZE), "", m_GUIStyleBtn))
     {
         Debug.Log("Press Play");
         Application.LoadLevel("Level");
         WindowsGateway.OnClickPlay();
     }
 }
Пример #4
0
    void Start()
    {
        _version = MyPlugin.WindowsPlugin.Instance.GetAppVersion();
        _score   = GameObject.Find("Score").GetComponent <Score>();

        InitialiseSound();

#if UNITY_WINRT && !UNITY_EDITOR
        WindowsGateway.Initialize();
        WindowsGateway.UnityLoaded();
#endif
    }