Exemplo n.º 1
0
    private void DrawUI()
    {
        Transform[] childLBElements = LeaderboardPanel.GetComponentsInChildren <Transform>();
        foreach (Transform childObject in childLBElements)
        {
            if (!LeaderboardPanel.transform.IsChildOf(childObject.transform))
            {
                Destroy(childObject.gameObject);
            }
        }
        // Populate leaderboard
        for (int i = 0; i < scores.leaderboard.Count; i++)
        {
            GameObject         LBgameObject = Instantiate(LeaderboardItemPrefab);
            LeaderBoardElement LBelement    = LBgameObject.GetComponent <LeaderBoardElement>();
            LBelement.SetupElement(i + 1, scores.leaderboard[i]);
            LBelement.transform.SetParent(LeaderboardPanel.transform, false);
        }

        // Scroll to top
        LeaderboardScrollRect.verticalNormalizedPosition = 1f;
    }
Exemplo n.º 2
0
    // Method to update the Game Menu User Interface
    public void RedrawUI()
    {
        if (FB.IsLoggedIn)
        {
            // Swap GUI Header for a player after login
            HeaderLoggedIn.SetActive(true);
            HeaderNotLoggedIn.SetActive(false);

            // Show HighScore if we have one
            if (GameStateManager.HighScore > 0)
            {
                ScoreText.text = "Score: " + GameStateManager.HighScore.ToString();
            }

            //Set Coin and Bomb counters
            CoinText.text = GameStateManager.CoinBalance.ToString();
            BombText.text = GameStateManager.NumBombs.ToString();
        }

        if (GameStateManager.UserTexture != null && !string.IsNullOrEmpty(GameStateManager.Username))
        {
            // Update Profile Picture
            ProfilePic.enabled = true;
            ProfilePic.texture = GameStateManager.UserTexture;

            // Update Welcome Text
            WelcomeText.text = "Welcome " + GameStateManager.Username + "!";

            // Disable loading animation
            LoadingText.SetActive(false);
        }

        var scores = GameStateManager.Scores;

        if (GameStateManager.ScoresReady && scores.Count > 0)
        {
            // Clear out previous leaderboard
            Transform[] childLBElements = LeaderboardPanel.GetComponentsInChildren <Transform>();
            foreach (Transform childObject in childLBElements)
            {
                if (!LeaderboardPanel.transform.IsChildOf(childObject.transform))
                {
                    Destroy(childObject.gameObject);
                }
            }

            // Populate leaderboard
            for (int i = 0; i < scores.Count; i++)
            {
                GameObject         LBgameObject = Instantiate(LeaderboardItemPrefab) as GameObject;
                LeaderBoardElement LBelement    = LBgameObject.GetComponent <LeaderBoardElement>();
                LBelement.SetupElement(i + 1, scores[i]);
                LBelement.transform.SetParent(LeaderboardPanel.transform, false);
            }

            // Scroll to top
            LeaderboardScrollRect.verticalNormalizedPosition = 1f;
        }

        // Update PaymentPanel UI
        PaymentPanel.GetComponent <PaymentDialog>().UpdateUI();
    }