예제 #1
0
    public override void PayResultCallBack(string arg)
    {
        base.PayResultCallBack(arg);
        Debug.Log("------------PayResult=" + arg);

        string str = "";

        SFJSONObject sfjson = new SFJSONObject(arg);
        string       type   = (string)sfjson.get("result");
        string       data   = (string)sfjson.get("data");

        if (APaymentHelper.PayResult.PAY_SUCCESS == type)
        {
            str = "pay result = pay success " + data;
        }
        else if (APaymentHelper.PayResult.PAY_FAILURE == type)
        {
            str = "pay result = pay failure" + data;
        }
        else if (APaymentHelper.PayResult.PAY_ORDER_NO == type)
        {
            str = "pay result = pay order No" + data;
        }

        SDKLogManager.DebugLog(str);
    }
예제 #2
0
 //显示登录平台的方法
 public virtual void Login(Action <bool> onComplete, string arg = null)
 {
     this.RefreshLoginData();
     onLoginComplete = onComplete;
     SDKLogManager.DebugLog("Login");
     CallAndroidFunc(SDKData.SDKPlatCommonData.StartSDKLogin, arg);
 }
예제 #3
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);
    }
예제 #4
0
    //显示登录平台的方法
    public void Login(Action onComplete)
    {
        //重置数据
        RefreshLoginData();
#if UNITY_ANDROID
        #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK
        //监听回调

        YaoLingSDKCallBackManager.Instance.onSDKLoginComplete = (evtData) =>
        {
            if (evtData == null)
            {
                SDKLogManager.DebugLog("登陆失败 !", SDKLogManager.DebugType.LogError);
            }
            else
            {
                SDKLogManager.DebugLog("登陆回调参数如下:token:" + evtData.token + "username:"******"登陆失败 !", SDKLogManager.DebugType.LogError);
            }
            else
            {
                SDKLogManager.DebugLog("登陆回调参数如下:token:" + evtData.token + "username:"******"default_token",
            userName = "******",
            userId   = "default_userid",
        });
#endif
    }
예제 #5
0
        public virtual string PayItem(SDKData.PayOrderData orderData)
        {
            SDKLogManager.DebugLog("PayItem");
#if UNITY_EDITOR
#elif UNITY_ANDROID
#elif UNITY_PHONE
#endif
            return(null);
        }
예제 #6
0
 public override string PayItem(SDKData.PayOrderData orderData)
 {
     using (AndroidJavaObject curActivity = CallAndroidFuncGetResult <AndroidJavaObject>("GetGameMainActivity"))
     {
         SDKLogManager.DebugLog("pay");
         pay(curActivity.GetRawObject(), gameObject.name, (int)(orderData.amount * 100), orderData.productName, 1, orderData.extra, orderData.callbackUrl, "PayResultCallBack");
         return(null);
     }
 }
예제 #7
0
    public void IOSLogoutCallBack(string arg)
    {
        SDKLogManager.DebugLog("unity: 收到账号注销结果:" + arg);
        bool result = arg == "SUCCESS";

        if (onSDKLogoutComplete != null)
        {
            onSDKLogoutComplete(result);
        }
    }
예제 #8
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);
        }
