Exemplo n.º 1
0
        public LeaderboardSystem(IPoolManager poolManager)
        {
            var accessor = poolManager.CreateGroupAccessor(new HasScoreGroup());

            _leaderboardFilter          = new LeaderboardFilter(accessor);
            _cacheableLeaderboardFilter = new CacheableLeaderboardFilter(accessor);
            _leaderBoardText            = GameObject.Find("Leaderboard").GetComponent <Text>();
            _useCacheToggle             = GameObject.Find("UseCache").GetComponent <Toggle>();
        }
        private void UpdateData(uint pageNumber, LeaderboardFilter filter)
        {
            this.viewFilter = filter;

            if (!this.isLocalUserAdded)
            {
                return;
            }

            if (this.stat == null)
            {
                return;
            }

            if (this.xboxLiveUser == null)
            {
                this.xboxLiveUser = SignInManager.Instance.GetPlayer(this.PlayerNumber);
            }

            LeaderboardQuery query;

            if (pageNumber == this.currentPage + 1 && this.leaderboardData != null && this.leaderboardData.HasNext)
            {
                query = this.leaderboardData.GetNextQuery();
            }
            else
            {
                socialGroup = LeaderboardHelper.GetSocialGroupFromLeaderboardType(this.leaderboardType);
                if (filter == LeaderboardFilter.Default)
                {
                    query = new LeaderboardQuery()
                    {
                        SkipResultToRank = pageNumber == 0 ? 0 : ((pageNumber - 1) * this.entryCount),
                        MaxItems         = this.entryCount,
                    };
                }
                else
                {
                    query = new LeaderboardQuery()
                    {
                        SkipResultToMe = true,
                        MaxItems       = this.entryCount,
                    };
                }
            }

            this.currentPage = pageNumber;
            XboxLive.Instance.StatsManager.GetLeaderboard(this.xboxLiveUser, this.stat.ID, query);
        }
        public void LoadView(int newFilterNumber)
        {
            if (newFilterNumber >= Enum.GetNames(typeof(LeaderboardFilter)).Length)
            {
                newFilterNumber = 0;
            }

            if (newFilterNumber < 0)
            {
                newFilterNumber = Enum.GetNames(typeof(LeaderboardFilter)).Length - 1;
            }

            this.viewFilter = (LeaderboardFilter)newFilterNumber;

            this.Clear();
            this.UpdateData(0, this.viewFilter);
            this.ViewSelector.SelectFilter(newFilterNumber);
        }
Exemplo n.º 4
0
        public IActionResult GetLeaderboard(LeaderboardFilter filter)
        {
            if (filter != null)
            {
                var leaderboard = _leaderboardService.GetLeaderboard(filter);

                if (leaderboard != null)
                {
                    int pages = (int)Math.Ceiling(Convert.ToDouble(leaderboard.TotalEntries) / Convert.ToDouble(filter.Count));

                    var result = new LeaderboardViewModel()
                    {
                        Leaderboard  = leaderboard,
                        Page         = filter.Page,
                        NextPage     = filter.Page >= pages ? pages : filter.Page + 1,
                        PreviousPage = filter.Page > 1 ? filter.Page - 1 : 1
                    };
                    return(Ok(result));
                }
            }
            return(NotFound());
        }
Exemplo n.º 5
0
 public static extern void _native_getScores(uint category, LeaderboardFilter filter, uint offset, List <HighScore> result);
Exemplo n.º 6
0
        /// <summary>
        /// gets highscores for a given leaderboard
        /// </summary>
        /// <param name="leaderboard">the leaderbaord to get the scores for</param>
        /// <param name="sortby">the sort order for the leaderboard</param>
        /// <param name="fillter">the range of scores to get</param>
        /// <param name="offset">score offset, the rank to start getting scors from</param>
        /// <param name="scoresToGet">total number of scores to get</param>
        /// <returns>returns the socres for the leaderboard. returns null when failes</returns>
        public static List <HighScore> GetCatchedScores(string leaderboard, SortOrder sortby, LeaderboardFilter fillter, int offset = 0, int scoresToGet = 100)
        {
            NEX_Category?category = CategoryHelper.GetCategory(leaderboard);

            if (category == null)
            {
                throw new Exception("Category does not exits!");
            }
            throw new NotImplementedException();
        }
Exemplo n.º 7
0
        /// <summary>
        /// gets highscores for a given leaderboard
        /// </summary>
        /// <param name="leaderboard">the leaderbaord to get the scores for</param>
        /// <param name="sortby">the sort order for the leaderboard</param>
        /// <param name="fillter">the range of scores to get</param>
        /// <param name="offset">score offset, the rank to start getting scors from</param>
        /// <param name="scoresToGet">total number of scores to get</param>
        /// <returns>returns the socres for the leaderboard. returns null when failes</returns>
        public static List <HighScore> GetScores(string leaderboard, SortOrder sortby, LeaderboardFilter fillter, uint offset = 0, int scoresToGet = 100)
        {
            NEX_Category?category = CategoryHelper.GetCategory(leaderboard);

            if (category == null)
            {
                throw new Exception("Category does not exits!");
            }

            List <HighScore> results = new List <HighScore>();

            IsBussy       = true;
            SendingFailed = false; //this has to be called by the user therefore we want to reset it

#if SWITCH
            _native_getScores((uint)category.Value.Code, fillter, offset, results);
            IsBussy = false;
            if (!asyncComm.result) //if failed
            {
                SendingFailed = true;
                if (results.Count == 0)
                {
                    results = null;
                }
            }
            else
            {
                SendingFailed = false;
            }
            return(results);
#else
            IsBussy = false;
            return(null);
#endif
        }