Esempio n. 1
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public static void Initialize()
        {
            if (Leaderboards.Initialized)
            {
                return;
            }

            Leaderboards.GlobalPlayers = new LeaderboardPlayers();
            Leaderboards.GlobalClans   = new LeaderboardClans();

            Leaderboards.RegionalPlayers = new Dictionary <string, LeaderboardPlayers>();
            Leaderboards.RegionalClans   = new Dictionary <string, LeaderboardClans>();

            foreach (RegionData Region in CsvFiles.Get(Gamefile.Regions).Datas)
            {
                Leaderboards.RegionalPlayers.Add(Region.Name, new LeaderboardPlayers(Region));
                Leaderboards.RegionalClans.Add(Region.Name, new LeaderboardClans(Region));
            }

            Leaderboards.Initialized = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the specified <see cref="Message"/>.
        /// </summary>
        /// <param name="Device">The device.</param>
        /// <param name="Message">The message.</param>
        /// <param name="Cancellation">The cancellation.</param>
        public static async Task Handle(Device Device, Message Message, CancellationToken Cancellation)
        {
            var AskForAvatarRankingListMessage = (AskForAvatarRankingListMessage)Message;

            if (AskForAvatarRankingListMessage == null)
            {
                throw new LogicException(typeof(AskForAvatarRankingListHandler), nameof(AskForAvatarRankingListMessage) + " == null at Handle(Device, Message, CancellationToken).");
            }

            LeaderboardPlayers Leaderboard = Leaderboards.GlobalPlayers;

            if (Leaderboard != null)
            {
                Device.NetworkManager.SendMessage(new AvatarRankingListMessage()
                {
                    Entries           = Leaderboard.Players.ToArray(),
                    LastSeasonEntries = Leaderboard.LastSeason.ToArray()
                });
            }
            else
            {
                Logging.Error(typeof(AskForAvatarRankingListHandler), "Leaderboard == null at Handle(Device, Message, CancellationToken).");
            }
        }