Ejemplo n.º 1
0
        public virtual bool ProcessError(EB.Sparx.Response response, EB.Sparx.eResponseCode errCode)
        {
            if (ErrorHandler != null)
            {
                var dels = ErrorHandler.GetInvocationList();
                foreach (var del in dels)
                {
                    var func = del as System.Func <EB.Sparx.Response, EB.Sparx.eResponseCode, bool>;
                    if (func(response, errCode))
                    {
                        EB.Debug.Log("SparxAPI.ProcessError: process error {0} success", errCode);
                        return(true);
                    }
                }
            }

            if (GlobalErrorHandler != null)
            {
                var dels = GlobalErrorHandler.GetInvocationList();
                foreach (var del in dels)
                {
                    var func = del as System.Func <EB.Sparx.Response, EB.Sparx.eResponseCode, bool>;
                    if (func(response, errCode))
                    {
                        EB.Debug.Log("SparxAPI.ProcessError: process error {0} success", errCode);
                        return(true);
                    }
                }
            }

            EB.Debug.LogError("SparxAPI.ProcessError: request {0} failed, {1}:{2}", response.request.uri, errCode, response.error);

            return(false);
        }
Ejemplo n.º 2
0
 public static bool CheckAndShowModal(this EB.Sparx.eResponseCode response)
 {
     if (response == EB.Sparx.eResponseCode.Success)
     {
         return(true);
     }
     else
     {
         ShowErrorDialogue(TranslateToUIText(response));
         return(false);
     }
 }
Ejemplo n.º 3
0
    public static bool GlobalErrorHandler(EB.Sparx.Response response, EB.Sparx.eResponseCode errCode)
    {
        if (response.fatal)
        {
            SparxHub.Instance.FatalError(response.localizedError);
        }
        else
        {
            ShowErrorDialogue(response.localizedError);
        }

        return(false);
    }
Ejemplo n.º 4
0
        public override bool ProcessResponse(EB.Sparx.Response response)
        {
            if (!response.sucessful && response.fatal)
            {
                EB.Debug.LogError("SparxAPI.ProcessResponse: error {0} occur when request {1}", response.error,
                                  response.request.uri);
                ProcessError(response, CheckError(response.error.ToString()));
                return(false);
            }

            if (!response.sucessful)
            {
                string errStr = response.error.ToString();
                if (errStr != null && errStr.Equals("ID_FIELD_HAVE_FULL"))
                {
                    GlobalMenuManager.Instance.RemoveCache("AllianceHudUI");
                    GlobalMenuManager.Instance.RemoveCache("AllianceBattleResultUI");
                    GlobalMenuManager.Instance.CloseMenu("AllianceBattleResultUI");
                    AlliancesManager.Instance.BattleInfo.IsFieldFull = true;
                }
                else if (errStr != null && errStr.Equals("ID_FIELD_CONDITION_NOT_MEET"))
                {
                    MessageTemplateManager.ShowMessage(902187, null, delegate(int result)
                    {
                        if (result == 0)
                        {
                            GlobalMenuManager.Instance.RemoveCache("AllianceHudUI");
                            GlobalMenuManager.Instance.RemoveCache("AllianceBattleResultUI");
                            GlobalMenuManager.Instance.CloseMenu("AllianceBattleResultUI");
                        }
                    });
                    return(false);
                }
                else if (errStr != null &&
                         (errStr.Equals("ID_ALLIANCE_NOT_IN_TRANSFER") || errStr.Equals("ID_ALLIANCE_ROBED")))
                {
                    AlliancesManager.Instance.GetRobInfo();
                }

                EB.Sparx.eResponseCode errCode = CheckError(response.error.ToString());
                if (errCode != EB.Sparx.eResponseCode.Success && !ProcessError(response, errCode))
                {
                    EB.Debug.LogError("SparxAPI.ProcessResponse: request {0} failed, {1}", response.request.uri,
                                      response.error);
                    return(false);
                }
            }

            return(ProcessResult(response));
        }
