Exemple #1
0
    public override void InitSDK(SDKData.InitArgModel initArgModel)
    {
        SDKLogManager.DebugLog("InitSDK start ");
        SDKInitArgModel = initArgModel;

        onInitComplete   = initArgModel.onComplete;
        onLogoutComplete = initArgModel.onSDKLogoutComplete;

        //注册登入回调
        if (Application.platform == RuntimePlatform.Android)
        {
            using (AndroidJavaObject curActivity = CallAndroidFuncGetResult <AndroidJavaObject>("GetGameMainActivity"))
            {
                if (curActivity == null)
                {
                    SDKLogManager.DebugLog("GetGameMainActivity is null !", SDKLogManager.DebugType.LogError);
                    onInitComplete(false);
                    return;
                }
                setLoginListener(curActivity.GetRawObject(), gameObject.name, "LoginCallBack");
            }
        }

        SDKLogManager.DebugLog("InitSDK success");
        onInitComplete(true);
    }
Exemple #2
0
        /// <summary>
        /// 初始化(友盟初始化) - 参数:初始化回调  注销登入回调
        /// </summary>
        public virtual void InitSDK(SDKData.InitArgModel initArgModel)
        {
            SDKInitArgModel = initArgModel;

            onInitComplete   = initArgModel.onComplete;
            onLogoutComplete = initArgModel.onSDKLogoutComplete;

            SDKLogManager.DebugLog("InitSDK");
            CallAndroidFunc(SDKData.SDKPlatCommonData.StartSDKInit);
        }
