Beispiel #1
0
        IEnumerator ShowVideoRewardedCoroutine(Action success, Action failed)
        {
            if (statusVideoRewarded != StatusVideoRewarded.Loaded)
            {
                failed?.Invoke();
                yield break;
            }

            ui.Block();
            music.SetVolume(0f);

            Log("Ads - Appodeal - Predicted eCPM for Rewarded Video: " + Appodeal.getPredictedEcpm(Appodeal.REWARDED_VIDEO));
            Log($"Ads - Appodeal - Reward currency: {Appodeal.getRewardParameters().Key}, amount: {Appodeal.getRewardParameters().Value}");

            Appodeal.show(Appodeal.REWARDED_VIDEO);

            while (statusVideoRewarded != StatusVideoRewarded.Closed)
            {
                yield return(null);
            }

            Log("Ads - Appodeal Result Finished");

            Analytic.EventPropertiesImportant("Ads", "Appodeal VideoRewarded Result", "Finished");

            ui.Unblock();
            music.SetVolume(music.volumeNormal);

            success?.Invoke();
        }
Beispiel #2
0
        public virtual void Activate()
        {
            ObscuredPrefs.SetString(id.ToString(), "activated");

            Analytic.EventPropertiesImportant("Promocode",
                                              new Dictionary <string, object>()
            {
                { "code", code }, { "action", Json.Serialize(action) }
            });
        }
Beispiel #3
0
        IEnumerator ShowInterstitialCoroutine(Action success, Action failed)
        {
            if (statusInterstitial != StatusInterstitial.Loaded)
            {
                failed?.Invoke();
                yield break;
            }

            Appodeal.show(Appodeal.INTERSTITIAL);

            float startTime = Time.time;

            while (statusInterstitial != StatusInterstitial.Shown || Time.time - startTime < 5f)
            {
                yield return(null);
            }

            if (statusInterstitial != StatusInterstitial.Shown)
            {
                failed?.Invoke();
                yield break;
            }

            ui.Block();

            while (statusInterstitial != StatusInterstitial.ClosedAfterClicked && statusInterstitial != StatusInterstitial.Closed)
            {
                yield return(null);
            }

            ui.Unblock();

            if (statusInterstitial == StatusInterstitial.ClosedAfterClicked)
            {
                Log("Ads - Appodeal - Interstitial Result - Click");

                Analytic.EventProperties("Ads", "Appodeal Interstitial Result", "Click");

                success?.Invoke();
            }
            else
            {
                Log("Ads - Appodeal - Interstitial Result - Dismiss");

                Analytic.EventProperties("Ads", "Appodeal Interstitial Result", "Dismiss");

                failed?.Invoke();
            }
        }
Beispiel #4
0
        public override bool isReadyVideoRewarded()
        {
            statusVideoRewarded = Appodeal.isLoaded(Appodeal.REWARDED_VIDEO) ? StatusVideoRewarded.Loaded : StatusVideoRewarded.FailedToLoad;

            if (statusVideoRewarded != StatusVideoRewarded.Loaded)
            {
                Appodeal.cache(Appodeal.REWARDED_VIDEO);
            }

            LogDebug("Ads - Appodeal - VideoRewarded Request - " + (statusVideoRewarded == StatusVideoRewarded.Loaded ? "YES" : "NO"));

            Analytic.EventProperties("Ads", "Appodeal VideoRewarded Request", statusVideoRewarded == StatusVideoRewarded.Loaded ? "YES" : "NO");

            return(statusVideoRewarded == StatusVideoRewarded.Loaded);
        }
Beispiel #5
0
        public override bool isReadyInterstitial()
        {
            bool isReady = Chartboost.hasInterstitial(CBLocation.Default);

            Debug.Log("Ads - Chartboost - Interstitial isReady - " + (isReady ? "YES" : "NO"));

            Analytic.Event("Ads", "Chartboost Interstitial", isReady ? "YES" : "NO");

            if (!isReady)
            {
                Chartboost.cacheInterstitial(CBLocation.Default);
            }

            return(isReady);
        }
