void HandleActionRecorderDidChangeAvailability(bool IsRecordingAvaliable)
    {
        ISN_Logger.Log("Is Recording Avaliable: " + IsRecordingAvaliable);

        ISN_ReplayKit.ActionRecordDiscard += HandleActionRecordDiscard;
        ISN_ReplayKit.Instance.DiscardRecording();
    }
Beispiel #2
0
        public void RestorePurchases()
        {
            if (!_IsStoreLoaded)
            {
                SA.Common.Models.Error e = new SA.Common.Models.Error((int)TransactionErrorCode.SKErrorPaymentServiceNotInitialized, "Store Kit Initilizations required");

                RestoreResult r = new RestoreResult(e);
                OnRestoreComplete(r);
                return;
            }

            OnRestoreStarted();

            if (!Application.isEditor)
            {
                BillingNativeBridge.RestorePurchases();
            }
            else
            {
                if (IOSNativeSettings.Instance.InAppsEditorTesting)
                {
                    foreach (Product product in Products)
                    {
                        if (product.Type == ProductType.NonConsumable)
                        {
                            ISN_Logger.Log("Restored: " + product.Id);
                            FireProductBoughtEvent(product.Id, "", "", "", true);
                        }
                    }

                    FireRestoreCompleteEvent();
                }
            }
        }
 void HandleOnStoreDidChangeExternally(System.Collections.Generic.List <iCloudData> changedData)
 {
     foreach (iCloudData data in changedData)
     {
         ISN_Logger.Log("Cloud data with key:  " + data.Key + " was chnaged");
     }
 }
    void OnLeaderboardSetsInfoLoaded(SA.Common.Models.Result res)
    {
        ISN_Logger.Log("OnLeaderboardSetsInfoLoaded");
        GameCenterManager.OnLeaderboardSetsInfoLoaded -= OnLeaderboardSetsInfoLoaded;
        if (res.IsSucceeded)
        {
            foreach (GK_LeaderboardSet s in GameCenterManager.LeaderboardSets)
            {
                ISN_Logger.Log(s.Title);
                ISN_Logger.Log(s.Identifier);
                ISN_Logger.Log(s.GroupIdentifier);
            }
        }


        if (GameCenterManager.LeaderboardSets.Count == 0)
        {
            return;
        }

        GK_LeaderboardSet LeaderboardSet = GameCenterManager.LeaderboardSets[0];

        LeaderboardSet.OnLoaderboardsInfoLoaded += OnLoaderboardsInfoLoaded;
        LeaderboardSet.LoadLeaderBoardsInfo();
    }
    // --------------------------------------
    // TBM
    // --------------------------------------


    private void OnPlayerAcceptedInvitation_TBM(string data)
    {
        ISN_Logger.Log("OnPlayerAcceptedInvitation_TBM");
        GK_Invite invite = new GK_Invite(data);

        ActionPlayerAcceptedInvitation(GK_MatchType.TurnBased, invite);
    }
Beispiel #6
0
        public override void OnLeaderboardReady(ISN_GKLeaderboard leaderboard)
        {
            var leaderboardRequest = new ISN_GKLeaderboard();

            leaderboardRequest.Identifier  = leaderboard.Identifier;
            leaderboardRequest.PlayerScope = ISN_GKLeaderboardPlayerScope.Global;
            leaderboardRequest.TimeScope   = ISN_GKLeaderboardTimeScope.AllTime;
            leaderboardRequest.Range       = new ISN_NSRange(1, 10);


            leaderboardRequest.LoadScores((result) => {
                if (result.IsSucceeded)
                {
                    ISN_Logger.Log("Score Load Success");
                    foreach (var score in result.Scores)
                    {
                        ISN_Logger.Log("score.Value: " + score.Value);
                        ISN_Logger.Log("score.Context: " + score.Context);
                        ISN_Logger.Log("score.Date: " + score.Date);
                        ISN_Logger.Log("score.Rank: " + score.Rank);
                        ISN_Logger.Log("score.Player.PlayerID: " + score.Player.PlayerID);
                        ISN_Logger.Log("score.Player.DisplayName: " + score.Player.DisplayName);
                        ISN_Logger.Log("score.Player.Alias: " + score.Player.Alias);
                    }

                    ISN_Logger.Log("leaderboardRequest.MaxRange: " + leaderboardRequest.MaxRange);
                    ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Value: " + leaderboardRequest.LocalPlayerScore.Value);
                    ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Context: " + leaderboardRequest.LocalPlayerScore.Context);
                    ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Date: " + leaderboardRequest.LocalPlayerScore.Date);
                    ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Rank: " + leaderboardRequest.LocalPlayerScore.Rank);
                }
                SetAPIResult(result);
            });
        }