Exemple #3
0
    /// <summary>
    /// 初始化(友盟初始化) - 参数:初始化回调  注销登入回调
    /// </summary>
    public virtual void InitSDK(SDKData.InitArgModel initArgModel)
    {
        onInitComplete   = initArgModel.onComplete;
        onLogoutComplete = initArgModel.onSDKLogoutComplete;

        SDKLogManager.DebugLog("InitSDK ");
        QuickSDK.getInstance().setListener(this);

        mExitDialogCanvas = GameObject.Find("ExitDialog");
        if (mExitDialogCanvas != null)
        {
            mExitDialogCanvas.SetActive(false);
        }
    }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        InitButton           = transform.Find("InitButton").GetComponent <Button>();
        LoginButton          = transform.Find("LoginButton").GetComponent <Button>();
        PayOrderButton       = transform.Find("PayOrderButton").GetComponent <Button>();
        SaveRoleButton       = transform.Find("SaveRoleButton").GetComponent <Button>();
        SaveRoleButton2      = transform.Find("SaveRoleButton2").GetComponent <Button>();
        SaveRoleButton3      = transform.Find("SaveRoleButton3").GetComponent <Button>();
        LogoutButton         = transform.Find("LogoutButton").GetComponent <Button>();
        OnGameExitButton     = transform.Find("OnGameExitButton").GetComponent <Button>();
        SaveUMengLevelButton = transform.Find("SaveUMengLevelButton").GetComponent <Button>();
        SaveUMengCountButton = transform.Find("SaveUMengCountButton").GetComponent <Button>();
        CheckSimulatorButton = transform.Find("CheckSimulatorButton").GetComponent <Button>();

        Message = transform.Find("Message").GetComponent <Text>();

        SaveUMengLevelButton.gameObject.SetActive(false);
        SaveUMengCountButton.gameObject.SetActive(false);
        SetGameGoState(false);
        LoginButton.gameObject.SetActive(false);

        sdkmanager = AloneSdk.AloneSDKManager.instance;
        if (sdkmanager == null)
        {
            Debug.LogError("sdkmanager is null !");
            return;
        }

        InitButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在初始化sdk!", SDKLogManager.DebugType.LogWarning);
            SDKData.InitArgModel initArg = new SDKData.InitArgModel()
            {
                onComplete = (result) =>
                {
                    if (result)
                    {
                        SDKLogManager.DebugLog("初始化成功!", SDKLogManager.DebugType.LogWarning);
                        InitButton.gameObject.SetActive(false);
                        LoginButton.gameObject.SetActive(true);
                    }
                },
                onSDKLogoutComplete = (state) =>
                {
                    if (state)
                    {
                        SDKLogManager.DebugLog("注销成功!", SDKLogManager.DebugType.LogWarning);
                        LoginButton.gameObject.SetActive(true);
                        SetGameGoState(false);
                    }
                    else
                    {
                        SDKLogManager.DebugLog("注销失败!", SDKLogManager.DebugType.LogError);
                    }
                },
                onSDKMessageCallBack = (message) =>
                {
                    Message.text = message;
                },
            };

            sdkmanager.InitSDK(initArg);
        });

        LoginButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在登录!", SDKLogManager.DebugType.LogWarning);
            // SDKManager.Instance.Login((a) => { });
            sdkmanager.Login((result) =>
            {
                if (result)
                {
                    SDKLogManager.DebugLog("登入成功!开始验证:", SDKLogManager.DebugType.LogWarning);
                    if (isLoginVerification)
                    {
                        StartCoroutine(LoginVerification((userid) =>
                        {
                            SDKLogManager.DebugLog("验证成功,用户id:" + userid, SDKLogManager.DebugType.LogWarning);
                            LoginButton.gameObject.SetActive(false);
                            SetGameGoState(true);
                        }));
                    }
                    else
                    {
                        SDKLogManager.DebugLog("验证成功!", SDKLogManager.DebugType.LogWarning);
                        LoginButton.gameObject.SetActive(false);
                        SetGameGoState(true);
                    }
                }
            }, UnityEngine.Random.Range(0, 2) == 0 ? "qq" : "wx");
        });

        PayOrderButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("生成订单中~", SDKLogManager.DebugType.LogWarning);
            var payOrderData = new SDKData.PayOrderData()
            {
                orderId         = SDKData.PayOrderData.GetCurrentTimeMiss(),
                userid          = sdkmanager.SDK_Id,
                amount          = 6,
                productId       = "10001",
                productName     = "60钻石",
                productDesc     = "60钻石",
                callbackMessage = "回调给服务器时的附加消息",
                productCount    = 1,
                callbackUrl     = "http://111.231.206.145/juhe/u9Pay/payCallBack",
                roleID          = "roleiid",
                roleName        = "roleiid", //角色名字
                zoneID          = 2,         //区id
                zoneName        = "2区",      //区名字
                orderTime       = SDKData.PayOrderData.GetCurrentTimeMiss(),
                extra           = "",
                gamename        = N3DClient.GameConfig.GetClientConfig("GameName", "yyty"),
                ratio           = 10,//充值比例
            };
            payOrderData.extra = "" + payOrderData.zoneID + "|" + payOrderData.roleID + "|" + payOrderData.productId;


            Action <OrderCreateModel> orderCreateAction = (order) =>
            {
                payOrderData.amount      = order.amount;
                payOrderData.callbackUrl = order.callbackurl;
                payOrderData.orderId     = order.orderid;

                sdkmanager.PayItem(payOrderData);
            };

            if (isRequestOrderId)
            {
                StartCoroutine(CreateOrder(orderCreateAction, payOrderData));
            }
            else
            {
                orderCreateAction(new OrderCreateModel()
                {
                    amount      = (int)payOrderData.amount,
                    callbackurl = payOrderData.callbackUrl,
                    orderid     = SDKData.PayOrderData.GetCurrentTimeMiss(),
                });
            }


            // SDKManager.Instance.PayOrder(payOrderData);
        });

        Action <SDKData.UpdatePlayerInfoType> onSaveRoleInfoClick = (type) =>
        {
            SDKLogManager.DebugLog("正在保存角色信息!!", SDKLogManager.DebugType.LogWarning);
            var roleData = new SDKData.RoleData()
            {
                roleId     = "123456",
                roleLevel  = "22",
                roleName   = "测试角色",
                createTime = System.DateTime.Now.Millisecond.ToString(),
                realmId    = "1",
                realmName  = "1区测试服",
                chapter    = "1-1",
                arg        = "这是一条保存角色信息的附加信息!",
            };
            sdkmanager.UpdatePlayerInfo(roleData, type);
        };

        SaveRoleButton.onClick.AddListener(() =>
        {
            onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.createRole);
        });
        SaveRoleButton2.onClick.AddListener(() =>
        {
            onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.enterGame);
        });
        SaveRoleButton3.onClick.AddListener(() =>
        {
            onSaveRoleInfoClick(SDKData.UpdatePlayerInfoType.levelUp);
        });


        LogoutButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在登出账号!!", SDKLogManager.DebugType.LogWarning);
            //SDKManager.Instance.Logout();
            sdkmanager.Logout();
        });

        OnGameExitButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在退出sdk!!", SDKLogManager.DebugType.LogWarning);
            //SDKManager.Instance.OnGameExit(() =>
            //{
            //    Debug.LogWarning("SDK 已经退出!");
            //});
            sdkmanager.ExitGame();

#if UNITY_EDITOR
            SetGameGoState(false);
            LoginButton.gameObject.SetActive(false);
            InitButton.gameObject.SetActive(true);
#endif
        });

        SaveUMengLevelButton.onClick.AddListener(() =>
        {
            //UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestEventID);
        });

        SaveUMengCountButton.onClick.AddListener(() =>
        {
            var data = new System.Collections.Generic.Dictionary <string, string>()
            {
                { "test1", "1" },
                { "test2", "4" },
                { "test3", "8" },
                { "test4", "16" },
            };
            //UmengManager.Instance.TriggerEvent(UMengCustomEventID.TestComputingEvent, data);
        });

        CheckSimulatorButton.onClick.AddListener(() =>
        {
            CheckSimulator();
        });
    }