Beispiel #1
0
 public static void StartGame()
 {
     //DONE
     // Track in TopAnalytics that a game has started
     TopAnalytics.TrackEvent("game_start");
     currentGameIndex++;
 }
Beispiel #2
0
 public static void OnAdShown()
 {
     lastAdShownTime      = Time.unscaledTime;
     lastAdShownGameIndex = currentGameIndex;
     adLoaded             = false;
     TopAnalytics.TrackEvent("ad_shown");
     LoadAd();
 }
Beispiel #3
0
 static public void RevokeConsent()
 {
     TopAds.RevokeConsent();
     TopAnalytics.InitWithConsent(false);
     if (!PlayerPrefs.HasKey("consent") || PlayerPrefs.GetInt("consent") != 0)
     {
         PlayerPrefs.SetInt("consent", 0);
         PlayerPrefs.Save();
     }
 }
Beispiel #4
0
 static public void GrantConsent()
 {
     TopAds.GrantConsent();
     TopAnalytics.InitWithConsent(true);
     if (!PlayerPrefs.HasKey("consent") || PlayerPrefs.GetInt("consent") == 0)
     {
         PlayerPrefs.SetInt("consent", 1);
         PlayerPrefs.Save();
     }
 }
Beispiel #5
0
    public static void SetGDPRConsent(bool gdprConsent)
    {
        TopAnalytics.InitWithConsent(gdprConsent);

        TopAds.InitializeSDK();
        if (gdprConsent)
        {
            TopAds.GrantConsent();
        }
        else
        {
            TopAds.RevokeConsent();
        }
    }
Beispiel #6
0
 // Before calling methods in TopAds and TopAnalytics you must call their init methods
 // TopAds requires the TopAds prefab to be created in the scene
 // You also need to collect user GDPR consent and pass that boolean value to TopAds and TopAnalytics
 // You can collect this consent by displaying a popup to the user at the start of the game and then storing that value for future use
 public static void StartGame()
 {
     UnityEngine.Assertions.Assert.IsTrue(RGPDManager.RgpdConsentalue.HasValue);
     TopAds.InitializeSDK();
     TopAnalytics.InitWithConsent(RGPDManager.RgpdConsentalue.Value);
     if (RGPDManager.RgpdConsentalue.Value)
     {
         TopAds.GrantConsent();
     }
     else
     {
         TopAds.RevokeConsent();
     }
     // Track in TopAnalytics that a game has started
     TopAnalytics.TrackEvent(GAME_STARTED_EVENT);
     TopAds.OnAdShownEvent += TopAds_OnAdShownEvent;
 }
Beispiel #7
0
    // TODO Before calling methods in TopAds and TopAnalytics you must call their init methods
    // TopAds requires the TopAds prefab to be created in the scene
    // TODO You also need to collect user GDPR consent and pass that boolean value to TopAds and TopAnalytics
    // You can collect this consent by displaying a popup to the user at the start of the game and then storing that value for future use


    /**
     * @requires calling the Initialize method first
     */
    public static void StartGame()
    {
        /**
         * GDPR CONSENT
         * We Asynchronously Collect this consent by displaying a popup to the user
         * we pass the consent to the SDK in the initialization Method alongslide the app ID
         * @see An example at [MainCanvasScript.cs]
         */

        // use the ConsentGiven to init TopAnalytics
        TopAnalytics.InitWithConsent(ConsentGiven);

        // init TopAds
        TopAds.InitializeSDK();


        // Grant/Revoke TopAds based on consentGiven value
        if (ConsentGiven)
        {
            TopAds.GrantConsent();
        }
        else
        {
            TopAds.RevokeConsent();
        }

        // Track in TopAnalytics that a game has started
        TopAnalytics.TrackEvent("Game_started");


        // Delegate TopAds events to listeners to ensure that we always have an ad ready :)
        TopAds.OnAdLoadedEvent += OnAdLoadedEvent;
        TopAds.OnAdFailedEvent += OnAdFailedEvent;
        TopAds.OnAdShownEvent  += OnAdShownEvent;


        // we request an ad to prepare for the ShowAd Event :)
        TopAds.RequestAd(appAdUnitID);


        gamesSinceLastAd++;
    }
Beispiel #8
0
    /*
     * ************************************************
     *
     * TopAds Action events
     * Ad readiness/display events
     *
     * An autorequest system that ensures an ad is always ready to be displayed
     *
     * ************************************************
     */

    /**
     * this is a delegate of TopAds.OnAdShownEvent
     * Track in TopAnalytics when an ad is displayed.
     */
    private static void OnAdShownEvent()
    {
        // Track in TopAnalytics when an ad is displayed.
        TopAnalytics.TrackEvent("ad_displayed");

        // since ad is displayed, we turn this to false and to allow requesting a new one
        adLoaded = false;

        // Prepare for the next ad
        TopAds.RequestAd(appAdUnitID);


        Debug.Log("Ad shown, requesting for next time");


        gamesSinceLastAd = 0;
        // The number of seconds that have elapsed since 1970-01-01T00:00:00Z.
        // needed to compare later
        secondsSinceLastAd = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
    }
Beispiel #9
0
 public static void EndGame()
 {
     // Track in TopAnalytics that a game has ended
     TopAnalytics.TrackEvent(GAME_ENDED_EVENT);
     GamesPlayedSinceLastAd++;
 }
Beispiel #10
0
 private static void TopAds_OnAdShownEvent()
 {
     TopAnalytics.TrackEvent(AD_DISPLAYED_EVENT);
     TimeLastAdShown        = Time.time;
     GamesPlayedSinceLastAd = 0;
 }
Beispiel #11
0
 public static void EndGame()
 {
     //DONE
     // Track in TopAnalytics that a game has ended
     TopAnalytics.TrackEvent("game_end");
 }
Beispiel #12
0
 public static void EndGame()
 {
     TopAnalytics.TrackEvent("gameEnded");
     // Track in TopAnalytics that a game has ended
 }
Beispiel #13
0
 public static void StartGame()
 {
     gamesShown++;
     TopAnalytics.TrackEvent("gameStarted");
     // Track in TopAnalytics that a game has started
 }