예제 #9
0
    public override void LoginCallBack(string arg)
    {
        base.LoginCallBack(arg);
        //TODO 登入验证
        Debug.Log("------------loginResult=" + arg);
        string str = "";

        SFJSONObject sfjson = new SFJSONObject(arg);

        string type         = (string)sfjson.get("result");
        string customParams = (string)sfjson.get("customParams");

        if (APaymentHelper.LoginResult.LOGOUT == type)
        {
            str = "login result = logout" + customParams;
            if (onLogoutComplete != null)
            {
                onLogoutComplete(true);
            }
        }
        else if (APaymentHelper.LoginResult.LOGIN_SUCCESS == type)
        {
            SFJSONObject userinfo = (SFJSONObject)sfjson.get("userinfo");
            string       oldchanneluserid;
            currentSDKParmer.TryGetValue("channeluserid", out oldchanneluserid);
            if (userinfo != null && (string)userinfo.get("channeluserid") != oldchanneluserid)
            {
                //long id = long.Parse((string)userinfo.get("id"));
                //string channelId = (string)userinfo.get("channelid");
                //string ChannelUserId = (string)userinfo.get("channeluserid");
                //string UserName = (string)userinfo.get("username");
                //string Token = (string)userinfo.get("token");
                //string ProductCode = (string)userinfo.get("productcode");
                currentSDKParmer["id"]            = (string)userinfo.get("id");            //易接内部 userid,该值可能为 0,请不要以此参数作为判定。
                currentSDKParmer["channelid"]     = (string)userinfo.get("channelid");     //易接平台标示的渠道 SDK ID,
                currentSDKParmer["channeluserid"] = (string)userinfo.get("channeluserid"); //渠道 SDK 标示的用户 ID。
                currentSDKParmer["username"]      = (string)userinfo.get("username");      //渠道 SDK 的用户名称。
                currentSDKParmer["token"]         = (string)userinfo.get("token");         //渠道 SDK 登录完成后的 Session ID。特别提醒:部分渠道此参数会包含特殊值如‘+’,空格之类的,如直接使用 URL 参数传输到游戏服务器请求校验,请使用 URLEncoder 编码
                currentSDKParmer["productcode"]   = (string)userinfo.get("productcode");   //易接平台创建的游戏 ID,appId

                onLoginComplete(true);                                                     //标志登入成功
                str = "login result = login success" + customParams;
            }
            else
            {
                str = "login result = sdk login success , but game loginfailed ~~~~~" + currentSDKParmer["channeluserid"];
            }
        }
        else if (APaymentHelper.LoginResult.LOGIN_FAILED == type)
        {
            str = "login result = login failed" + customParams;
        }

        SDKLogManager.DebugLog(str);
    }
예제 #10
0
    public override void Login(Action <bool> onComplete, string arg = null)
    {
        this.RefreshLoginData();
        onLoginComplete = onComplete;
        SDKLogManager.DebugLog("Login");

        using (AndroidJavaObject curActivity = CallAndroidFuncGetResult <AndroidJavaObject>("GetGameMainActivity"))
        {
            login(curActivity.GetRawObject(), "Login");
        }
    }
예제 #11
0
 /// <summary>
 /// 支付回调  1 成功  0 取消或失败
 /// </summary>
 /// <param name="arg"></param>
 public void IOSPayResultCallBack(string arg)
 {
     SDKLogManager.DebugLog("支付回调参数:" + arg);
     if (string.IsNullOrEmpty(arg))
     {
         onSDKPayComplete(false);
         onSDKPayComplete = null;
     }
     else
     {
         onSDKPayComplete(arg.Equals("1"));
     }
 }
예제 #12
0
    public void ExitGame()
    {
#if UNITY_ANDROID
        YaoLingSDKCallBackManager.Instance.CallAndroidFunc(YaoLingSDKCallBackManager.YaoLinAndroidSDKNameType.ExitGame);
#elif UNITY_IOS
        Debug.LogWarning("sdk 没有退出游戏的方法!!!直接退出");
        Application.Quit();
#endif

#if UNITY_EDITOR
        SDKLogManager.DebugLog("game over", SDKLogManager.DebugType.LogWarning);
#endif
    }
예제 #13
0
 public void LoginCallBack(string arg)
 {
     SDKLogManager.DebugLog("登入回调参数:" + arg);
     if (string.IsNullOrEmpty(arg))
     {
         onSDKLoginComplete(null);
         onSDKLoginComplete = null;
     }
     else
     {
         onSDKLoginComplete(LitJson.JsonMapper.ToObject <YX116UserInfoModel>(arg));
     }
 }
예제 #14
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);
        }
    }
예제 #15
0
        public void CallAndroidFunc(string funcName, params object[] args)
        {
            try
            {
                SDKLogManager.DebugLog("CallAndroidFunc:" + funcName);

#if UNITY_ANDROID && !UNITY_EDITOR
                AndJC.CallStatic(funcName, args);
#endif
            }
            catch (System.Exception e)
            {
                SDKLogManager.DebugLog(e.Message, SDKLogManager.DebugType.LogError);
            }
        }