Beispiel #6
0
        public override bool isReadyInterstitial()
        {
            statusInterstitial = Appodeal.isLoaded(Appodeal.INTERSTITIAL) ? StatusInterstitial.Loaded : StatusInterstitial.FailedToLoad;

            if (statusInterstitial != StatusInterstitial.Loaded)
            {
                Appodeal.cache(Appodeal.INTERSTITIAL);
            }

            LogDebug("Ads - Appodeal - Interstitial isReady - " + (statusInterstitial == StatusInterstitial.Loaded ? "YES" : "NO"));

            Analytic.EventProperties("Ads", "Appodeal Interstitial", statusInterstitial == StatusInterstitial.Loaded ? "YES" : "NO");

            return(statusInterstitial == StatusInterstitial.Loaded);
        }
Beispiel #7
0
        public void PurchaseSucceed(PurchaseData data)
        {
            if (data.iap != null)
            {
                user.Buy(data.iap);

                Analytic.EventRevenue(data);
            }

            if (purchaseCallback != null)
            {
                ui.LoadingHide();
                purchaseCallback(true);
                purchaseCallback = null;
            }
        }
Beispiel #8
0
        void didDismissInterstitial(CBLocation location)
        {
            Debug.Log("Ads - Chartboost Interstitial - Dismissing... (" + location + ")");

            ui.Unblock();

            if (isInterstitialClick)
            {
                Analytic.Event("Ads", "Chartboost Interstitial Result", "Click");
                if (interstitialSuccess != null)
                {
                    interstitialSuccess();
                }
            }
            else
            {
                Analytic.Event("Ads", "Chartboost Interstitial Result", "Dismiss");
                if (interstitialFailed != null)
                {
                    interstitialFailed();
                }
            }
        }
Beispiel #9
0
        IEnumerator ShowCoroutine(string id, Action success, Action failed)
        {
            if (!Advertisement.isInitialized || status == Status.Shown || !isReady(id))
            {
                failed?.Invoke();
                yield break;
            }

            ui.Block();
            music.SetVolume(0f);

            Advertisement.Show(id);

            //float startTime = Time.time;
            //while (statusInterstitial != StatusInterstitial.Shown || Time.time - startTime < 5f) yield return null;

            status = Status.Shown;
            while (status == Status.Shown)
            {
                yield return(null);
            }

            Analytic.EventPropertiesImportant("Ads", $"Unity {id} Result", status);

            music.SetVolume(music.volumeNormal);
            ui.Unblock();

            if (status == Status.Finished)
            {
                success?.Invoke();
            }
            else
            {
                failed?.Invoke();
            }
        }
Beispiel #10
0
        public override void Init()
        {
            base.Init();

            if (!data.ContainsKey("id"))
            {
                data.Add("id", null);
            }

#if PREVENT_READ_PHONE_STATE
            if (!data.ContainsKey("deviceId"))
            {
                data.Add("deviceId", UnityEngine.Random.Range(100000000, 999999999).ToString());
            }
#else
            if (!data.ContainsKey("deviceId"))
            {
                data.Add("deviceId", SystemInfo.deviceUniqueIdentifier);
            }
#endif

            if (!data.ContainsKey("facebookId"))
            {
                data.Add("facebookId", null);
            }
            if (!data.ContainsKey("email"))
            {
                data.Add("email", null);
            }
            if (!data.ContainsKey("name"))
            {
                data.Add("name", null);
            }
            if (!data.ContainsKey("firstName"))
            {
                data.Add("firstName", null);
            }
            if (!data.ContainsKey("lastName"))
            {
                data.Add("lastName", null);
            }
            if (!data.ContainsKey("gender"))
            {
                data.Add("gender", 0);
            }

            if (!data.ContainsKey("socialName"))
            {
                data.Add("socialName", null);
            }
            if (!data.ContainsKey("gameCenterId"))
            {
                data.Add("gameCenterId", null);
            }
            if (!data.ContainsKey("googleGamesId"))
            {
                data.Add("googleGamesId", null);
            }

            if (!data.ContainsKey("status"))
            {
                data.Add("status", 0);
            }

            if (!data.ContainsKey("revenue"))
            {
                data.Add("revenue", 0.0f);
            }

            if (!data.ContainsKey("version"))
            {
                data.Add("version", build.version);
            }
            if (version != build.version)
            {
                data["version"] = build.version;
            }

            if (!data.ContainsKey("deviceInfo"))
            {
                data.Add("deviceInfo", Json.Serialize(SG_Utils.deviceInfo));
            }

            if (!data.ContainsKey("firstDate"))
            {
                data.Add("firstDate", SG_Utils.dateNowFormated);
            }

            if (!data.ContainsKey("firstVersion"))
            {
                data.Add("firstVersion", build.version);
            }

            TutorialLoad();

            //if (!data.ContainsKey("invitedBy")) data.Add("invitedBy", null);

            Analytic.SetUserProperties(new Dictionary <string, object>()
            {
                { "firstDate", firstDate },
                { "firstVersion", firstVersion },
                { "version", version },
            });

            StartCoroutine(SyncCoroutine());
        }
