Exemplo n.º 1
0
    public void Reinit()
    {
        Game.getInstance().release();
        string appKey           = "FDBE1788-C7E2-94A9-0B79-7B4B418F5871";
        string appSecret        = "8bd1bd4e5ad4ae603039a6c6e3f41ecb";
        string privateKey       = "0FBA2600D9720A14793946F640CF8708";
        string oauthLoginServer = "http://10.10.10.253:8080/AnyLoginOauth/";

        Game.getInstance().init(appKey, appSecret, privateKey, oauthLoginServer);
        GameUser.getInstance().setListener(this, "UserExternalCall");
        GameIAP.getInstance().setListener(this, "IAPExternalCall");
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        TransferRate._Inst.Send("Init SDK Begin");
        _QuestTypeMirror = new Dictionary <QuestKind, string>();
        _QuestTypeMirror[QuestKind.QK_Main]       = ((int)TaskType.MAIN_LINE).ToString();
        _QuestTypeMirror[QuestKind.QK_Daily]      = ((int)TaskType.DAILY).ToString();
        _QuestTypeMirror[QuestKind.QK_Profession] = ((int)TaskType.OTHER).ToString();
        _QuestTypeMirror[QuestKind.QK_Sub]        = ((int)TaskType.BRANCH_LINE).ToString();
        _QuestTypeMirror[QuestKind.QK_Tongji]     = ((int)TaskType.ACTIVITY).ToString();

        string appKey           = "FDBE1788-C7E2-94A9-0B79-7B4B418F5871";
        string appSecret        = "8bd1bd4e5ad4ae603039a6c6e3f41ecb";
        string privateKey       = "0FBA2600D9720A14793946F640CF8708";
        string oauthLoginServer = "http://10.10.10.253:8080/AnyLoginOauth/";

        Game.getInstance().init(appKey, appSecret, privateKey, oauthLoginServer);

        GameUser.getInstance().setListener(this, "UserExternalCall");

        GameIAP.getInstance().setListener(this, "IAPExternalCall");

        CommonEvent.OnAppPause          += OnAppPause;
        CommonEvent.OnAppResume         += OnAppResume;
        CommonEvent.OnAccountChange     += OnAccountChange;    //Login regist logout
        CommonEvent.OnQuestFinish       += OnQuestFinish;
        CommonEvent.OnQuestFail         += OnQuestFail;
        CommonEvent.OnQuestStart        += OnQuestStart;
        CommonEvent.OnException         += OnException;
        CommonEvent.OnPurchase          += OnPurchase;
        CommonEvent.OnUseItem           += OnUseItem;
        CommonEvent.OnRewardVirtualCash += OnRewardVirtualCash;

#if UNITY_IOS || UNITY_IPHONE
        OnAppResume();
#endif
    }
Exemplo n.º 3
0
    void IAPExternalCall(string msg)
    {
        Dictionary <string, string> dic = GameUtil.stringToDictionary(msg);
        int    code   = Convert.ToInt32(dic["code"]);
        string result = dic["msg"];

        ClientLog.Instance.Log("IAPExternalCall( code: " +  +code + "  result: " + result + ")");

        Dictionary <string, string> map;
        GameParam param;

        string orderId = GameIAP.getInstance().getOrderId(GameIAP.getInstance().getPluginId()[0]);

        if (code != (int)PayResultCode.kPaySuccess)
        {
            map                            = new Dictionary <string, string>();
            map["Order_Id"]                = orderId;
            map["Product_Name"]            = _PayInfo == null? "": orderId;
            map["Currency_Amount"]         = _PayInfo == null? "": _PayInfo._PayPrice;
            map["Currency_Type"]           = "CNY";
            map["Payment_Type"]            = Game.getInstance().getChannelId();
            map["Virtual_Currency_Amount"] = _PayInfo == null? "": _PayInfo._PayVirtual;
            param                          = new GameParam(map);
            GameAnalytics.getInstance().callFuncWithParam("onChargeRequest", param);
        }

        switch (code)
        {
        case (int)PayResultCode.kPaySuccess:        //支付成功回调

            break;

        case (int)PayResultCode.kPayFail:        //支付失败回调
            PopText.Instance.Show(LanguageManager.instance.GetValue("payFail"), PopText.WarningType.WT_Warning);
            map                = new Dictionary <string, string>();
            map["Order_Id"]    = orderId;
            map["Fail_Reason"] = "PayFail";
            param              = new GameParam(map);
            GameAnalytics.getInstance().callFuncWithParam("onChargeFail", param);
            break;

        case (int)PayResultCode.kPayCancel:        //支付取消回调
            PopText.Instance.Show(LanguageManager.instance.GetValue("payCancel"), PopText.WarningType.WT_Warning);
            map                = new Dictionary <string, string>();
            map["Order_Id"]    = orderId;
            map["Fail_Reason"] = "PayCancel";
            param              = new GameParam(map);
            GameAnalytics.getInstance().callFuncWithParam("onChargeFail", param);
            break;

        case (int)PayResultCode.kPayNetworkError:        //支付超时回调
            PopText.Instance.Show(LanguageManager.instance.GetValue("payNetworkErr"), PopText.WarningType.WT_Warning);
            map                = new Dictionary <string, string>();
            map["Order_Id"]    = orderId;
            map["Fail_Reason"] = "payNetworkErr";
            param              = new GameParam(map);
            GameAnalytics.getInstance().callFuncWithParam("onChargeFail", param);
            break;

        case (int)PayResultCode.kPayProductionInforIncomplete:        //支付信息不完整
            map                = new Dictionary <string, string>();
            map["Order_Id"]    = orderId;
            map["Fail_Reason"] = "payIncompleteInfo";
            param              = new GameParam(map);
            GameAnalytics.getInstance().callFuncWithParam("onChargeFail", param);
            break;

        /**
         * 新增加:正在进行中回调
         * 支付过程中若SDK没有回调结果,就认为支付正在进行中
         * 游戏开发商可让玩家去判断是否需要等待,若不等待则进行下一次的支付
         */
        case (int)PayResultCode.kPayNowPaying:
            GameIAP.getInstance().resetPayState();
            map                = new Dictionary <string, string>();
            map["Order_Id"]    = orderId;
            map["Fail_Reason"] = "otherPaying";
            param              = new GameParam(map);
            GameAnalytics.getInstance().callFuncWithParam("onChargeFail", param);
            break;

        default:
            map                = new Dictionary <string, string>();
            map["Order_Id"]    = orderId;
            map["Fail_Reason"] = "otherReason";
            param              = new GameParam(map);
            GameAnalytics.getInstance().callFuncWithParam("onChargeFail", param);
            break;
        }

        _PayInfo = null;
    }