예제 #16
0
        public T CallAndroidFuncGetResult <T>(string funcName, params object[] args)
        {
            try
            {
                SDKLogManager.DebugLog("CallAndroidFuncGetResult:" + funcName);

#if UNITY_ANDROID && !UNITY_EDITOR
                return(AndJC.CallStatic <T>(funcName, args));
#endif
            }
            catch (System.Exception e)
            {
                SDKLogManager.DebugLog(e.Message, SDKLogManager.DebugType.LogError);
            }
            return(default(T));
        }
예제 #17
0
 public void IOSLoginCallBack(string arg)
 {
     SDKLogManager.DebugLog("登入回调参数:" + arg);
     if (string.IsNullOrEmpty(arg))
     {
         onSDKLoginComplete(null);
         onSDKLoginComplete = null;
     }
     else
     {
         int index = arg.IndexOf("|", 0);
         YX116UserInfoModel model = new YX116UserInfoModel()
         {
             userName = arg.Substring(0, index),
             token    = arg.Substring(index + 1),
         };
         onSDKLoginComplete(model);
     }
 }
예제 #18
0
    /// <summary>
    /// 初始化(包含友盟初始化) - 参数:成功回调  注销登入回调
    /// </summary>
    public void InitSDK(Action onComplete, Action <bool> onSDKLogoutComplete)
    {
        gameObject.name = "TypeSDK";
        ChannelName     = N3DClient.GameConfig.GetClientConfig("DitchID", "dev");
        YaoLingSDKCallBackManager.Instance.onSDKLogoutComplete = onSDKLogoutComplete;

#if UNITY_ANDROID
        #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK
        if (onComplete != null)
        {
            onComplete();
        }
        #endregion
#elif UNITY_IOS
        SDKIOSFunction.sdkmanagerinit();
        if (onComplete != null)
        {
            onComplete();
        }
#endif
        SDKLogManager.DebugLog("sdk 初始化成功!!!!当前得到的渠道id为:" + ChannelName, SDKLogManager.DebugType.LogWarning);
    }
예제 #19
0
 /// <summary>
 /// 获取是否有sdk游戏退出框
 /// </summary>
 public virtual bool onGetChannelHasExitDialog()
 {
     SDKLogManager.DebugLog("onGetChannelHasExitDialog");
     return(true);
 }
예제 #20
0
 /// <summary>
 /// 退出游戏
 /// </summary>
 public virtual void ExitGame()
 {
     SDKLogManager.DebugLog("ExitGame");
     CallAndroidFunc(SDKData.SDKPlatCommonData.StartExitGame);
 }
예제 #21
0
 /// <summary>
 /// 上传玩家信息到sdk服务器  参数1:玩家参数 参数2:上传时机
 /// </summary>
 public virtual void UpdatePlayerInfo(SDKData.RoleData roleData, SDKData.UpdatePlayerInfoType updateType)
 {
     SDKLogManager.DebugLog("Begin UpdatePlayerInfo");
 }
예제 #22
0
 //登出平台
 public virtual void Logout()
 {
     SDKLogManager.DebugLog("Logout");
     CallAndroidFunc(SDKData.SDKPlatCommonData.StartSDKLogout);
 }
예제 #23
0
 private void Awake()
 {
     instance = this;
     var logConsole = gameObject.AddComponent <Consolation.TestConsole>();
 }
예제 #24
0
 public virtual void DebugErrorCallBack(string arg)
 {
     SDKLogManager.DebugLog("javaMessage:" + arg, SDKLogManager.DebugType.LogError);
 }
예제 #25
0
        //************************************************************以下是需要实现的回调接口*************************************************************************************************************************
        //callback

        #region 共有回调
        public virtual void DebugLogCallBack(string arg)
        {
            SDKLogManager.DebugLog("javaMessage:" + arg);
        }
