void Awake()
    {
        if (instance == null)
        {
            instance = this;

            DontDestroyOnLoad(gameObject);

            Skillz.Init(Application.unityVersion);

            if (enableGCM)
            {
                if (!Skillz.IsGCMRegistered())
                {
                    Skillz.RegisterGCM();
                }
            }

            if (enableLocalytics)
            {
                SkillzLocalytics.Instance.Open();
                SkillzLocalytics.Instance.Upload();
            }
        }
        else if (instance != this)
        {
            DestroyObject(gameObject);
        }
    }
 /// <summary>
 /// Starts up the Skillz UI. Should be used as soon as the player clicks your game's "Multiplayer" button.
 /// </summary>
 public static void LaunchSkillz()
 {
             #if UNITY_ANDROID
     Skillz.Launch();
             #elif UNITY_IOS
     SkillzSDK.Api.LaunchSkillz();
             #endif
 }
Beispiel #3
0
 public static void SendData(byte[] data)
 {
             #if UNITY_ANDROID
     Skillz.SendData(data);
             #elif UNITY_IOS
     SkillzSDK.Api.SendData(data);
             #endif
 }
 /// <summary>
 /// Call this method to make the player forfeit the game, returning him to the Skillz portal.
 /// </summary>
 public static void AbortMatch()
 {
             #if UNITY_ANDROID
     Skillz.AbortMatch();
             #elif UNITY_IOS
     SkillzSDK.Api.AbortGame();
             #endif
 }
 /// <summary>
 /// Call this method every time the player's score changes during a Skillz match.
 /// This adds important anti-cheating functionality to your game.
 /// This can accept a string, a float, or an int.
 /// </summary>
 ///
 /// <param name="score">The player's current score as a string.</param>
 public static void UpdatePlayersCurrentScore(String score)
 {
             #if UNITY_ANDROID
     Skillz.UpdatePlayersCurrentScore(score);
             #elif UNITY_IOS
     SkillzSDK.Api.UpdatePlayerScore(float.Parse(score));
             #endif
 }
 /// <summary>
 /// Call this method every time the player's score changes during a Skillz match.
 /// This adds important anti-cheating functionality to your game.
 /// This can accept a string, a float, or an int.
 /// </summary>
 ///
 /// <param name="score">The player's current score as an int.</param>
 public static void UpdatePlayersCurrentScore(int score)
 {
             #if UNITY_ANDROID
     Skillz.UpdatePlayersCurrentScore(score);
             #elif UNITY_IOS
     SkillzSDK.Api.UpdatePlayerScore(score);
             #endif
 }
 /// <summary>
 /// Call this method if you want to add meta data for the match.
 /// </summary>
 /// <param name="metadataJson">A string representing the meta data in a json string.</param>
 /// <param name="forMatchInProgress">A boolean to check whether the user is in a Skillz game.</param>
 public static void AddMetadataForMatchInProgress(string metadataJson, bool forMatchInProgress)
 {
             #if UNITY_ANDROID
     Skillz.AddMetadataForMatchInProgress(metadataJson, forMatchInProgress);
             #elif UNITY_IOS
     SkillzSDK.Api.AddMetadataForMatchInProgress(metadataJson, forMatchInProgress);
             #endif
 }
 /// <summary>
 /// Call this method when a player finishes a multiplayer game. This will report the result of the game
 /// to the Skillz server, and return the player to the Skillz portal.
 /// This can accept a string, a float, or an int.
 /// </summary>
 ///
 /// <param name="score">A float representing the score a player achieved in the game.</param>
 public static void ReportFinalScore(float score)
 {
             #if UNITY_ANDROID
     Skillz.ReportScore(score);
             #elif UNITY_IOS
     SkillzSDK.Api.FinishTournament(score);
             #endif
 }
 /// <summary>
 /// Gets whether we are currently in a Skillz tournament.
 /// Use this method to have different logic in single player than in multiplayer(Skillz game).
 /// </summary>
 public static bool IsMatchInProgress()
 {
             #if UNITY_ANDROID
     return(Skillz.IsMatchInProgress());
             #elif UNITY_IOS
     return(SkillzSDK.Api.IsTournamentInProgress);
             #endif
     return(false);
 }
Beispiel #10
0
 /// <summary>
 /// Returns a Match object that has details regarding the specific match the user is in
 /// </summary>
 public static SkillzSDK.Match GetMatchInfo()
 {
             #if UNITY_ANDROID
     return(Skillz.GetMatchInfo());
             #elif UNITY_IOS
     return(SkillzSDK.Api.GetMatchInfo());
             #endif
     return(null);
 }
