57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class HighscoreModeManager : MonoBehaviour
|
|
{
|
|
public static bool isPraticeMode= true;
|
|
public static string playerKey = "";
|
|
public static int leaderboarId = 0;
|
|
public static int highscore = 0;
|
|
void Awake()
|
|
{
|
|
#if UNITY_SERVER && !UNITY_EDITOR
|
|
return;
|
|
#endif
|
|
|
|
string url = Application.absoluteURL;
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
// Extract query parameters
|
|
string isPractice = GetQueryParam(url, "isPractice") ?? "0";
|
|
string isDev = GetQueryParam(url, "isDev") ?? "0";
|
|
if(isDev == "1"){
|
|
DuelFi.VALIDATOR_URL = DuelFi.VALIDATOR_DEV_URL;
|
|
}else{
|
|
DuelFi.VALIDATOR_URL = DuelFi.VALIDATOR_PROD_URL;
|
|
}
|
|
if(isPractice == "1"){
|
|
isPraticeMode = true;
|
|
}else{
|
|
isPraticeMode = false;
|
|
playerKey = GetQueryParam(url, "playerKey");
|
|
leaderboarId = int.Parse(GetQueryParam(url, "leaderboardId"));
|
|
highscore = int.Parse(GetQueryParam(url, "highscore"));
|
|
Debug.Log("Dump parameters");
|
|
Debug.Log("highscore: " + highscore);
|
|
Debug.Log("playerKey: " + playerKey);
|
|
Debug.Log("leaderboarId: " + leaderboarId);
|
|
|
|
GameManager.Instance.SetHighscore(highscore);
|
|
}
|
|
}
|
|
}
|
|
|
|
string GetQueryParam(string url, string key)
|
|
{
|
|
if (!url.Contains("?")) return null;
|
|
string[] queries = url.Split('?')[1].Split('&');
|
|
foreach (string query in queries)
|
|
{
|
|
string[] pair = query.Split('=');
|
|
if (pair.Length == 2 && pair[0] == key) return pair[1];
|
|
}
|
|
return null;
|
|
}
|
|
}
|