Ejemplo n.º 1
0
        public async Task ReplaceScore()
        {
            var leaderboard = await SteamUserStats.FindLeaderboardAsync("Testleaderboard");

            Assert.IsTrue(leaderboard.HasValue);

            var result = await leaderboard.Value.ReplaceScore(576);

            Assert.IsTrue(result.HasValue);

            Console.WriteLine($"result.Changed: {result?.Changed}");
            Console.WriteLine($"result.OldGlobalRank: {result?.OldGlobalRank}");
            Console.WriteLine($"result.NewGlobalRank: {result?.NewGlobalRank}");
            Console.WriteLine($"result.RankChange: {result?.RankChange}");
            Console.WriteLine($"result.Score: {result?.Score}");
        }
Ejemplo n.º 2
0
        public async Task StoreStats()
        {
            var result = Result.NotSettled;

            SteamUserStats.OnUserStatsStored += (r) =>
            {
                result = r;
            };

            SteamUserStats.StoreStats();

            while (result == Result.NotSettled)
            {
                await Task.Delay(10);
            }

            Assert.AreEqual(result, Result.OK);
        }
        public async Task GetScoresAroundUserAsync()
        {
            var leaderboard = await SteamUserStats.FindLeaderboard("Testleaderboard");

            Assert.IsTrue(leaderboard.HasValue);

            // Get entries around user
            var relativeScores = await leaderboard.Value.GetScoresAroundUserAsync(-5, 5);

            Assert.IsNotNull(relativeScores);

            Console.WriteLine($"");
            Console.WriteLine($"Relative Scores:");
            foreach (var e in relativeScores)
            {
                Console.WriteLine($"{e.GlobalRank}: {e.Score} {e.User}");
            }
        }
Ejemplo n.º 4
0
        public async Task GetScoresAsync()
        {
            var leaderboard = await SteamUserStats.FindLeaderboardAsync("Testleaderboard");

            Assert.IsTrue(leaderboard.HasValue);

            // Get top 20 global scores
            var globalsScores = await leaderboard.Value.GetScoresAsync(20);

            Assert.IsNotNull(globalsScores);

            Console.WriteLine($"");
            Console.WriteLine($"Global Scores:");
            foreach (var e in globalsScores)
            {
                Console.WriteLine($"{e.GlobalRank}: {e.Score} {e.User}");
            }
        }
        public async Task GetScoresFromFriends()
        {
            var leaderboard = await SteamUserStats.FindLeaderboard("Testleaderboard");

            Assert.IsTrue(leaderboard.HasValue);

            // Get entries around user
            var friendScores = await leaderboard.Value.GetScoresFromFriends();

            Assert.IsNotNull(friendScores);

            Console.WriteLine($"");
            Console.WriteLine($"Friend Scores:");
            foreach (var e in friendScores)
            {
                Console.WriteLine($"{e.GlobalRank}: {e.Score} {e.User}");
            }
        }
Ejemplo n.º 6
0
        public static void Shutdown()
        {
            Event.DisposeAllClient();

            initialized = false;

            SteamApps.Shutdown();
            SteamUtils.Shutdown();
            SteamParental.Shutdown();
            SteamMusic.Shutdown();
            SteamVideo.Shutdown();
            SteamUser.Shutdown();
            SteamFriends.Shutdown();
            SteamScreenshots.Shutdown();
            SteamUserStats.Shutdown();
            SteamInventory.Shutdown();

            SteamAPI.Shutdown();
        }
Ejemplo n.º 7
0
 public static void Shutdown()
 {
     Event.DisposeAllClient();
     SteamClient.initialized = false;
     SteamClient.ShutdownInterfaces();
     SteamApps.Shutdown();
     SteamUtils.Shutdown();
     SteamParental.Shutdown();
     SteamMusic.Shutdown();
     SteamVideo.Shutdown();
     SteamUser.Shutdown();
     SteamFriends.Shutdown();
     SteamScreenshots.Shutdown();
     SteamUserStats.Shutdown();
     SteamInventory.Shutdown();
     SteamNetworking.Shutdown();
     SteamMatchmaking.Shutdown();
     SteamParties.Shutdown();
     SteamNetworkingUtils.Shutdown();
     SteamNetworkingSockets.Shutdown();
     Base.Shutdown();
     SteamAPI.Shutdown();
 }
Ejemplo n.º 8
0
        public static void Init(uint appid)
        {
            if (IntPtr.Size != 8)
            {
                throw new System.Exception("Only 64bit processes are currently supported");
            }

            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;


            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();
            SteamNetworking.InstallEvents();
            SteamMatchmaking.InstallEvents();
            SteamParties.InstallEvents();
            SteamNetworkingSockets.InstallEvents();

            RunCallbacksAsync();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initialize the steam client.
        /// If asyncCallbacks is false you need to call RunCallbacks manually every frame.
        /// </summary>
        public static void Init(uint appid, bool asyncCallbacks = true)
        {
            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;

            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();
            SteamNetworking.InstallEvents();
            SteamMatchmaking.InstallEvents();
            SteamParties.InstallEvents();
            SteamNetworkingSockets.InstallEvents();
            SteamInput.InstallEvents();
            SteamUGC.InstallEvents();

            if (asyncCallbacks)
            {
                RunCallbacksAsync();
            }
        }
Ejemplo n.º 10
0
        public async Task FindLeaderboard()
        {
            var leaderboard = await SteamUserStats.FindLeaderboardAsync("Testleaderboard");

            Assert.IsTrue(leaderboard.HasValue);
        }
Ejemplo n.º 11
0
        public async Task CreateLeaderboard()
        {
            var leaderboard = await SteamUserStats.FindOrCreateLeaderboardAsync("Testleaderboard", Data.LeaderboardSort.Ascending, Data.LeaderboardDisplay.Numeric);

            Assert.IsTrue(leaderboard.HasValue);
        }
        public static bool AddStat(string name, float amount = 1f)
        {
            float statFloat = SteamUserStats.GetStatFloat(name);

            return(SteamUserStats.SetStat(name, statFloat + amount));
        }
        public static bool AddStat(string name, int amount = 1)
        {
            int statInt = SteamUserStats.GetStatInt(name);

            return(SteamUserStats.SetStat(name, statInt + amount));
        }