Beispiel #7
0
    private void HandleActionSavesResolved(GK_SavesResolveResult res)
    {
        ISN_GameSaves.ActionSavesResolved -= HandleActionSavesResolved;

        if (res.IsSucceeded)
        {
            ISN_Logger.Log("The conflict is resolved");

            foreach (GK_SavedGame game in res.SavedGames)
            {
                SavesConflicts.Remove(game.Name);

                if (!GameSaves.ContainsKey(game.Name))
                {
                    GameSaves.Add(game.Name, new List <GK_SavedGame> ());
                    GameSaves [game.Name].Add(game);
                }
            }

            ISN_Logger.Log("------------------------------------------");
            ISN_Logger.Log("Duplicates " + SavesConflicts.Count);
            ISN_Logger.Log("Unique saves " + GameSaves.Count);
            ISN_Logger.Log("------------------------------------------");
            foreach (GK_SavedGame game in res.SavedGames)
            {
                ISN_Logger.Log("The name of the save game " + game.Name);
            }
        }
        else
        {
            ISN_Logger.Log("Failed: " + res.Error.Message);
        }
    }
    private void CheckMatchState(GK_RTM_Match macth)
    {
        IOSNativePopUpManager.dismissCurrentAlert();
        if (macth != null)
        {
            if (macth.ExpectedPlayerCount == 0)
            {
                IOSNativePopUpManager.showMessage("Match Started", "let's play now\n   Macth.ExpectedPlayerCount): " + macth.ExpectedPlayerCount);



                m.enabled = true;
                b.enabled = false;
                d.enabled = true;


                ISN_Logger.Log("Sending HelloPackage ");
                HelloPackage p = new HelloPackage();
                p.send();
            }
            else
            {
                IOSNativePopUpManager.showMessage("Match Created", "Macth.ExpectedPlayerCount): " + macth.ExpectedPlayerCount);
            }
        }
    }
Beispiel #9
0
    public void RestorePurchases()
    {
        if (!_IsStoreLoaded)
        {
            SA.Common.Models.Error e = new SA.Common.Models.Error((int)IOSTransactionErrorCode.SKErrorPaymentServiceNotInitialized, "Store Kit Initilizations required");

            IOSStoreKitRestoreResult r = new IOSStoreKitRestoreResult(e);
            OnRestoreComplete(r);
            return;
        }

        OnRestoreStarted();

                #if !UNITY_EDITOR
        IOSNativeMarketBridge.restorePurchases();
                #else
        if (IOSNativeSettings.Instance.SendFakeEventsInEditor)
        {
            foreach (IOSProductTemplate product in Products)
            {
                if (product.ProductType == ISN_InAppType.NonConsumable)
                {
                    ISN_Logger.Log("Restored: " + product.Id);
                    FireProductBoughtEvent(product.Id, "", "", "", true);
                }
            }

            FireRestoreCompleteEvent();
        }
                #endif
    }
Beispiel #10
0
    private void HandleActionSavesFetched(GK_FetchResult res)
    {
        ISN_GameSaves.ActionSavesFetched -= HandleActionSavesFetched;

        if (res.IsSucceeded)
        {
            ISN_Logger.Log("Received " + res.SavedGames.Count + " game saves");
            foreach (GK_SavedGame game in res.SavedGames)
            {
                ISN_Logger.Log("The name of the save game " + game.Name);
            }
            ISN_Logger.Log("------------------------------------------");

            GameSaves.Clear();
            foreach (GK_SavedGame game in res.SavedGames)
            {
                if (!GameSaves.ContainsKey(game.Name))
                {
                    GameSaves.Add(game.Name, new List <GK_SavedGame> ());
                }
                GameSaves [game.Name].Add(game);
            }

            ISN_Logger.Log("Check the saves on duplicates");
            CheckSavesOnDuplicates();
        }
        else
        {
            ISN_Logger.Log("Failed: " + res.Error.Message + " with code " + res.Error.Code);
        }
    }
