public void CloseAd()
        {
            AdFinished adFinished = new AdFinished();

            adFinished.network = provider;
            adFinished.type    = adType;
            adFinished.reason  = "close";

            if (adType.ToLower().Trim().Equals("rewardvideo"))
            {
                adFinished.reward = new AdReward();

                if (Spil.CurrencyName != null)
                {
                    adFinished.reward.currencyName = Spil.CurrencyName;
                }

                if (Spil.CurrencyId != null)
                {
                    adFinished.reward.currencyId = Spil.CurrencyId;
                }

                if (Spil.Reward != 0)
                {
                    adFinished.reward.reward = Spil.Reward;
                }
            }

            SpilUnityImplementationBase.fireAdFinishedEvent(JsonHelper.getJSONFromObject(adFinished));
            provider = null;
            adType   = null;
            Destroy(AdOverlay);
        }
Ejemplo n.º 2
0
        public static void ProcessOverlayResponse(ResponseEvent response)
        {
            string url = null;

            if (response.data.HasField("url"))
            {
                url = response.data.GetField("url").Print(false);
            }

            if (response.action.ToLower().Trim().Equals("show"))
            {
                if (response.eventName.ToLower().Equals("splashscreen"))
                {
                    OverlayManager.ShowSplashScreen(response.data, url);
                }
                else if (response.eventName.ToLower().Equals("dailybonus"))
                {
                    OverlayManager.ShowDailyBonus(response.data, url);
                }
            }
            else if (response.action.ToLower().Trim().Equals("notavailable"))
            {
                if (response.eventName.ToLower().Equals("splashscreen"))
                {
                    SpilUnityImplementationBase.fireSplashScreenNotAvailable();
                }
                else if (response.eventName.ToLower().Equals("dailybonus"))
                {
                    SpilUnityImplementationBase.fireDailyBonusNotAvailable();
                }
            }
        }
 public static void OpenLiveEvent()
 {
     if (liveEventOverview.alwaysShowStartStage)
     {
         if (liveEventOverview.startStage != null)
         {
             OpenStageView(StageType.START, liveEventOverview.startStage);
         }
         else
         {
             SpilUnityImplementationBase.fireLiveEventNotAvailable();
         }
     }
     else
     {
         if (liveEventOverview.currentStage != null)
         {
             OpenStageView(StageType.PROGRESS, liveEventOverview.currentStage);
         }
         else if (liveEventOverview.startStage != null)
         {
             OpenStageView(StageType.START, liveEventOverview.startStage);
         }
         else
         {
             SpilUnityImplementationBase.fireLiveEventNotAvailable();
         }
     }
 }
        private static void OpenStageView(StageType stageType, JSONObject stage)
        {
            CloseStageView();

            StageTypeValue = stageType;
            switch (stageType)
            {
            case StageType.START:
                LiveEventStart = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Spilgames/Editor/Prefabs/LiveEventStart.prefab"));
                LiveEventStart.SetActive(true);

                stageData = stage;
                break;

            case StageType.PROGRESS:
                LiveEventProgress = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Spilgames/Editor/Prefabs/LiveEventProgress.prefab"));
                LiveEventProgress.SetActive(true);

                applyItems   = new JSONObject(JSONObject.Type.ARRAY);
                currentStage = stage;
                break;

            case StageType.INFO:
                LiveEventInfo = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Spilgames/Editor/Prefabs/LiveEventInfo.prefab"));
                LiveEventInfo.SetActive(true);

                currentStage = stage;
                break;
            }

            SpilUnityImplementationBase.fireLiveEventStageOpen();
        }
        private static void CloseStageView()
        {
            stageData    = null;
            currentStage = null;
            id           = "";
            amount       = "";
            applyItems   = null;

            switch (StageTypeValue)
            {
            case StageType.START:
                Destroy(LiveEventStart);
                break;

            case StageType.PROGRESS:
                Destroy(LiveEventProgress);
                break;

            case StageType.INFO:
                Destroy(LiveEventInfo);
                break;
            }

            SpilUnityImplementationBase.fireLiveEventStageClosed();
        }
 public static void ProcessUserLogout()
 {
     Spil.Instance.SetUserId(null, null);
     Spil.SpilUserIdEditor = Guid.NewGuid().ToString();
     SpilUnityEditorImplementation.spilToken = null;
     SpilUnityImplementationBase.fireLogoutSuccessful();
 }