Ejemplo n.º 5
0
 private void ProcessError(EB.Sparx.Response response)
 {
     if (response.fatal)
     {
         EB.Debug.LogError("LTHeroBattleAPI.ProcessError: error {0} occur when request {1}", response.error,
                           response.request.uri);
         ProcessError(response, CheckError(response.error.ToString()));
     }
     else
     {
         EB.Sparx.eResponseCode errCode = CheckError(response.error.ToString());
         if (errCode != EB.Sparx.eResponseCode.Success && !ProcessError(response, errCode))
         {
             EB.Debug.LogError("LTHeroBattleAPI.ProcessError: request {0} failed, {1}", response.request.uri, response.error);
         }
     }
 }
Ejemplo n.º 6
0
        static StackObject *Invoke_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            EB.Sparx.eResponseCode @obj = (EB.Sparx.eResponseCode) typeof(EB.Sparx.eResponseCode).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Action <EB.Sparx.eResponseCode> instance_of_this_method = (System.Action <EB.Sparx.eResponseCode>) typeof(System.Action <EB.Sparx.eResponseCode>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Invoke(@obj);

            return(__ret);
        }
Ejemplo n.º 7
0
    public static string TranslateToUIText(EB.Sparx.eResponseCode response)
    {
        bool isNetworkReachable = Application.internetReachability != NetworkReachability.NotReachable;

        string result = null;

        switch (response)
        {
        case EB.Sparx.eResponseCode.Success:
            result = "Operation successful!";
            break;

        case EB.Sparx.eResponseCode.InsufficientHardCurrency:
            result = "You don't have enough gems. Go to the store to buy more!";
            break;

        case EB.Sparx.eResponseCode.InsufficientSocialCurrency:
            result = "You don't have enough tickets for this purchase.";
            break;

        case EB.Sparx.eResponseCode.InsufficientSoftCurrency:
            result = "You don't have enough gold for this purchase.";
            break;

        case EB.Sparx.eResponseCode.InsufficientStamina:
            result = "You don't have enough stamina. Get more using the + button!";
            break;

        default:
            if (!isNetworkReachable)
            {
                result = "Could not connect to network.";
            }
            else
            {
                result = "An error occurred.";
            }
            break;
        }

        return(result);
    }
Ejemplo n.º 8
0
        public virtual bool ProcessResponse(EB.Sparx.Response response)
        {
            if (!response.sucessful && response.fatal)
            {
                EB.Debug.LogError("SparxAPI.ProcessResponse: error {0} occur when request {1}", response.error, response.request.uri);
                ProcessError(response, CheckError(response.error.ToString()));
                return(false);
            }

            if (!response.sucessful)
            {
                EB.Sparx.eResponseCode errCode = CheckError(response.error.ToString());
                if (errCode != EB.Sparx.eResponseCode.Success && !ProcessError(response, errCode))
                {
                    EB.Debug.LogError("SparxAPI.ProcessResponse: request {0} failed, {1}", response.request.uri, response.error);
                    return(false);
                }
            }

            return(ProcessResult(response));
        }
Ejemplo n.º 9
0
        static StackObject *ProcessError_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            EB.Sparx.eResponseCode @errCode = (EB.Sparx.eResponseCode) typeof(EB.Sparx.eResponseCode).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            EB.Sparx.Response @response = (EB.Sparx.Response) typeof(EB.Sparx.Response).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            EB.Sparx.SparxAPIWithoutEndpoint instance_of_this_method = (EB.Sparx.SparxAPIWithoutEndpoint) typeof(EB.Sparx.SparxAPIWithoutEndpoint).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.ProcessError(@response, @errCode);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
Ejemplo n.º 10
0
 public static void ShowErrorModal(this EB.Sparx.eResponseCode response)
 {
     ShowErrorDialogue(TranslateToUIText(response));
 }
Ejemplo n.º 11
0
 private bool ErrorHandler(EB.Sparx.Response response, EB.Sparx.eResponseCode errCode)
 {
     return(false);
 }