Beispiel #1
0
        public static Yodo1U3dAdError createWithJson(string errorJsonString)
        {
            Yodo1U3dAdError             error    = new Yodo1U3dAdError();
            Dictionary <string, object> errorDic = (Dictionary <string, object>)Yodo1JSON.Deserialize(errorJsonString);

            if (errorDic != null)
            {
                if (errorDic.ContainsKey("code"))
                {
                    error.Code = int.Parse(errorDic["code"].ToString());
                }
                if (errorDic.ContainsKey("message"))
                {
                    error.Message = errorDic["message"].ToString();
                }
            }
            return(error);
        }
Beispiel #2
0
        public void Yodo1U3dMasCallbackResult(string result)
        {
            Debug.Log("[Yodo1 Mas] The SDK callback result:" + result + "\n");

            Dictionary <string, object> obj = (Dictionary <string, object>)Yodo1JSON.Deserialize(result);

            if (obj == null)
            {
                return;
            }

            if (!obj.ContainsKey("flag") || !obj.ContainsKey("data"))
            {
                return;
            }

            string jsonData = obj["data"].ToString();
            Dictionary <string, object> dataDic = (Dictionary <string, object>)Yodo1JSON.Deserialize(jsonData);

            if (dataDic == null)
            {
                return;
            }

            int flag = int.Parse(obj["flag"].ToString());

            if (flag == FLAG_INITIALIZE)
            {
                bool            success = false;
                Yodo1U3dAdError error   = new Yodo1U3dAdError();

                if (dataDic.ContainsKey("success"))
                {
                    success = int.Parse(dataDic["success"].ToString()) == EVENT_INITIALIZE_SUCCESS ? true : false;
                }
                if (dataDic.ContainsKey("error"))
                {
                    string errorStr = dataDic["error"].ToString();
                    error = Yodo1U3dAdError.createWithJson(errorStr);
                }

                if (_initializeDelegate != null)
                {
                    _initializeDelegate(success, error);
                }
            }
            else if (flag == FLAG_AD_EVENT)
            {
                AdType type = AdType.Rewarded;
                if (dataDic.ContainsKey("type"))
                {
                    type = (AdType)int.Parse(dataDic["type"].ToString());
                }
                else
                {
                    return;
                }
                Yodo1U3dAdEvent eventCode = Yodo1U3dAdEvent.AdError;
                if (dataDic.ContainsKey("code"))
                {
                    eventCode = (Yodo1U3dAdEvent)int.Parse(dataDic["code"].ToString());
                }
                string message;
                if (dataDic.ContainsKey("message"))
                {
                    message = dataDic["message"].ToString();
                }
                Yodo1U3dAdError error = new Yodo1U3dAdError();
                if (dataDic.ContainsKey("error"))
                {
                    error = Yodo1U3dAdError.createWithJson(dataDic["error"].ToString());
                }

                switch (type)
                {
                case AdType.Rewarded:
                {
                    if (_rewardedAdDelegate != null)
                    {
                        _rewardedAdDelegate(eventCode, error);
                    }
                }
                break;

                case AdType.Interstitial:
                    if (_interstitialAdDelegate != null)
                    {
                        _interstitialAdDelegate(eventCode, error);
                    }
                    break;

                case AdType.Banner:
                    if (_bannerDelegate != null)
                    {
                        _bannerDelegate(eventCode, error);
                    }
                    break;

                default:
                    break;
                }
            }
        }