//public static async Task GetInventoryCount() //{ // // disable start buttonn first // await TrinaxAsyncServerManager.Instance.GetInventoryCount((bool success, InventoryCountReceiveJsonData rJson) => // { // if (success) // { // if (rJson.data > 0) // { // Debug.Log(string.Format("Inventory Count: {0}", rJson.data)); // GameManager.Instance.startGameBtn.interactable = true; // } // else // { // GameManager.Instance.startGameBtn.interactable = false; // } // } // }); //} //public static async Task AddPlayer() //{ // AddPlayerSendJsonData sJson = new AddPlayerSendJsonData(); // await TrinaxAsyncServerManager.Instance.AddPlayer(sJson, (bool success, AddPlayerReceiveJsonData rJson) => // { // if (success && !string.IsNullOrEmpty(rJson.data)) // { // GameManager.Instance.PLAYER_ID = rJson.data; // Debug.Log(string.Format("Send: {0}, {1}, {2}", GameManager.Instance.firstName, GameManager.Instance.lastName, GameManager.Instance.scoreManager.ScoredPairs)); // APICalls.GetResult().WrapErrors(); // } // else // { // Debug.LogWarning("ERROR: Did not add player to table!"); // } // }); //} //public static async Task GetResult() //{ // await TrinaxAsyncServerManager.Instance.GetResult((bool success, GetResultReceiveJsonData rJson) => // { // if (success) // { // if (rJson.data) // { // Debug.Log("Player only did not get gift twice! Dispensing gift..."); // GameManager.Instance.doDispense = true; // } // else // { // Debug.Log("Player already received gift twice! Do not dispense gift"); // GameManager.Instance.doDispense = false; // } // } // else // { // Debug.Log("Player already received gift twice! Do not dispense gift"); // GameManager.Instance.doDispense = false; // } // }); // //GameManager.Instance.CheckIfCanDispense(); //} //public static async Task DispenseGift() //{ // await TrinaxAsyncServerManager.Instance.DispenseGift((bool success, dispenseGiftReceiveJsonData rJson) => // { // if (success) // { // if (rJson.data) // { // Debug.Log("Dispensed out gift "); // } // else { Debug.LogWarning("ERROR: Did not dispense gift!"); } // } // else // { // Debug.LogWarning("ERROR: Did not dispense gift!"); // } // }); //} public static async Task RunPopulateLeaderboard(LeaderboardDisplay lb) { List <PlayerInfo> playerInfoList = new List <PlayerInfo>(); await TrinaxAsyncServerManager.Instance.PopulateLeaderboard((bool success, LeaderboardReceiveJsonData rJson) => { if (success) { if (rJson.data != null) { for (int i = 0; i < rJson.data.Count; i++) { PlayerInfo info = new PlayerInfo { rank = int.Parse(rJson.data[i].playerid), name = rJson.data[i].name, mobile = rJson.data[i].mobile, score = rJson.data[i].score, }; playerInfoList.Add(info); } lb.PopulateData(playerInfoList); } else { Debug.Log("no data"); } } else { Debug.Log("Error in <getLeaderBoard> API!"); lb.PopulateDefault(); } }); }
public static async Task RunUpdateLeaderboard(LeaderboardDisplay lb) { await TrinaxManager.trinaxAsyncServerManager.PopulateLeaderboard((bool success, LeaderboardReceiveJsonData rJson) => { if (success) { if (rJson.data != null) { Debug.Log("Success populated leaderboard!"); lb.PopulateData(rJson); var last = rJson.data[rJson.data.Count - 1]; AppManager.gameManager.lastPlaceScore = last.score; } } else { Debug.Log("Error in <GetTopScore> API!"); lb.PopulateDefault(); } }); }
internal CallResult <LeaderboardFindResult_t> FindOrCreateLeaderboard([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string pchLeaderboardName, LeaderboardSort eLeaderboardSortMethod, LeaderboardDisplay eLeaderboardDisplayType) { var returnValue = _FindOrCreateLeaderboard(Self, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType); return(new CallResult <LeaderboardFindResult_t>(returnValue)); }
private static extern SteamAPICall_t _FindOrCreateLeaderboard(IntPtr self, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string pchLeaderboardName, LeaderboardSort eLeaderboardSortMethod, LeaderboardDisplay eLeaderboardDisplayType);
/// <summary> /// Gets a leaderboard by name, it will create it if it's not yet created. /// Leaderboards created with this function will not automatically show up in the Steam Community. /// You must manually set the Community Name field in the App Admin panel of the Steamworks website. /// As such it's generally recommended to prefer creating the leaderboards in the App Admin panel on /// the Steamworks website and using FindLeaderboard unless you're expected to have a large amount of /// dynamically created leaderboards. /// </summary> public static async Task <Leaderboard?> FindOrCreateLeaderboardAsync(string name, LeaderboardSort sort, LeaderboardDisplay display) { var result = await Internal.FindOrCreateLeaderboard(name, sort, display); if (!result.HasValue || result.Value.LeaderboardFound == 0) { return(null); } return(new Leaderboard { Id = result.Value.SteamLeaderboard }); }
//The process to update a LeaderboardRow public static void UpdateLeaderboardRow(LeaderboardRow leaderboardRow) { //DoWork function is really intensive so it's called only when absolutely required //This function will calculate the total max possible score for either OST or with extras void DoWork(bool e) { Il2CppSystem.Collections.Generic.List <SongList.SongData> songs = SongList.I.songs; int totalMaxScore = 0; for (int i = 0; i < songs.Count; i++) { SongList.SongData song = songs[i]; if (e) { if (song.dlc | song.unlockable) { totalMaxScore += starThresholds.GetMaxRawScore(song.songID, KataConfig.Difficulty.Expert); } } if (song.dlc == false && song.unlockable == false && song.extrasSong == false) { totalMaxScore += starThresholds.GetMaxRawScore(song.songID, KataConfig.Difficulty.Expert); } } if (e) { extrasMaxTotalScore = totalMaxScore; } else { ostMaxTotalScore = totalMaxScore; } } float score = Convert.ToSingle(leaderboardRow.mData.score.Split('.')[0]); float percentage; if (menuState != MenuState.State.MainPage) { percentage = GetScorePercentage(selectedSong, score, KataConfig.Difficulty.Expert); } else { LeaderboardDisplay leaderboardDisplay = UnityEngine.Object.FindObjectOfType <LeaderboardDisplay>(); bool extras = leaderboardDisplay.extrasButton.IsChecked.Invoke(); DoWork(extras); if (extras) { if (extrasMaxTotalScore == 0) { DoWork(extras); } percentage = (score / extrasMaxTotalScore) * 100; } else { if (ostMaxTotalScore == 0) { DoWork(extras); } percentage = (score / ostMaxTotalScore) * 100; } } //Make pretty-ish strings leaderboardRow.username.text = "<size=" + leaderboardUsernameSize + ">" + leaderboardRow.username.text + "</size>"; string scoreString = "<size=" + leaderboardHighScoreSize + ">" + String.Format("{0:n0}", score).Replace(",", " ") + "</size>"; string percentageString = "<size=" + leaderboardPercentSize + "> (" + String.Format("{0:0.00}", percentage) + "%)</size>"; //Update label if (leaderboardRow.score.text.Contains("<color=yellow>")) { leaderboardRow.score.text = "<color=" + leaderboardUserColor + ">" + scoreString + percentageString + "</color>"; } else { leaderboardRow.score.text = scoreString + percentageString; } if (leaderboardRow.rank.text.Contains("<color=yellow>")) { leaderboardRow.rank.text = leaderboardRow.rank.text.Replace("<color=yellow>", "<color=" + leaderboardUserColor + ">"); } if (leaderboardRow.username.text.Contains("<color=yellow>")) { leaderboardRow.username.text = leaderboardRow.username.text.Replace("<color=yellow>", "<color=" + leaderboardUserColor + ">"); } }
internal async Task <LeaderboardFindResult_t?> FindOrCreateLeaderboard([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string pchLeaderboardName, LeaderboardSort eLeaderboardSortMethod, LeaderboardDisplay eLeaderboardDisplayType) { return(await LeaderboardFindResult_t.GetResultAsync(_FindOrCreateLeaderboard( Self, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType ))); }
internal async Task <LeaderboardFindResult_t?> FindOrCreateLeaderboard(string pchLeaderboardName, LeaderboardSort eLeaderboardSortMethod, LeaderboardDisplay eLeaderboardDisplayType) { return(await LeaderboardFindResult_t.GetResultAsync(_FindOrCreateLeaderboard( Self, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType ))); }
public static async Task <Leaderboard?> FindOrCreateLeaderboardAsync(string name, LeaderboardSort sort, LeaderboardDisplay display) { Leaderboard? nullable; bool flag; LeaderboardFindResult_t?nullable1 = await SteamUserStats.Internal.FindOrCreateLeaderboard(name, sort, display); LeaderboardFindResult_t?nullable2 = nullable1; nullable1 = null; flag = (!nullable2.HasValue ? true : nullable2.Value.LeaderboardFound == 0); if (!flag) { nullable = new Leaderboard?(new Leaderboard() { Id = nullable2.Value.SteamLeaderboard }); } else { nullable = null; } return(nullable); }
void Awake() { Instance = this; // DontDestroyOnLoad (gameObject); }