Example #1
0
        public static void Build(JSONObject response)
        {
            ResponseEvent responseEvent = Spil.MonoInstance.gameObject.AddComponent <ResponseEvent>();

            responseEvent.eventName = response.GetField("name").str;

            if (response.HasField("type"))
            {
                responseEvent.type = response.GetField("type").str;
            }

            if (response.HasField("action"))
            {
                responseEvent.action = response.GetField("action").str;
            }

            if (response.HasField("data"))
            {
                responseEvent.data = response.GetField("data");
            }

            if (responseEvent.type != null)
            {
                switch (responseEvent.type.ToLower().Trim())
                {
                case "advertisement":
                    AdvertisementResponse.ProcessAdvertisementResponse(responseEvent);
                    break;

                case "overlay":
                    OverlayResponse.ProcessOverlayResponse(responseEvent);
                    break;

                case "gameconfig":
                    ConfigResponse.ProcessConfigResponse(responseEvent);
                    break;

                case "packages":
                    PackagesResponse.ProcessPackagesResponse(responseEvent);
                    break;

                case "notification":
                    break;

                case "gamedata":
                    GameDataResponse.ProcessGameDataResponse(responseEvent);
                    break;

                case "promotions":
                    PromotionsResponse.ProcessPromotionResponse(responseEvent);
                    break;

                case "userdata":
                    UserDataResponse.ProcessUserDataResponse(responseEvent);
                    break;

                case "playerdata":
                    PlayerDataResponse.ProcessPlayerDataResponse(responseEvent);
                    break;

                case "gamestate":
                    GameStateResponse.ProcessGameStateResponse(responseEvent);
                    break;

                case "reward":
                    RewardResponse.ProcessRewardResponse(responseEvent);
                    break;

                case "liveevent":
                    LiveEventResponse.ProcessLiveEventResponse(responseEvent);
                    break;

                case "authentication":
                    SocialLoginResponse.ProcessSocialLoginResponse(responseEvent);
                    break;
                }
            }
            GameObject.Destroy(responseEvent);
        }