Ejemplo n.º 7
0
        public static void ProcessBoughtPromotionResponse(SpilPromotionData boughtPromotion)
        {
            SpilPromotionData promotion = null;

            foreach (SpilPromotionData promotionData in PromotionData)
            {
                if (promotionData.id == boughtPromotion.id)
                {
                    promotionData.amountPurchased = boughtPromotion.amountPurchased;
                    promotion = promotionData;
                    break;
                }
            }

            bool maxReached = false;

            if (promotion != null && (promotion.amountPurchased == promotion.maxPurchase || promotion.amountPurchased > promotion.maxPurchase))
            {
                PromotionData.Remove(promotion);
                maxReached = true;
            }

            JSONObject data = new JSONObject();

            data.AddField("promotionId", boughtPromotion.id);
            data.AddField("amountPurchased", boughtPromotion.amountPurchased);
            data.AddField("maxAmountReached", maxReached);

            SpilUnityImplementationBase.firePromotionAmountBought(data.Print());
        }
        public override void UserPlayAsGuest()
        {
            SpilEvent spilEvent = Spil.MonoInstance.gameObject.AddComponent <SpilEvent>();

            spilEvent.eventName = "userPlayAsGuest";

            string newUid = Guid.NewGuid().ToString();

            spilEvent.customData.AddField("newUid", newUid);

            spilEvent.Send();

            Spil.SpilUserIdEditor = newUid;
            unauthorized          = false;
            spilToken             = null;

            JSONObject loginResponse = new JSONObject();

            loginResponse.AddField("resetData", true);
            loginResponse.AddField("socialProvider", (string)null);
            loginResponse.AddField("socialId", (string)null);
            loginResponse.AddField("isGuest", true);

            SpilUnityImplementationBase.fireLoginSuccessful(loginResponse.Print());
        }
Ejemplo n.º 9
0
        public static void ShowDailyBonus(JSONObject data, string url)
        {
            SpilLogging.Log("Opening URL: " + url + " With data: " + data.Print(false));

            SpilUnityImplementationBase.fireDailyBonusOpen();

            DailyBonus = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Spilgames/Editor/Prefabs/DailyBonus.prefab"));
            DailyBonus.SetActive(true);
        }
Ejemplo n.º 10
0
    public void InfoAccepted()
    {
        if (openId == 2)
        {
            SpilUnityImplementationBase.fireAdNotAvailableEvent("rewardVideo");
        }

        Destroy(PrivacyPolicyObject);
    }
 public static void PlayMoreApps()
 {
     AdOverlay = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Spilgames/Editor/Prefabs/AdOverlay.prefab"));
     AdOverlay.SetActive(true);
     provider   = "Spil";
     adType     = "moreApps";
     adInfoText = provider + " " + adType + " is playing!";
     SpilUnityImplementationBase.fireAdStartedEvent();
 }
 public static void ProcessConfigResponse(ResponseEvent response)
 {
     if (response.data == null)
     {
         return;
     }
     ConfigManager.GameConfigData = response.data.Print();
     SpilUnityImplementationBase.fireConfigUpdatedEvent();
 }
        public static void ProcessMergeUserData(List <UserDataVersion> receivedUserDataVersions)
        {
            userDataVersions = receivedUserDataVersions;

            remoteUserDataVersions = null;

            Spil.Instance.RequestLiveEvent();
            SpilUnityImplementationBase.fireUserDataMergeSuccessful();
        }
 public void RequestLogin()
 {
     SpilUnityImplementationBase.fireRequestLogin();
     title           = null;
     message         = null;
     loginText       = null;
     playAsGuestText = null;
     Destroy(SocialOverlay);
 }
Ejemplo n.º 15
0
        public void AcceptPrivacyPolicy()
        {
            if (Spil.Instance.GetPrivValue() < 0)
            {
                Spil.Instance.SavePrivValue(3);
                SpilUnityImplementationBase.firePrivacyPolicyStatus(true);
            }

            Destroy(PrivacyPolicy);
        }
        public static void ProcessUserLoginError(JSONObject socialLoginJSON)
        {
            if (socialLoginJSON.HasField("authError"))
            {
                long authError = socialLoginJSON.GetField("authError").i;

                SpilErrorMessage error = new SpilErrorMessage();

                switch (authError)
                {
                case 1:
                    error.id      = 32;
                    error.name    = "InvalidSpilTokenError";
                    error.message = "Spil Token is invalid! Please login again!";
                    break;

                case 3:
                    error.id      = 34;
                    error.name    = "InvalidSocialTokenError";
                    error.message = "The provided social token could not be verified with the backend";
                    break;

                case 4:
                    error.id      = 35;
                    error.name    = "UserAlreadyLinkedError";
                    error.message = "User already has a social provider account";
                    break;

                case 5:
                    error.id      = 36;
                    error.name    = "SocialIdAlreadyLinkedError";
                    error.message = "The social id is already linked to another user!";
                    break;

                default:
                    error.id      = 37;
                    error.name    = "SocialLoginServerError";
                    error.message = "Error communicating with the server!";
                    break;
                }

                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));
            }
            else
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";

                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));
            }
        }
