Exemplo n.º 1
0
        /// <summary>
        /// Checks whether local user is a member of a clan, then disables or enables <see cref="_showClan"/>
        /// button accordingly. Shows this menu.
        /// </summary>
        public async override void Show()
        {
            Client   client  = NakamaSessionManager.Instance.Client;
            ISession session = NakamaSessionManager.Instance.Session;

            // If local user is not a member of a clan, disable clan leaderboards
            IUserGroupListUserGroup clan = await ClanManager.GetUserClanAsync(client, session);

            if (clan != null)
            {
                _showClan.gameObject.SetActive(true);
            }
            else
            {
                // User is not a member of any clan
                // Hiding clan score tab

                if (_showClan.interactable == true)
                {
                    // Last showed tab is clan tab
                    // Switching to other tab
                    ShowGlobalLeaderboards();
                }
                _showClan.gameObject.SetActive(false);
            }


            base.Show();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fills <see cref="_userList"/> with records of all members of the clan local user belongs to.
        /// </summary>
        public async void ShowClanLeaderboards(string cursor)
        {
            IUserGroupListUserGroup clan = await ClanManager.GetUserClanAsync(Client, Session);

            if (clan == null)
            {
                return;
            }
            IApiLeaderboardRecordList records = await LeaderboardManager.GetClanLeaderboarsAsync(Client, Session, clan.Group, _recordsPerPage, cursor);

            if (records != null)
            {
                SetLeaderboardsCursor(records, ShowClanLeaderboards);
                FillLeaderboard(records.OwnerRecords);

                _showFriends.interactable = true;
                _showClan.interactable    = false;
                _showGlobal.interactable  = true;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets fields of this panel to show <see cref="PlayerData"/> gathered from <paramref name="user"/>.
        /// </summary>
        /// <param name="user">User to be displayed in this panel.</param>
        private async Task <bool> PopulateDataAsync(IApiUser user)
        {
            Client   client  = NakamaSessionManager.Instance.Client;
            ISession session = NakamaSessionManager.Instance.Session;

            PlayerData data = await _playerDataStorage.LoadDataAsync(user.Id, "player_data");

            IUserGroupListUserGroup clan = await ClanManager.GetUserClanAsync(client, session, user.Id);

            Deck deck = await _deckStorage.LoadDataAsync(user.Id, "deck");

            if (data != null && deck != null)
            {
                _usernameText.text = user.Username;
                _statsText.text    = GenerateStats(data).TrimEnd();

                if (clan != null)
                {
                    _clanNameText.text = clan.Group.Name;
                }
                else
                {
                    _clanNameText.text = "<i><color=#b0b0b0>[Not a clan member yet]</color></i>";
                }

                for (int i = 0; i < deck.usedCards.Count; i++)
                {
                    Card card = deck.usedCards[i];
                    _cardSlots[i].SetCard(card);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }