107 lines
2.3 KiB
C#
107 lines
2.3 KiB
C#
using UnityEngine;
|
|
|
|
public class GlobalTournamentSteamworks : MonoBehaviour
|
|
{
|
|
private static GlobalTournamentSteamworks instance;
|
|
|
|
public GlobalTournamentScreen globalTournamentScreen;
|
|
|
|
public string currentLeaderboardName = "GLOBAL_TOURNAMENT_01";
|
|
|
|
public LeaderboardSettings currentLeaderboardSettings;
|
|
|
|
private GlobalSettings globalSettings;
|
|
|
|
public static GlobalTournamentSteamworks Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private GlobalTournamentSteamworks()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
else
|
|
{
|
|
Object.Destroy(base.gameObject);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
globalSettings = GlobalSettings.Instance;
|
|
Initialize();
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
currentLeaderboardSettings = new LeaderboardSettings(currentLeaderboardName);
|
|
currentLeaderboardSettings.objectsToInform.Add(base.gameObject);
|
|
}
|
|
|
|
public LeaderboardSettings GetCurrentLeaderboardSettings()
|
|
{
|
|
return currentLeaderboardSettings;
|
|
}
|
|
|
|
public void OnFindLeaderboard(LeaderboardSettings lbSettings)
|
|
{
|
|
if ((bool)globalTournamentScreen && globalTournamentScreen.isVisible)
|
|
{
|
|
globalTournamentScreen.UploadScores();
|
|
}
|
|
}
|
|
|
|
public void OnDownloadScores(LeaderboardSettings lbSettingse)
|
|
{
|
|
if ((bool)globalTournamentScreen && globalTournamentScreen.isVisible)
|
|
{
|
|
globalTournamentScreen.RefreshRanking();
|
|
}
|
|
}
|
|
|
|
public void OnDownloadMyScore(LeaderboardSettings lbSettings)
|
|
{
|
|
}
|
|
|
|
public bool UploadScore(LeaderboardSettings leaderboard)
|
|
{
|
|
if (globalSettings == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (GlobalSettings.Instance.IsMyProfileCracked() ? true : false)
|
|
{
|
|
return false;
|
|
}
|
|
int currentScoreInt = GlobalTournamentManager.Instance.GetCurrentScoreInt();
|
|
leaderboard.UploadScore(currentScoreInt, new int[6]
|
|
{
|
|
globalSettings.playerSettings.playersLevel,
|
|
globalSettings.playerSettings.playersExperience,
|
|
SteamStatsManager.Instance.mySteamUser.tournamentTotalFishCount,
|
|
SteamStatsManager.Instance.mySteamUser.tournamentTotalFishWeight,
|
|
SteamStatsManager.Instance.mySteamUser.tournamentBiggestFishSpecies,
|
|
SteamStatsManager.Instance.mySteamUser.tournamentBiggestFishWeight
|
|
});
|
|
return true;
|
|
}
|
|
|
|
public void OnUploadScore(LeaderboardSettings lbSettings)
|
|
{
|
|
if ((bool)globalTournamentScreen && globalTournamentScreen.isVisible)
|
|
{
|
|
globalTournamentScreen.DownloadScores();
|
|
}
|
|
}
|
|
}
|