Beispiel #1
0
    void OnGUI()
    {
        GUIStyle buttonStyle = new GUIStyle("button");

        buttonStyle.fontSize = 32;
        GUIStyle boxStyle = new GUIStyle("box");

        boxStyle.fontSize = 38;

        GUIStyle labelStyle = new GUIStyle("label");

        labelStyle.fontSize  = 18;
        labelStyle.alignment = TextAnchor.LowerCenter;

        GUI.Box(new Rect(padding, boxY, boxWidth, boxHeight), "Main Menu", boxStyle);

        GUI.Label(new Rect(0, boxY - padding - labelStyle.fontSize, buttonWidth, buttonHeight), "Arbiter User Id:" + Arbiter.UserId, labelStyle);
        GUI.Label(new Rect(0, boxY - padding, buttonWidth, buttonHeight), "User Wallet Balance:" + Arbiter.Balance, labelStyle);

        if (GUI.Button(new Rect(padding * 2, buttonHeight + boxY, buttonWidth / 2 - padding / 2, buttonHeight), "Dashboard", buttonStyle))
        {
            Arbiter.DisplayWalletDashboard(OnWalletDashboardClose);
        }

        if (GUI.Button(new Rect(padding * 2.5f + buttonWidth / 2, buttonHeight + boxY, buttonWidth / 2 - padding / 2, buttonHeight), "Free Credits!", buttonStyle))
        {
            Arbiter.SendPromoCredits("100", OnSendPromoCreditsSuccess, ErrorHandler);
            Arbiter.DisplayWalletDashboard(OnWalletDashboardClose);
        }

        if (GUI.Button(new Rect(padding * 2, buttonHeight * 2 + padding + boxY, buttonWidth, buttonHeight), "Cash Challenge", buttonStyle))
        {
            Application.LoadLevel("CashChallenge");
        }

        GUI.Label(new Rect(padding * 2, buttonHeight * 3 + padding + boxY, buttonWidth, buttonHeight), "Entry fee: 50 credits", labelStyle);
        if (GUI.Button(new Rect(padding * 2, buttonHeight * 3 + padding * 2 + boxY, buttonWidth, buttonHeight), "Join Cash Tournament", buttonStyle))
        {
            string betSize = "50";
            Dictionary <string, string> filters = new Dictionary <string, string>();
            filters.Add("level", "2");
            Arbiter.JoinTournament(betSize, filters, JoinTournamentSuccessHandler, FriendlyErrorHandler);
        }

        if (GUI.Button(new Rect(padding * 2, buttonHeight * 4 + padding * 3 + boxY, buttonWidth / 2 - padding / 2, buttonHeight), "Updates", buttonStyle))
        {
            Arbiter.ShowPreviousTournaments(OnViewPreviousTournamentsClosed);
        }

        if (GUI.Button(new Rect(padding * 2.5f + buttonWidth / 2, buttonHeight * 4 + padding * 3 + boxY, buttonWidth / 2 - padding / 2, buttonHeight), "Previous", buttonStyle))
        {
            Arbiter.ShowPreviousTournaments(OnViewPreviousTournamentsClosed);
        }

        if (GUI.Button(new Rect(padding * 2, buttonHeight * 5 + padding * 4 + boxY, buttonWidth, buttonHeight), "Logout", buttonStyle))
        {
            Arbiter.Logout(LogoutSuccessHandler, ErrorHandler);
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        // Define text and button formatting
        ////////////////////////////////////////
        int      padding      = 10;
        int      buttonHeight = 80;
        int      textHeight   = 40;
        int      buttonWidth  = Screen.width - padding * 2;
        GUIStyle titleStyle   = new GUIStyle("label");

        titleStyle.fontSize         = 48;
        titleStyle.fontStyle        = FontStyle.BoldAndItalic;
        titleStyle.normal.textColor = Color.red;
        titleStyle.alignment        = TextAnchor.MiddleCenter;
        GUIStyle buttonStyle = new GUIStyle("button");

        buttonStyle.fontSize  = 32;
        buttonStyle.fontStyle = FontStyle.Bold;
        GUIStyle defaultTextStyle = new GUIStyle("label");

        defaultTextStyle.fontSize         = 32;
        defaultTextStyle.normal.textColor = Color.black;
        defaultTextStyle.fontStyle        = FontStyle.Bold;
        defaultTextStyle.alignment        = TextAnchor.MiddleCenter;


        // Render title and practice button
        ////////////////////////////////////
        GUI.Label(new Rect(padding, padding, buttonWidth, 80), "Clickster", titleStyle);

        if (GUI.Button(new Rect(padding, 400, buttonWidth, buttonHeight), "Practice", buttonStyle))
        {
            gameState.challenge = null;
            Application.LoadLevel("ClickArena");
        }


        // Arbiter Logic
        ////////////////////////////////////
        if (uiEnabled)
        {
            // If logged into Arbiter, then create and display a Cash Challenge
            if (Arbiter.IsAuthenticated)
            {
                // Opens the Wallet Dashboard for the user to purchase and cashout their credits
                /////////////////////////////////////////////////////////////////////////////////
                if (GUI.Button(new Rect(padding, Screen.height - padding * 2 - buttonHeight * 2, buttonWidth, buttonHeight), "View Arbiter Wallet", buttonStyle))
                {
                    Arbiter.DisplayWalletDashboard(OnWalletClosed);
                }

                // Logout button destroys the current session. If the player authenticated with
                // their device (vs using Game Center), they will lose access to their wallet
                /////////////////////////////////////////////////////////////////////////////////
                if (GUI.Button(new Rect(padding, Screen.height - padding - buttonHeight, buttonWidth, buttonHeight), "Logout", buttonStyle))
                {
                    uiEnabled = false;
                    Arbiter.Logout(LogoutSuccessHandler, DefaultErrorHandler);
                }

                // Cash Challenge Details and Entry Button
                ////////////////////////////////////////////
                if (gameState.challenge != null)
                {
                    GUI.Label(new Rect(padding, 400 + buttonHeight * 2, buttonWidth, buttonHeight), "Cash Challenge", titleStyle);
                    GUI.Label(new Rect(padding, 400 + buttonHeight * 3, buttonWidth, buttonHeight), "Score to beat: " + gameState.challenge.ScoreToBeat, defaultTextStyle);
                    GUI.Label(new Rect(padding, 400 + buttonHeight * 3 + textHeight, buttonWidth, buttonHeight), "Entry fee: " + gameState.challenge.EntryFee, defaultTextStyle);
                    GUI.Label(new Rect(padding, 400 + buttonHeight * 4, buttonWidth, buttonHeight), "Prize: " + gameState.challenge.Prize, defaultTextStyle);
                    if (GUI.Button(new Rect(padding, 400 + buttonHeight * 5, buttonWidth, buttonHeight), "Enter Cash Challenge", buttonStyle))
                    {
                        Arbiter.AcceptCashChallenge(gameState.challenge.Id, OnCashChallengeAccepted, OnCashChallengeError);
                    }
                }

                // If not logged into Arbiter, then display the login options
            }
            else
            {
                // Authenticates with Token stored on the device
                ////////////////////////////////////////////////
                if (GUI.Button(new Rect(padding, Screen.height - padding - buttonHeight, buttonWidth, buttonHeight), "Login with Device", buttonStyle))
                {
                    uiEnabled = false;
                    Arbiter.LoginWithDeviceId(LoginSuccessHandler, DefaultErrorHandler);
                }

                // Uses Unity's social plugin to authenticate with Apple Game Center
                // and then uses that Game Center account to authenticate with Aribter
                //////////////////////////////////////////////////////////////////////
                if (GUI.Button(new Rect(padding, Screen.height - padding * 2 - buttonHeight * 2, buttonWidth, buttonHeight), "Login with Game Center", buttonStyle))
                {
                    uiEnabled = false;
                    Action <bool> processAuth = (success) => {
                        if (success)
                        {
                            Arbiter.LoginWithGameCenter(LoginSuccessHandler, DefaultErrorHandler);
                        }
                        else
                        {
                            Debug.LogError("Could not authenticate to Game Center! Make Sure the user has not disabled Game Center on their device, or have them create an Arbiter Account.");
                        }
                    };
                    Social.localUser.Authenticate(processAuth);
                }
            }
        }
    }