Exemplo n.º 1
0
        public void Update(LeaderBoard.Row row, float normalizedScore, bool isFriend, bool inHighlightPlayer, string facebookName = null)
        {
            int xp   = row.Experience > 0 ? row.Experience : row.Score;
            int rank = PlayerPersistantInfo.GetPlayerRankFromExperience(xp);

            string displayname = string.IsNullOrEmpty(row.DisplayName) ? row.PrimaryKey : GuiBaseUtils.FixNameForGui(row.DisplayName);

            if (facebookName != null)
            {
                displayname = GuiBaseUtils.FixNickname(facebookName + " (" + displayname + ")", displayname, false);
            }

            m_Order.SetNewText(row.Order < 0 ? "" : row.Order.ToString());
            m_RankText.SetNewText(rank <= 0 ? "" : rank.ToString());
            m_DisplayName.SetNewText(displayname);
            m_Score.SetNewText(row.Score < 0 ? "" : row.Score.ToString("N0"));

            string rankState = string.Format("Rank_{0}", Mathf.Min(rank, m_RankIcon.Count - 1).ToString("D2"));

            m_RankIcon.State = rank <= 0 ? GUIBase_MultiSprite.DefaultState : rankState;

            SetProgress(normalizedScore);

            m_Order.Widget.Color       = inHighlightPlayer ? HIGHLIGHT_COLOR : DEFAULT_COLOR;
            m_DisplayName.Widget.Color = inHighlightPlayer ? HIGHLIGHT_COLOR : DEFAULT_COLOR;
            m_Score.Widget.Color       = inHighlightPlayer ? HIGHLIGHT_COLOR : DEFAULT_COLOR;

            m_FriendIcon.FadeAlpha         = isFriend && (facebookName == null) ? 1.0f : 0.0f;
            m_FacebookFriendIcon.FadeAlpha = facebookName != null ? 1.0f : 0.0f;
        }
Exemplo n.º 2
0
    void UpdateView()
    {
        LeaderBoard.Row maxScoreRow = m_ActiveLeaderBoard[0];
        float           maxScore    = (maxScoreRow != null) && (maxScoreRow.Score > 0) ? Mathf.Exp(Mathf.Log10((float)maxScoreRow.Score)) : 1.0f;

        var friends = GameCloudManager.friendList.friends;

        for (uint i = 0; i < m_GuiLines.Length; i++)
        {
            uint index = i;
            if (m_RowMapping != null)
            {
                index = (uint)m_RowMapping[i];
            }

            LeaderBoard.Row row = m_ActiveLeaderBoard[index];
            if (row != null)
            {
                float score = row.Score > 0 ? Mathf.Exp(Mathf.Log10((float)row.Score)) : 0.0f;

                bool   isFriend     = friends.Find(obj => obj.PrimaryKey == row.PrimaryKey) != null;
                string facebookName = null;

                m_GuiLines[i].Show();
                m_GuiLines[i].Update(row, score / maxScore, isFriend, row.LocalUser, facebookName);
            }
            else
            {
                m_GuiLines[i].Hide();
            }
        }

        m_Table.MaxItems = m_ActiveLeaderBoard.RowCount();
        m_Table.Widget.SetModify();
    }