Ejemplo n.º 17
0
        public PlayerDataHelper(SpilUnityImplementationBase Instance)
        {
            string walletString    = Instance.GetWalletFromSdk();
            string inventoryString = Instance.GetInvetoryFromSdk();

            if (walletString != null && inventoryString != null)
            {
                WalletData    walletData    = JsonHelper.getObjectFromJson <WalletData>(walletString);
                InventoryData inventoryData = JsonHelper.getObjectFromJson <InventoryData>(inventoryString);

                AddDataToHelper(walletData != null ? walletData.currencies : null, inventoryData != null ? inventoryData.items : null);
            }
        }
        public void DismissAd()
        {
            AdFinished adFinished = new AdFinished();

            adFinished.network = provider;
            adFinished.type    = adType;
            adFinished.reason  = "dismiss";

            SpilUnityImplementationBase.fireAdFinishedEvent(JsonHelper.getJSONFromObject(adFinished));
            provider = null;
            adType   = null;
            Destroy(AdOverlay);
        }
Ejemplo n.º 19
0
        public void IAPPurchaseRequest()
        {
            if (Spil.IapPurchaseRequest == null || Spil.IapPurchaseRequest.Equals(""))
            {
                SpilLogging.Error("Iap Purchase Request SKU Id not set! Please configure value in the Spil SDK object!");
            }
            else
            {
                SpilUnityImplementationBase.fireIAPRequestPurchase(Spil.IapPurchaseRequest);
            }

            Destroy(SplashScreen);
        }
        public static void ProcessUserLogin(JSONObject socialLoginJSON)
        {
            if (socialLoginJSON == null)
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";
                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));

                return;
            }

            string uid            = socialLoginJSON.GetField("uid").str;
            string spilToken      = socialLoginJSON.GetField("spilToken").str;
            string socialProvider = socialLoginJSON.GetField("socialProvider").str;
            string socialId       = socialLoginJSON.GetField("socialId").str;

            if (uid != null && spilToken != null && socialProvider != null && socialId != null)
            {
                bool resetData = false;

                if (!Spil.SpilUserIdEditor.Equals(uid))
                {
                    resetData             = true;
                    Spil.SpilUserIdEditor = uid;
                }

                SpilUnityEditorImplementation.spilToken = spilToken;

                Spil.Instance.SetUserId(socialProvider, socialId);

                SpilUnityEditorImplementation.unauthorized = false;

                JSONObject loginMessage = new JSONObject();
                loginMessage.AddField("resetData", resetData);
                loginMessage.AddField("socialProvider", socialProvider);
                loginMessage.AddField("socialId", socialId);
                loginMessage.AddField("isGuest", false);

                SpilUnityImplementationBase.fireLoginSuccessful(loginMessage.Print());
            }
            else
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";
                SpilUnityImplementationBase.fireLoginFailed(JsonUtility.ToJson(error));
            }
        }