Beispiel #11
0
 public static long GetTimeLeftForReconnection(UInt64 playerId)
 {
             #if UNITY_ANDROID
     return(Skillz.GetTimeLeftForReconnection(playerId));
             #elif UNITY_IOS
     return(SkillzSDK.Api.ReconnectTimeLeftForPlayer(playerId));
             #endif
     return(0);
 }
Beispiel #12
0
 public static double GetServerTime()
 {
             #if UNITY_ANDROID
     return(Skillz.GetServerTime());
             #elif UNITY_IOS
     return(SkillzSDK.Api.GetServerTime());
             #endif
     return(0);
 }
Beispiel #13
0
 public static UInt64 GetCurrentOpponentPlayerId()
 {
             #if UNITY_ANDROID
     return(Skillz.GetCurrentOpponentPlayerId());
             #elif UNITY_IOS
     return(SkillzSDK.Api.CurrentOpponentPlayerId());
             #endif
     return(0);
 }
 /// <summary>
 /// This method returns what SDK version your user is on.
 /// </summary>
 public static string SDKVersionShort()
 {
             #if UNITY_ANDROID
     return(Skillz.SDKVersionShort());
             #elif UNITY_IOS
     return(SkillzSDK.Api.SDKVersionShort);
             #endif
     return(null);
 }
 /// <summary>
 /// Returns a Hashtable of the Match Rules that you set in Developer Portal
 /// You can set these rules in https://developers.skillz.com/dashboard and clicking on your game.
 /// </summary>
 public static Hashtable GetMatchRules()
 {
             #if UNITY_ANDROID
     return(Skillz.GetMatchRules());
             #elif UNITY_IOS
     return(SkillzSDK.Api.GetMatchRules());
             #endif
     return(null);
 }
 /// <summary>
 /// This returns the current user's display name in case you want to use it in the game
 /// </summary>
 public static string CurrentUserDisplayName()
 {
             #if UNITY_ANDROID
     return(Skillz.CurrentUserDisplayName());
             #elif UNITY_IOS
     return(SkillzSDK.Api.Player.DisplayName);
             #endif
     return(null);
 }
Beispiel #17
0
 public static bool IsMatchCompleted()
 {
             #if UNITY_ANDROID
     return(Skillz.IsMatchCompleted());
             #elif UNITY_IOS
     return(SkillzSDK.Api.IsMatchCompleted());
             #endif
     return(false);
 }
Beispiel #18
0
 public static int GetConnectedPlayerCount()
 {
             #if UNITY_ANDROID
     return(Skillz.GetConnectedPlayerCount());
             #elif UNITY_IOS
     return(SkillzSDK.Api.ConnectedPlayerCount());
             #endif
     return(0);
 }
Beispiel #19
0
 /// <summary>
 /// Use this Player class to grab information about your current user.
 /// </summary>
 public static SkillzSDK.Player GetPlayer()
 {
     #if UNITY_ANDROID
     return(Skillz.GetPlayer());
     #elif UNITY_IOS
     return(SkillzSDK.Api.GetPlayer());
     #endif
     return(null);
 }
        public Match(JSONDict jsonData)
        {
            Description   = jsonData.SafeGetStringValue("matchDescription");
            EntryCash     = (float)jsonData.SafeGetDoubleValue("entryCash");
            EntryPoints   = jsonData.SafeGetIntValue("entryPoints");
            ID            = jsonData.SafeGetIntValue("id");
            TemplateID    = jsonData.SafeGetIntValue("templateId");
            Name          = jsonData.SafeGetStringValue("name");
            IsCash        = jsonData.SafeGetBoolValue("isCash");
            IsSynchronous = (bool)jsonData.SafeGetBoolValue("isSynchronous");

            object players = jsonData.SafeGetValue("players");

            Players = new List <Player>();

            List <object> playerArray = (List <object>)players;

            foreach (object player in playerArray)
            {
                Players.Add(new Player((Dictionary <string, object>)player));
            }

            var connectionInfoJson = jsonData.SafeGetValue("connectionInfo") as JSONDict;

            CustomServerConnectionInfo = connectionInfoJson != null
                ? new CustomServerConnectionInfo(connectionInfoJson)
                : null;

#if UNITY_IOS
            GameParams = new Dictionary <string, string>();
            object parameters = jsonData.SafeGetValue("gameParameters");
            if (parameters != null && parameters.GetType() == typeof(JSONDict))
            {
                foreach (KeyValuePair <string, object> kvp in (JSONDict)parameters)
                {
                    if (kvp.Value == null)
                    {
                        continue;
                    }

                    string val = kvp.Value.ToString();
                    if (kvp.Key == "skillz_difficulty")
                    {
                        SkillzDifficulty = Helpers.SafeUintParse(val);
                    }
                    else
                    {
                        GameParams.Add(kvp.Key, val);
                    }
                }
            }
#elif UNITY_ANDROID
            GameParams       = HashtableToDictionary(Skillz.GetMatchRules());
            SkillzDifficulty = jsonData.SafeGetUintValue("skillzDifficulty");
#endif
        }
