Ejemplo n.º 1
0
        public virtual void UpdateUI()
        {
            if (m_pData != null)
            {
                ProfileId     = m_pData.ProfileId;
                Pos.text      = m_pData.PlayerRank.ToString();
                UserName.text = m_pData.PlayerName == "" ? DEFAULT_NAME : m_pData.PlayerName;

                Dictionary <string, object> extraData = m_pData.GetCurrentLeaderboardExtraData();
                if (extraData != null && extraData.ContainsKey(BrainCloudConsts.JSON_RANK) && extraData.ContainsKey(BrainCloudConsts.JSON_LEVEL))
                {
                    Rank.text = extraData[BrainCloudConsts.JSON_RANK] as string + " " + "(" + extraData[BrainCloudConsts.JSON_LEVEL] as string + ")";
                }
                //TODO: Remove the Rank's value "(3)" before shipping.

                Kills.text = HudHelper.ToGUIString((Mathf.Floor(float.Parse(m_pData.PlayerRating.ToString()) / 10000) + 1));

                Color color = IsYou ? Color.white : notYou;
                Pos.color      = color;
                UserName.color = color;
                Rank.color     = color;
                Kills.color    = color;

                PlayerRankIcon.UpdateIcon(int.Parse(extraData[BrainCloudConsts.JSON_LEVEL] as string));
            }
        }
Ejemplo n.º 2
0
        private void OnUpdateStats()
        {
            if (m_statsPanelContentLeft != null)
            {
                // clear all stats
                for (int i = 0; i < m_statsPanelContentLeft.transform.childCount; ++i)
                {
                    Destroy(m_statsPanelContentLeft.transform.GetChild(i).gameObject);
                    Destroy(m_statsPanelContentRight.transform.GetChild(i).gameObject);
                }

                List <BrainCloudStats.Stat> playerStats = BrainCloudStats.Instance.GetStats();
                XPData xpData       = GPlayerMgr.Instance.PlayerData.PlayerXPData;
                int    currentLevel = xpData.CurrentLevel;

                if (GPlayerMgr.Instance.PlayerData.PlayerRank != currentLevel)
                {
                    // Update the PlayerSummaryData only if the Player's rank has changed
                    GPlayerMgr.Instance.PlayerData.PlayerRank = currentLevel;
                    GPlayerMgr.Instance.UpdatePlayerSummaryData();
                    PlayerRankIcon.UpdateIcon(GPlayerMgr.Instance.PlayerData.PlayerRank);
                }

                string rank = BrainCloudStats.Instance.m_playerLevelTitles[0] + "(" + GPlayerMgr.Instance.PlayerData.PlayerXPData.CurrentLevel + ")";

                if (currentLevel > 0 && currentLevel < BrainCloudStats.Instance.m_playerLevelTitles.Length)
                {
                    rank = BrainCloudStats.Instance.m_playerLevelTitles[currentLevel - 1] + " (" + currentLevel + ")";
                }
                // over max
                else if (currentLevel > 0)
                {
                    rank = BrainCloudStats.Instance.m_playerLevelTitles[BrainCloudStats.Instance.m_playerLevelTitles.Length - 1] + " (" + currentLevel + ")";
                }

                if (m_statsImage == null)
                {
                    m_statsImage = m_statsPanelContentLeft.transform.parent.parent.parent.FindDeepChild("XpBar").GetComponent <Image>();
                }

                m_statsImage.fillAmount = Mathf.InverseLerp(xpData.PrevThreshold, xpData.NextThreshold, xpData.ExperiencePoints);

                Text tempText = null;
                for (int i = 2; i < playerStats.Count; ++i)
                {
                    tempText           = Instantiate(m_statText, m_statsPanelContentLeft.transform).GetComponent <Text>();
                    tempText.alignment = TextAnchor.MiddleLeft;
                    tempText.text      = "  " + playerStats[i].Name;
                    tempText           = Instantiate(m_statValue, m_statsPanelContentRight.transform).GetComponent <Text>();
                    tempText.text      = HudHelper.ToGUIString(playerStats[i].Value);
                }
                GameObject.Find("RankText").GetComponent <Text>().text = rank;
            }
        }
Ejemplo n.º 3
0
        private void updateInfo()
        {
            // load from IAP?
            if (m_product != null)
            {
                if (TicketsNonSale != null)
                {
                    TicketsNonSale.SetActive(false);
                }
                if (TicketSale != null)
                {
                    TicketSale.SetActive(false);
                }

                long currencyValue = HudHelper.GetLongValue(m_product.CurrencyRewards, "coins");
                if (currencyValue > 0)
                {
                    //TitleIcon.sprite = CoinIconSprite;
                }

                Label.text = HudHelper.ToGUIString(currencyValue) + " " + m_product.Category;

                string desc = m_product.LongDescription;
                desc             = desc.Replace("\\n", "\n");
                Description.text = desc;

                Title.text     = m_product.Title;
                ValueCost.text = m_product.PriceString;

                SaleContainer.SetActive(m_product.IsPromotion);
                if (m_product.IsPromotion && m_product.RegularPrice > 0)
                {
                    RegularPrice.text   = m_product.RegularPriceString;
                    SalePrice.text      = m_product.PriceString;
                    SalePercentage.text = "" + HudHelper.QuickRound((1.0f - (float)(m_product.Price / m_product.RegularPrice)) * 100.0f) + "%";
                }

                // Check if this is the Gold Wing product
                // If we have already purchased it, update the button to reflect this.
                if (m_product.BrainCloudProductID.Equals("GoldWings") && GPlayerMgr.Instance.GetCurrencyBalance(GBomberRTTConfigManager.CURRENCY_GOLD_WINGS) > 0)
                {
                    ValueCost.text         = "Purchased";
                    BuyButton.interactable = false;
                }
            }
        }