Ejemplo n.º 21
0
        public static void ProcessRewardResponse(ResponseEvent response)
        {
            string reason = "";

            if (RewardManager.rewardFeatureType.ToString().ToLower().Trim().Equals(RewardManager.DeepLink))
            {
                reason = PlayerDataUpdateReasons.Deeplink;
            }
            else if (RewardManager.rewardFeatureType.ToString().ToLower().Trim().Equals(RewardManager.PushNotification))
            {
                reason = PlayerDataUpdateReasons.PushNotification;
            }

            if (RewardManager.rewardType == Spil.TokenRewardTypeEnum.EXTERNAL)
            {
                JSONObject rewards = new JSONObject(JSONObject.Type.ARRAY);

                JSONObject reward = new JSONObject();
                reward.AddField("externalId", Spil.TokenExternalRewardId);
                reward.AddField("amount", Spil.TokenRewardAmount);
                reward.AddField("type", RewardManager.rewardType.ToString());

                rewards.Add(reward);

                JSONObject json = new JSONObject();
                json.AddField("reward", rewards);
                json.AddField("rewardType", RewardManager.rewardFeatureType.ToString());

                SpilUnityImplementationBase.fireRewardTokenClaimed(json.Print());
            }
            else
            {
                int id     = Spil.TokenRewardId;
                int amount = Spil.TokenRewardAmount;

                if (id == 0 || amount == 0)
                {
                    SpilLogging.Error("Token Rewards not configured for Editor!");
                }

                if (RewardManager.rewardType == Spil.TokenRewardTypeEnum.CURRENCY)
                {
                    SpilUnityEditorImplementation.pData.WalletOperation("add", id, amount, reason, null, "DeepLink", null);
                }
                else if (RewardManager.rewardType == Spil.TokenRewardTypeEnum.ITEM)
                {
                    SpilUnityEditorImplementation.pData.InventoryOperation("add", id, amount, reason, null, "DeepLink", null);
                }
            }
        }
        public static void ProcessUnauthorizedResponse(string errorJSONString)
        {
            if (SpilUnityEditorImplementation.unauthorized)
            {
                return;
            }

            SpilUnityEditorImplementation.unauthorized = true;

            JSONObject errorJSON = new JSONObject(errorJSONString);

            if (errorJSON.HasField("authError"))
            {
                long authError = errorJSON.GetField("authError").i;

                SpilErrorMessage error = new SpilErrorMessage();

                switch (authError)
                {
                case 1:
                    error.id      = 32;
                    error.name    = "InvalidSpilTokenError";
                    error.message = "Spil Token is invalid! Please login again!";
                    break;

                case 2:
                    error.id      = 33;
                    error.name    = "RequriesLoginError";
                    error.message = "Event requires user login!";
                    break;

                default:
                    error.id      = 37;
                    error.name    = "SocialLoginServerError";
                    error.message = "Error communicating with the server!";
                    break;
                }

                SpilUnityImplementationBase.fireAuthenticationError(JsonUtility.ToJson(error));
            }
            else
            {
                SpilErrorMessage error = new SpilErrorMessage();
                error.id      = 37;
                error.name    = "SocialLoginServerError";
                error.message = "Error communicating with the server!";

                SpilUnityImplementationBase.fireAuthenticationError(JsonUtility.ToJson(error));
            }
        }
        public static void ProcessPackagesResponse(ResponseEvent response)
        {
            if (response.data == null)
            {
                SpilUnityImplementationBase.firePackagesNotAvailable();
                return;
            }

            if (response.data.HasField("packages"))
            {
                JSONObject json = new JSONObject();
                json.AddField("data", response.data.GetField("packages").Print(false));
                PackagesManager.GamePackagesData = JsonHelper.getObjectFromJson <List <PackageData> >(json.GetField("data").str);
            }
        }
        /// <summary>
        /// Used to get the image from the cache, based on the url provided.ImageContext will be imageType = custom when it's not provided as parameter
        /// </summary>
        public override void RequestImage(string url, int id, string imageType)
        {
            JSONObject jsonObject = new JSONObject();

            jsonObject.AddField("localPath", url);

            JSONObject imageContextJSON = new JSONObject();

            imageContextJSON.AddField("id", id);
            imageContextJSON.AddField("imageType", imageType);
            imageContextJSON.AddField("imageUrl", url);

            jsonObject.AddField("imageContext", imageContextJSON);

            SpilUnityImplementationBase.fireImageLoadSuccess(jsonObject.Print());
        }
        public void RefreshData(SpilUnityImplementationBase Instance)
        {
            string spilGameDataString = Instance.GetSpilGameDataFromSdk();

            if (spilGameDataString != null)
            {
                SpilGameData spilGameData = JsonHelper.getObjectFromJson <SpilGameData>(spilGameDataString);
                if (spilGameData != null)
                {
                    AddDataToHelper(spilGameData.currencies, spilGameData.items, spilGameData.bundles, spilGameData.shop);
                    Debug.Log("Spil GameData Refreshed");
                }
                else
                {
                    Debug.Log("Spil GameData not created, Instance.GetSpilGameDataFromsdk() did not return any data.");
                }
            }
        }
        public static void ProcessRequestUserData(WalletData receivedWallet, InventoryData receivedInventory, bool externalChange, string gameStateData, List <UserDataVersion> receivedUserDataVersions, UserDataMeta receivedUserDataMeta)
        {
            SpilUnityEditorImplementation.pData.CalculatePlayerDataResponse(receivedWallet, receivedInventory, true);
            GameStateManager.ProcessMyGameStateResponse(new JSONObject(gameStateData));

            if (receivedUserDataVersions != null)
            {
                userDataVersions = receivedUserDataVersions;
            }

            UpdateUserDataMeta();
            if (receivedUserDataMeta != null)
            {
                userDataMeta.serverTime = receivedUserDataMeta.serverTime;
            }

            SpilUnityImplementationBase.fireUserDataAvailable();
        }
        public override void UserLogout(bool global)
        {
            SpilEvent spilEvent = Spil.MonoInstance.gameObject.AddComponent <SpilEvent>();

            spilEvent.eventName = "userLogout";

            spilEvent.customData.AddField("newUid", Spil.SpilUserIdEditor);
            spilEvent.customData.AddField("global", global);

            spilEvent.Send();

            if (!global)
            {
                SetUserId(null, null);
                Spil.SpilUserIdEditor = Guid.NewGuid().ToString();
                spilToken             = null;
                SpilUnityImplementationBase.fireLogoutSuccessful();
            }
        }