Beispiel #11
0
        internal static void PermissionRequestResponse(string permissionData)
        {
            string[] DataArray = permissionData.Split(new string[] { SA.Common.Data.Converter.DATA_SPLITTER2 }, StringSplitOptions.None);

            for (int i = 0; i < DataArray.Length; i++)
            {
                if (DataArray[i] == SA.Common.Data.Converter.DATA_EOF)
                {
                    break;
                }
            }

            if (DataArray.Length > 0)
            {
                string callbackKey = DataArray [0];

                Action <PermissionStatus> callback = OnResponseDictionary [callbackKey];
                if (callback != null)
                {
                    string permissionStatusString = DataArray [1];
                    if (permissionStatusString != null)
                    {
                        try {
                            int permissionStatusCode = Int32.Parse(permissionStatusString);

                            PermissionStatus permissionStatus = (PermissionStatus)permissionStatusCode;
                            callback(permissionStatus);
                        } catch (FormatException e) {
                            ISN_Logger.Log(e.ToString());
                        }
                    }
                }
            }
        }
    // --------------------------------------
    // RTM
    // --------------------------------------

    private void OnPlayerAcceptedInvitation_RTM(string data)
    {
        ISN_Logger.Log("OnPlayerAcceptedInvitation_RTM");
        GK_Invite invite = new GK_Invite(data);

        ActionPlayerAcceptedInvitation(GK_MatchType.RealTime, invite);
    }
    private void OnUserInfoLoadedEvent(string array)
    {
        ISN_Logger.Log("OnUserInfoLoadedEvent");

        string[] data = array.Split(SA.Common.Data.Converter.DATA_SPLITTER);

        string playerId    = data[0];
        string alias       = data[1];
        string displayName = data[2];


        GK_Player p = new GK_Player(playerId, displayName, alias);


        if (_players.ContainsKey(playerId))
        {
            _players[playerId] = p;
        }
        else
        {
            _players.Add(playerId, p);
        }

        if (p.Id == _player.Id)
        {
            _player = p;
        }

        ISN_Logger.Log("Player Info loaded, for player with id: " + p.Id);

        GK_UserInfoLoadResult result = new GK_UserInfoLoadResult(p);

        OnUserInfoLoaded(result);
    }
Beispiel #14
0
    //--------------------------------------
    //  GET/SET
    //--------------------------------------

    //--------------------------------------
    //  PRIVATE METHODS
    //--------------------------------------

    private void Save(string name)
    {
        ISN_Logger.Log("Start to save game!");
        ISN_GameSaves.ActionGameSaved += HandleActionGameSaved;

        byte[] data = System.Text.Encoding.UTF8.GetBytes("Some data");
        ISN_GameSaves.Instance.SaveGame(data, name);
    }
 void HandleOnPlayerPhotoLoaded(GK_UserPhotoLoadResult result)
 {
     if (result.IsSucceeded)
     {
         ISN_Logger.Log(result.Photo);
         ISN_Logger.Log(GameCenterManager.Player.BigPhoto);
     }
 }
Beispiel #16
0
    void HandleOnAchievementsProgress(GK_AchievementProgressResult progress)
    {
        ISN_Logger.Log("OnAchievementProgress");

        GK_AchievementTemplate tpl = progress.Achievement;

        ISN_Logger.Log(tpl.Id + ":  " + tpl.Progress.ToString());
    }
Beispiel #17
0
    public void ReportScoreUpdateFail(string errorData)
    {
        ISN_Logger.Log("ReportScoreUpdateFail");
        _ErrorData = errorData;
        Scores.Add(null);

        DispatchUpdate();
    }
 private void HandleOnAchievementsProgress(GK_AchievementProgressResult result)
 {
     if (result.IsSucceeded)
     {
         GK_AchievementTemplate tpl = result.Achievement;
         ISN_Logger.Log(tpl.Id + ":  " + tpl.Progress.ToString());
     }
 }
Beispiel #19
0
    //--------------------------------------
    //  GET/SET
    //--------------------------------------

    //--------------------------------------
    //  EVENTS
    //--------------------------------------

    void HandleOnAchievementsLoaded(SA.Common.Models.Result res)
    {
        ISN_Logger.Log("Achievements loaded from iOS Game Center");

        foreach (GK_AchievementTemplate tpl in GameCenterManager.Achievements)
        {
            ISN_Logger.Log(tpl.Id + ":  " + tpl.Progress);
        }
    }