Beispiel #21
0
    public static void LaunchSkillz(SkillzSyncDelegate _syncMatchDelegate)
    {
        SkillzDelegate.AssignSkillzDelegate(_syncMatchDelegate);

                #if UNITY_ANDROID
        Skillz.Launch();
                #elif UNITY_IOS
        SkillzSDK.Api.LaunchSkillz();
                #endif
    }
Beispiel #22
0
    /// <summary>
    /// Call this method to set background music to be played inside our Skillz Lobby.
    /// This will be continuously playing throughout a user's time in our SDK.
    /// </summary>
    ///
    /// <param name="fileName">The name of the music file inside of the StreamingAssets folder, e.g. "game_music.mp3" .</param>
    public static void setSkillzBackgroundMusic(string fileName)
    {
        Debug.Log("SkillzAudio SkillzCrossPlatform.cs setSkillzBackgroundMusic with file name: " + fileName);

                #if UNITY_ANDROID
        Skillz.setSkillzBackgroundMusic(fileName);
                #elif UNITY_IOS
        SkillzSDK.Api.setSkillzBackgroundMusic(fileName);
                #endif
    }
Beispiel #23
0
    /// <summary>
    /// Call this method to set the SFX volume the user sets on
    /// your volume control. This value will be saved to be used as the volume
    /// inside the Skillz framework for our volume sliders as well.
    /// </summary>
    ///
    /// <param name="volume">The volume of the SFX sound.</param>
    public static void setSFXVolume(float volume)
    {
        Debug.Log("SkillzAudio SkillzCrossPlatform.cs setSFXVolume with volume " + volume);

                #if UNITY_ANDROID
        Skillz.setSFXVolume(volume);
                #elif UNITY_IOS
        SkillzSDK.Api.setSFXVolume(volume);
                #endif
    }
    public static void AssignSkillzDelegate(SkillzSyncDelegate skillzSyncDelegate)
    {
        _syncDelegate = skillzSyncDelegate;

        #if UNITY_ANDROID
        Skillz.InitializeSyncDelegate(skillzSyncDelegate);
        #elif UNITY_IOS
        SkillzSDK.Api.InitializeSyncDelegate(skillzSyncDelegate);
        #endif
    }
Beispiel #25
0
        public void Post([FromBody] SkillzModel value)
        {
            if (value != null)
            {
                var skillzEntity = new Skillz();
                skillzEntity.Description = value.Description;
                skillzEntity.Name        = value.Name;

                _ISkillzRepository.Add(skillzEntity);
            }
        }
Beispiel #26
0
    /// <summary>
    /// Call this method to get the SFX volume the user set or the default one
    /// to calibrate on your preferred volume sliders.
    /// </summary>
    public static float getSFXVolume()
    {
        float sfxVolume = 0.0f;

                #if UNITY_ANDROID
        sfxVolume = Skillz.getSFXVolume();
                #elif UNITY_IOS
        sfxVolume = SkillzSDK.Api.getSFXVolume();
                #endif

        Debug.Log("SkillzAudio SkillzCrossPlatform.cs getSFXVolume with volume " + sfxVolume);
        return(sfxVolume);
    }
    /// <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);
        }
    }
Beispiel #28
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);
 }
Beispiel #29
0
 /// <summary>
 /// Receives the message from AndroidSDK.
 /// </summary>
 /// <param name='message'>
 /// Message.
 /// </param>
 public void receiveSkillzMessage(string message)
 {
     startGame(Skillz.stringToDictionary(message));
 }
Beispiel #30
0
    public static void ReportPublisherDefinedValues(Dictionary <string, string> pars)
    {
        AndroidJavaObject hashmap = Skillz.dictionaryToHashmap(pars);

        GetSkillz().CallStatic("reportPublisherDefinedValues", GetContext(), hashmap);
    }