示例#1
0
    public static void ReportScore(float score)
    {
        AndroidJavaObject bigDecScore = new AndroidJavaObject("java.math.BigDecimal", score.ToString());

        GetSkillz().CallStatic("reportScore", GetCurrentActivity(), bigDecScore);
        _matchInfo = null;
    }
示例#2
0
    public static SkillzSDK.Match GetMatchInfo()
    {
        if (_matchInfo == null)
        {
            string matchInfoJsonString = GetSkillz().CallStatic <string>("getMatchInfoJsonString", GetCurrentActivity());
            Dictionary <string, object> matchInfoDict = DeserializeJSONToDictionary(matchInfoJsonString);
            _matchInfo = new SkillzSDK.Match(matchInfoDict);
        }

        return(_matchInfo);
    }
示例#3
0
//	/// <summary>
//	/// This returns the current user's display name in case you want to use it in the game
//	/// </summary>
//	[Obsolete("This method will be removed in a future release, instead use the get Player function, which will return an instance of Player for the current user")]
//	public static string CurrentUserDisplayName()
//	{
//#if UNITY_ANDROID
//			return Skillz.CurrentUserDisplayName();
//#elif UNITY_IOS
//			return SkillzSDK.Api.GetPlayer().DisplayName;
//#endif
//		return null;
//	}

    /// <summary>
    /// Use this Player class to grab information about your current user.
    /// </summary>
    public static SkillzSDK.Player GetPlayer()
    {
        SkillzSDK.Match match = GetMatchInfo();
        if (match != null)
        {
            foreach (SkillzSDK.Player player in match.Players)
            {
                if (player.IsCurrentPlayer)
                {
                    return(player);
                }
            }
        }

        return(BridgedAPI.GetPlayer());
    }
示例#4
0
    public override void OnTournamentWillBegin(SkillzSDK.Match matchInfo)
    {
        Debug.Log(matchInfo);

        //Parse the Skillz difficulty and go to the timed match scene.
        Application.LoadLevel("TimedGameScene");

        Dictionary <string, string> gameRules = matchInfo.GameParams;

        if (gameRules.ContainsKey("skillz_difficulty"))
        {
            MySkillzDelegate.SkillzDifficulty = System.Int32.Parse(gameRules["skillz_difficulty"]);
        }
        else
        {
            MySkillzDelegate.SkillzDifficulty = 5;
        }
    }
    /// <summary>
    /// This method is called when a user starts a match from Skillz
    /// This method is required to impelement.
    /// </summary>
    private void OnMatchWillBegin(String matchInfoJsonString)
    {
        Dictionary <string, object> matchInfoDict = DeserializeJSONToDictionary(matchInfoJsonString);

        SkillzSDK.Match matchInfo = new SkillzSDK.Match(matchInfoDict);

        if (_delegate != null)
        {
            _delegate.OnMatchWillBegin(matchInfo);
        }
        else
        {
            // We must re-initialize the sync delegate on Android for each match.
            #if UNITY_ANDROID
            Skillz.InitializeSyncDelegate(_syncDelegate);
            #endif
            _syncDelegate.OnMatchWillBegin(matchInfo);
        }
    }
 public void OnMatchWillBegin(SkillzSDK.Match matchInfo)
 {
     if (matchInfo.IsCustomSynchronousMatch)
     {
         Debug.Log("Sync Game Mode Starting...");
         SetSyncMatchSettings(matchInfo);
         Debug.Log("SetSyncMatchSettings complete...");
         if (UserData.Instance != null)
         {
             Debug.Log("IsGameOver = false complete...");
             UserData.Instance.IsGameOver = false;
         }
         Debug.Log("Loading SyncScene synchronously...");
         SceneManager.LoadScene("SyncScene", LoadSceneMode.Single);
     }
     else
     {
         ClearSyncSettings(); // Clear any settings from a previous match for good measure
         SceneManager.LoadScene("MainScene", LoadSceneMode.Single);
     }
 }
 private void SetSyncMatchSettings(SkillzSDK.Match matchInfo)
 {
     SkillzSDK.CustomServerConnectionInfo info = matchInfo.CustomServerConnectionInfo;
     UserData.Instance.SyncUrl        = info.ServerIp;
     UserData.Instance.SyncPort       = (uint)int.Parse(info.ServerPort);
     UserData.Instance.SyncMatchToken = info.MatchToken;
     UserData.Instance.SyncMatchId    = info.MatchId;
     UserData.Instance.IsGameOver     = false;
     foreach (SkillzSDK.Player player in matchInfo.Players)
     {
         if (player.IsCurrentPlayer)
         {
             UserData.Instance.CurrentPlayerId        = (long)player.ID;
             UserData.Instance.CurrentPlayerAvatarUrl = player.AvatarURL;
             UserData.Instance.CurrentPlayerName      = player.DisplayName;
         }
         else
         {
             UserData.Instance.OpponentAvatarUrl = player.AvatarURL;
             UserData.Instance.OpponentName      = player.DisplayName;
         }
     }
 }
示例#8
0
 /// <summary>
 /// Use this Player class to grab information about your current user.
 /// </summary>
 public static SkillzSDK.Player GetPlayer()
 {
     SkillzSDK.Match match = GetMatchInfo();
     if (match != null)
     {
         foreach (SkillzSDK.Player player in match.Players)
         {
             if (player.IsCurrentPlayer)
             {
                 return(player);
             }
         }
     }
     else
     {
                     #if UNITY_ANDROID
         return(Skillz.GetPlayer());
                     #elif UNITY_IOS
         return(SkillzSDK.Api.GetPlayer());
                     #endif
     }
     return(null);
 }
示例#9
0
 public static void AbortMatch()
 {
     GetSkillz().CallStatic("abortMatch", GetCurrentActivity());
     _matchInfo = null;
 }
 public override void OnTournamentWillBegin(SkillzSDK.Match matchInfo)
 {
     Debug.Log(matchInfo);
     Application.LoadLevel("NormalMatch");
 }
 /// <summary>
 /// Called when a match is about to start from the Skillz UI. You should load the level
 ///  and take any other necessary initialization actions in order to start the game.
 /// </summary>
 ///
 /// <param name="matchInfo">
 /// The custom tournament parameters you set up on the developer's portal (https://developers.skillz.com/developer)
 ///  for the type of tournament that is about to begin.
 /// </param>
 /// <remarks>
 /// Replaces the previous `OnTournamentWillBegin(Dictionary<string, string> tournamentRules)` method.
 /// `tournamentRules` (aka Game Parameters) are avaiable by using `matchInfo.GameParams`.
 /// </remarks>
 public abstract void OnTournamentWillBegin(Match matchInfo);
 //Standard messages:
 private void skillzTournamentWillBegin(string matchInfoJson)
 {
     Dictionary<string, object> matchInfoDict = DeserializeJSONToDictionary(matchInfoJson);
     Match match = new Match(matchInfoDict);
     DelStandard.OnTournamentWillBegin(match);
 }