예제 #26
0
파일: SDKDemo.cs 프로젝트: qb-lxl/SDKDemo
    /// <summary>
    /// 登录验证
    /// </summary>
    private IEnumerator LoginVerification(Action <string> onComplete)
    {
        string sdkType = N3DClient.GameConfig.GetClientConfig("mSdkTag");//sdk类型

        string url = ServerListURL + sdkType + "loginVerification.php";

        SDKLogManager.DebugLog("登录验证url:" + url);
        Dictionary <string, string> postData = new Dictionary <string, string>();
        //TODO  登录验证参数

        string platform = "win";

#if UNITY_ANDROID
        platform = "android";
#elif UNITY_IOS
        platform = "ios";
#endif
        var sdkInstance = AloneSdk.AloneSDKManager.instance;
        postData.Add("platform", platform);                                        //平台
        postData.Add("userid", sdkInstance.GetSDKParamer("userId"));               //渠道
        postData.Add("token", sdkInstance.GetSDKParamer("token"));
        postData.Add("checkloginurl", sdkInstance.GetSDKParamer("checkloginurl")); //登录验证url

        postData.Add("channeltype", sdkInstance.GetSDKParamer("channeltype"));     //渠道类型
        postData.Add("channelcode", sdkInstance.GetSDKParamer("channelcode"));     //渠道代码

        WWWForm form = null;
        WWW     www  = null;
        if (postData != null)
        {
            form = new WWWForm();
            foreach (var item in postData)
            {
                form.AddField(item.Key, item.Value);
            }
        }
        www = new WWW(url, form);

        yield return(www);

        try
        {
            if (string.IsNullOrEmpty(www.error))
            {
                string content = System.Text.Encoding.UTF8.GetString(www.bytes);
                if (!string.IsNullOrEmpty(content))
                {
                    SDKLogManager.DebugLog("玩家验证结果:" + content);
                    var result = LitJson.JsonMapper.ToObject <LoginVerificationData>(content);
                    if (result.code == 0)
                    {
                        SDKLogManager.DebugLog("玩家验证成功!" + result.data);
                        onComplete(result.data);
                    }
                    else
                    {
                        SDKLogManager.DebugLog("玩家验证失败!" + content, SDKLogManager.DebugType.LogError);
                    }
                }
            }
        }
        catch (Exception e)
        {
            SDKLogManager.DebugLog("玩家验证报错!" + e.Message, SDKLogManager.DebugType.LogError);
        }
    }
예제 #27
0
 private void OnDestroy()
 {
     instance = null;
 }
예제 #28
0
파일: SDKDemo.cs 프로젝트: qb-lxl/SDKDemo
    /// <summary>
    /// 请求服务器生成订单
    /// </summary>
    private IEnumerator CreateOrder(Action <OrderCreateModel> onComplete, SDKData.PayOrderData payData)
    {
        string sdkType = N3DClient.GameConfig.GetClientConfig("mSdkTag");//sdk类型

        string url = ServerListURL + sdkType + "orderCreate.php";

        SDKLogManager.DebugLog("支付验证url:" + url);
        Dictionary <string, string> postData = new Dictionary <string, string>();
        //TODO  登录验证参数

        string platform = "win";

#if UNITY_ANDROID
        platform = "android";
#elif UNITY_IOS
        platform = "ios";
#endif
        var sdkInstance = AloneSdk.AloneSDKManager.instance;
        postData.Add("platform", platform);                                    //平台
        postData.Add("userid", sdkInstance.GetSDKParamer("userId"));           //渠道
        postData.Add("roleid", payData.roleID);
        postData.Add("productid", payData.productId);                          //商品号
        postData.Add("zoneid", payData.zoneID.ToString());                     //区id
        postData.Add("money", payData.amount.ToString());                      //区id

        postData.Add("channeltype", sdkInstance.GetSDKParamer("channeltype")); //渠道类型
        postData.Add("channelcode", sdkInstance.GetSDKParamer("channelcode")); //渠道代码

        WWWForm form = null;
        WWW     www  = null;
        if (postData != null)
        {
            form = new WWWForm();
            foreach (var item in postData)
            {
                form.AddField(item.Key, item.Value);
            }
        }
        www = new WWW(url, form);

        yield return(www);

        try
        {
            if (string.IsNullOrEmpty(www.error))
            {
                string content = System.Text.Encoding.UTF8.GetString(www.bytes);
                if (!string.IsNullOrEmpty(content))
                {
                    SDKLogManager.DebugLog("订单生成返回结果:" + content);
                    var result = LitJson.JsonMapper.ToObject <OrderCreateModel>(content);
                    if (result.code == 0)
                    {
                        SDKLogManager.DebugLog("订单生成成功!" + result.orderid + "  amount:" + result.amount);
                        onComplete(result);
                    }
                    else
                    {
                        SDKLogManager.DebugLog("订单生成失败!" + content, SDKLogManager.DebugType.LogError);
                    }
                }
            }
        }
        catch (Exception e)
        {
            SDKLogManager.DebugLog("玩家订单生成报错!" + e.Message, SDKLogManager.DebugType.LogError);
        }
    }