Beispiel #20
0
 private void GetLocale(ISN_Locale locale)
 {
     ISN_Logger.Log("GetLocale");
     ISN_Logger.Log(locale.DisplayCountry);
     IOSNativePopUpManager.showMessage("Locale Info:", "Country:" + locale.CountryCode + "/"
                                       + locale.DisplayCountry + "  :   " + "Language:"
                                       + locale.LanguageCode + "/"
                                       + locale.DisplayLanguage);
     IOSNativeUtility.OnLocaleLoaded -= GetLocale;
 }
        public override void Test()
        {
            ISN_NSBuildInfo buildInfo = ISN_NSBundle.BuildInfo;

            ISN_Logger.Log("AppVersion: " + buildInfo.AppVersion);
            ISN_Logger.Log("BuildNumber: " + buildInfo.BuildNumber);


            SetResult(SA_TestResult.OK);
        }
    // --------------------------------------
    // Native Events
    // --------------------------------------

    private void OnInviteeResponse(string data)
    {
        ISN_Logger.Log("OnInviteeResponse");
        string[] DataArray = data.Split(SA.Common.Data.Converter.DATA_SPLITTER);

        GK_Player player = GameCenterManager.GetPlayerById(DataArray[0]);
        GK_InviteRecipientResponse responce = (GK_InviteRecipientResponse)Convert.ToInt32(DataArray[1]);

        ActionInviteeResponse(player, responce);
    }
Beispiel #23
0
 public static void Log(object message)
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         AN_Logger.Log(message);
     }
     else
     {
         ISN_Logger.Log(message);
     }
 }
    void HandleActionPlayerRequestedMatchWithRecipients(GK_MatchType matchType, string[] recepientIds, GK_Player[] recepients)
    {
        ISN_Logger.Log("inictation received");
        if (matchType == GK_MatchType.RealTime)
        {
            //Optionally you can provide and invitation message
            string invitationMessage = "Come play with me, bro.";

            GameCenter_RTM.Instance.FindMatchWithNativeUI(recepientIds.Length, recepientIds.Length, invitationMessage, recepientIds);
        }
    }
    public static void ReportScore(long score, string leaderboardId, long context = 0)
    {
        if (!IOSNativeSettings.Instance.DisablePluginLogs)
        {
            ISN_Logger.Log("unity reportScore: " + leaderboardId);
        }

                #if ((UNITY_IPHONE || UNITY_TVOS) && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE
        _reportScore(score.ToString(), leaderboardId, context.ToString());
                #endif
    }
 public static void ReportScore(double score, string leaderboardId)
 {
     if (!IOSNativeSettings.Instance.DisablePluginLogs)
     {
         ISN_Logger.Log("unity reportScore double: " + leaderboardId);
     }
             #if ((UNITY_IPHONE || UNITY_TVOS) && !UNITY_EDITOR && GAME_CENTER_ENABLED) || SA_DEBUG_MODE
     long s = System.Convert.ToInt64(score * 100);
     _reportScore(s.ToString(), leaderboardId, "0");
             #endif
 }
 void HandleActionMediaPickerResult(MP_MediaPickerResult res)
 {
     if (res.IsSucceeded)
     {
         ISN_Logger.Log("Media piacker Succeeded");
     }
     else
     {
         ISN_Logger.Log("Media piacker failed: " + res.Error.Message);
     }
 }
 void HandleOnAuthFinished(SA.Common.Models.Result result)
 {
     if (result.IsSucceeded)
     {
         ISN_Logger.Log("Player Authed");
     }
     else
     {
         IOSNativePopUpManager.showMessage("Game Center ", "Player authentication failed");
     }
 }
        private void OnContactsRetrieveFailed(string errorData)
        {
            ISN_Logger.Log("[ContactStore] OnContactsRetrieveFailed");

            var error = new SA.Common.Models.Error(errorData);

            ContactsResult result = new ContactsResult(error);

            ContactsLoadResult(result);
            ContactsLoadResult = delegate {};
        }
Beispiel #30
0
 private void HandleActionDataLoaded(GK_SaveDataLoaded res)
 {
     res.SavedGame.ActionDataLoaded -= HandleActionDataLoaded;
     if (res.IsSucceeded)
     {
         ISN_Logger.Log("Data loaded. data Length: " + res.SavedGame.Data.Length);
     }
     else
     {
         ISN_Logger.Log("Failed: " + res.Error.Message);
     }
 }