Beispiel #11
0
        public virtual void SetFacebookData(IDictionary <string, object> facebookData)
        {
            if (facebookData == null)
            {
                return;
            }

            object temp;

            bool isFirstTimeFacebookLogin = string.IsNullOrEmpty(facebookId);

            if (facebookData.TryGetValue("id", out temp))
            {
                facebookId = (string)temp;
            }
            if (facebookData.TryGetValue("name", out temp))
            {
                fullName = (string)temp;
            }
            if (facebookData.TryGetValue("first_name", out temp))
            {
                firstName = (string)temp;
            }
            if (facebookData.TryGetValue("last_name", out temp))
            {
                lastName = (string)temp;
            }
            if (facebookData.TryGetValue("email", out temp))
            {
                email = (string)temp;
            }
            if (facebookData.TryGetValue("gender", out temp))
            {
                gender = (string)temp == "male" ? Gender.Male : Gender.Female;
            }

            if (isFirstTimeFacebookLogin)
            {
                Analytic.SetUserProperties(new Dictionary <string, object>()
                {
                    { "facebookId", facebookId },
                    { "fullName", fullName },
                    { "email", email },
                    { "gender", gender.ToString() },
                });
            }

            //        {
            //  "id": "10204916518582922",
            //  "first_name": "Sergey",
            //  "last_name": "Kopov",
            //  "gender": "male",
            //  "age_range": {
            //    "min": 21
            //  },
            //  "email": "*****@*****.**",
            //  "friends": {
            //    "data": [
            //      {
            //        "first_name": "Nadia",
            //        "id": "10152536787152921",
            //        "picture": {
            //          "data": {
            //            "height": 200,
            //            "is_silhouette": false,
            //            "url": "https://scontent.xx.fbcdn.net/hprofile-xtp1/v/t1.0-1/c3.0.200.200/p200x200/12644751_10153453883592921_1769918035433820971_n.jpg?oh=ae9422673558c11eaad585a82de045cf&oe=573DE034",
            //            "width": 200
            //          }
            //        }
            //      },
            //      {
            //        "first_name": "Cassy",
            //        "id": "10154104640055550",
            //        "picture": {
            //          "data": {
            //            "height": 200,
            //            "is_silhouette": false,
            //            "url": "https://scontent.xx.fbcdn.net/hprofile-xlp1/v/t1.0-1/c0.0.200.200/p200x200/10427686_10154497538070550_3539351136513485076_n.jpg?oh=1a4559e9d234287f48671a833b2f0083&oe=573BC92F",
            //            "width": 200
            //          }
            //        }
            //      }
            //    ],
            //    "paging": {
            //      "next": "https://graph.facebook.com/v2.5/10204916518582922/friends?limit=2&fields=first_name,id,picture.width%28200%29.height%28200%29&access_token=CAALCpbbMpiMBAEusGokZAW2MglA6eo7hOOr0Bte0iGUeP2HmA4aUuApcBGt0MuK9dzmfLtezVgvRm6Lawe1lzFkME2FdTppzObiKX8cZASVeIohXHrg8IskTJ2Vba5hHnEbbgDYi5YxkYf1X1KHPzqdauU7bI2Jzsd4nyawtPZCwyyRSCRvndYP0ZAY7dTAT0WPgYO1YQThjOtWHiyRt&offset=2&__after_id=enc_AdCcdnvoxFY4TsuUZBK9NZBDuNXorDAxRY7WslZCiOZAhZBFZCwwJ0ohRCuTXWZAtmSFkCXdXMZD"
            //    },
            //    "summary": {
            //      "total_count": 905
            //    }
            //  },
            //  "invitable_friends": {
            //    "data": [
            //      {
            //        "first_name": "Александр",
            //        "picture": {
            //          "data": {
            //            "height": 200,
            //            "is_silhouette": false,
            //            "url": "https://scontent.xx.fbcdn.net/hprofile-xpl1/v/t1.0-1/p200x200/12688194_948009925247283_7846382134337642944_n.jpg?oh=ef70ffec6fc5dfbec6ed3e7253dc5b6b&oe=576C6440",
            //            "width": 200
            //          }
            //        },
            //        "id": "AVmIeKb_xKyqoqtwSoN34bz8KTNtizuCKdCEZSdXxPrunRHVdE5oYKYNWjvhblCTfGwj7BiW-EuqRXspVpzelG37fiy3fpQRt3FNz-mKJeTr-A"
            //      },
            //      {
            //        "first_name": "Aleksey",
            //        "picture": {
            //          "data": {
            //            "height": 200,
            //            "is_silhouette": false,
            //            "url": "https://scontent.xx.fbcdn.net/hprofile-xta1/v/t1.0-1/p200x200/10406801_10205409122241644_5094310415932755059_n.jpg?oh=b21d13d5389a85f96c0b62b2522f1323&oe=572DAF99",
            //            "width": 200
            //          }
            //        },
            //        "id": "AVnm11pdjHBaxE0x0yyVAVZMTy6dRekqtVWTT5YkGJ0m9k9tMwu_2Ow8Dskm2BE-7JmPvKUKpl84HyB5Oo1VMYHa2gPBttc9yYS742OF9e0jvw"
            //      }
            //    ],
            //    "paging": {
            //      "cursors": {
            //        "before": "QVZAraThVa2ozSDNQdnV1N1F1SWM5VFhHLTZAGaU1XdVBSQUpoMGRyaEYyZAm15bC0yWF9CcVNvY1VONGp6Q2h6c0xWQUFKM0FCckljcmYwVzZArQ0ZABdUdlM2EyaDlyWXkwbUQzMTZAaYkloeWRaRVEZD",
            //        "after": "QVZAtRzR2andlT19xMjZAIX1plMTYxTk5DZAHRuNE8wV1RuYXFKUmotYTF5d19UQkxrSFAwZAmtTRmF6ZAzh6aGhwM0UxelhJUmcyVFhrVEZAhYXMtQl9jWkp5anZAwRWNiSWh4a2RvZAVpVRV9sWkx4dmcZD"
            //      },
            //      "next": "https://graph.facebook.com/v2.5/10204916518582922/invitable_friends?access_token=CAALCpbbMpiMBAEusGokZAW2MglA6eo7hOOr0Bte0iGUeP2HmA4aUuApcBGt0MuK9dzmfLtezVgvRm6Lawe1lzFkME2FdTppzObiKX8cZASVeIohXHrg8IskTJ2Vba5hHnEbbgDYi5YxkYf1X1KHPzqdauU7bI2Jzsd4nyawtPZCwyyRSCRvndYP0ZAY7dTAT0WPgYO1YQThjOtWHiyRt&pretty=0&fields=first_name%2Cpicture.width%28200%29.height%28200%29&limit=2&after=QVZAtRzR2andlT19xMjZAIX1plMTYxTk5DZAHRuNE8wV1RuYXFKUmotYTF5d19UQkxrSFAwZAmtTRmF6ZAzh6aGhwM0UxelhJUmcyVFhrVEZAhYXMtQl9jWkp5anZAwRWNiSWh4a2RvZAVpVRV9sWkx4dmcZD"
            //    }
            //  }
            //}
        }