예제 #29
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>();
        LogoutButton         = transform.Find("LogoutButton").GetComponent <Button>();
        OnGameExitButton     = transform.Find("OnGameExitButton").GetComponent <Button>();
        SaveUMengLevelButton = transform.Find("SaveUMengLevelButton").GetComponent <Button>();
        SaveUMengCountButton = transform.Find("SaveUMengCountButton").GetComponent <Button>();

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

        InitButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在初始化sdk!", SDKLogManager.DebugType.LogWarning);

            //SDKManager.Instance.Init();
            U3DTypeSDK.Instance.InitSDK(() =>
            {
                SDKLogManager.DebugLog("初始化成功!", SDKLogManager.DebugType.LogWarning);
                InitButton.gameObject.SetActive(false);
                LoginButton.gameObject.SetActive(true);
            }, (state) =>
            {
                if (state)
                {
                    SDKLogManager.DebugLog("注销成功!", SDKLogManager.DebugType.LogWarning);
                    LoginButton.gameObject.SetActive(true);
                    SetGameGoState(false);
                }
                else
                {
                    SDKLogManager.DebugLog("注销失败!", SDKLogManager.DebugType.LogError);
                }
            });
        });

        LoginButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在登录!", SDKLogManager.DebugType.LogWarning);
            // SDKManager.Instance.Login((a) => { });
            U3DTypeSDK.Instance.Login(() =>
            {
                SDKLogManager.DebugLog("登入成功!", SDKLogManager.DebugType.LogWarning);
                LoginButton.gameObject.SetActive(false);
                SetGameGoState(true);
            });
        });

        PayOrderButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在支付订单!!", SDKLogManager.DebugType.LogWarning);
            var payOrderData = new SDKData.PayOrderData()
            {
                orderId         = SDKData.PayOrderData.GetCurrentTimeMiss(),
                userid          = U3DTypeSDK.Instance.Game_UserId,
                amount          = 6,
                productId       = "10001",
                productName     = "钻石",
                productDesc     = "钻石",
                callbackMessage = "回调给服务器时的附加消息",
                productCount    = 1,
                callbackUrl     = "http://112.345.678.1/payresult.php",
                roleID          = "roleiid",
                roleName        = "roleiid", //角色名字
                zoneID          = 1,         //区id
                zoneName        = "1区",      //区名字
                orderTime       = SDKData.PayOrderData.GetCurrentTimeMiss(),
                extra           = "附加参数不得为空",
                gamename        = N3DClient.GameConfig.GetClientConfig("GameName", "yyty"),
            };
            U3DTypeSDK.Instance.PayItem(payOrderData);
            // SDKManager.Instance.PayOrder(payOrderData);
        });

        SaveRoleButton.onClick.AddListener(() =>
        {
            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.Instance.SavePlayerInfo(roleData);
            U3DTypeSDK.Instance.UpdatePlayerInfo(roleData, SDKData.UpdatePlayerInfoType.levelUp);
        });

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

        OnGameExitButton.onClick.AddListener(() =>
        {
            SDKLogManager.DebugLog("正在退出sdk!!", SDKLogManager.DebugType.LogWarning);
            //SDKManager.Instance.OnGameExit(() =>
            //{
            //    Debug.LogWarning("SDK 已经退出!");
            //});
            U3DTypeSDK.Instance.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);
        });
    }
예제 #30
0
파일: SDKDemo.cs 프로젝트: qb-lxl/SDKDemo
    // 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();
        });
    }