Ejemplo n.º 28
0
        public void CollectReward()
        {
            if (rewardType == Spil.DailyBonusRewardTypeEnum.EXTERNAL)
            {
                List <Reward> rewards = new List <Reward>();

                Reward reward = new Reward();
                reward.externalId = Spil.DailyBonusExternalId;
                reward.amount     = Spil.DailyBonusAmount;

                rewards.Add(reward);

                string rewardsJSON = JsonHelper.getJSONFromObject(rewards);

                JSONObject json = new JSONObject();
                json.AddField("data", rewardsJSON);

                SpilUnityImplementationBase.fireDailyBonusReward(json.Print(false));
            }
            else
            {
                int id     = Spil.DailyBonusId;
                int amount = Spil.DailyBonusAmount;

                if (id == 0 || amount == 0)
                {
                    SpilLogging.Error("Daily Bonus Rewards not configured for Editor!");
                }

                if (rewardType == Spil.DailyBonusRewardTypeEnum.CURRENCY)
                {
                    SpilUnityEditorImplementation.pData.WalletOperation("add", id, amount, PlayerDataUpdateReasons.DailyBonus, null, "DailyBonus", null);
                }
                else if (rewardType == Spil.DailyBonusRewardTypeEnum.ITEM)
                {
                    SpilUnityEditorImplementation.pData.InventoryOperation("add", id, amount, PlayerDataUpdateReasons.DailyBonus, null, "DailyBonus", null);
                }
            }

            Destroy(DailyBonus);
        }
        public static void ProcessOtherUsersGameStateResponse(JSONObject jsonData)
        {
            JSONObject json = new JSONObject();

            String provider = null;

            if (jsonData.HasField("provider"))
            {
                provider = jsonData.GetField("provider").str;
                json.AddField("provider", provider);
            }

            JSONObject gameStates = null;

            if (jsonData.HasField("gameStates"))
            {
                gameStates = jsonData.GetField("gameStates");
                json.AddField("data", gameStates);
            }

            SpilUnityImplementationBase.fireOtherUsersGameStateLoaded(json.Print(false));
        }
 public static void ProcessLiveEventResponse(ResponseEvent response)
 {
     if (response.data != null)
     {
         if (response.action.ToLower().Trim().Equals("request"))
         {
             LiveEventManager.ProcessRequestLiveEvent(response.data);
         }
         else if (response.action.ToLower().Trim().Equals("nextstage"))
         {
             LiveEventManager.ProcessAdvanceToNextStage(response.data);
         }
         else if (response.action.ToLower().Trim().Equals("applyitems"))
         {
             LiveEventManager.ProcessApplyItems(response.data);
         }
         else if (response.action.ToLower().Trim().Equals("notavailable"))
         {
             SpilUnityImplementationBase.fireLiveEventNotAvailable();
         }
     }
 }
        public PlayerDataHelper(SpilUnityImplementationBase Instance)
        {
            string walletString = Instance.GetWalletFromSdk ();
            string inventoryString = Instance.GetInvetoryFromSdk ();
            if (walletString != null && inventoryString != null) {
                WalletData walletData = JsonHelper.getObjectFromJson<WalletData> (walletString);
                InventoryData inventoryData = JsonHelper.getObjectFromJson<InventoryData> (inventoryString);

                AddDataToHelper (walletData != null ? walletData.currencies : null, inventoryData != null ? inventoryData.items : null);
            }
        }
 public void RefreshData(SpilUnityImplementationBase Instance)
 {
     string spilGameDataString = Instance.GetSpilGameDataFromSdk ();
     if (spilGameDataString != null) {
         SpilGameData spilGameData = JsonHelper.getObjectFromJson<SpilGameData> (spilGameDataString);
         if (spilGameData != null) {
             AddDataToHelper (spilGameData.currencies, spilGameData.items, spilGameData.bundles, spilGameData.shop, spilGameData.promotions);
             Debug.Log ("Spil GameData Refreshed");
         } else {
             Debug.Log ("Spil GameData not created, Instance.GetSpilGameDataFromsdk() did not return any data.");
         }
     }
 }