Beispiel #1
0
    void LoginResult(U3DTypeEvent evt)
    {
        Debug.Log("LoginResult");

        U3DTypeBaseData data = evt.evtData;


        //string userName = data.GetData(U3DTypeAttName.USER_NAME);
        string userID    = data.GetData(U3DTypeAttName.USER_ID);
        string userToken = data.GetData(U3DTypeAttName.USER_TOKEN);

//		Dictionary<string,string> dataArr = new Dictionary<string,string> ();

        U3DTypeBaseData platform = U3DTypeSDK.Instance.GetPlatformData();

        U3DTypeBaseData baseData = new U3DTypeBaseData();

        baseData.SetData("id", userID);
        baseData.SetData("token", userToken);
        baseData.SetData("data", "");
        baseData.SetData("cid", platform.GetData(U3DTypeAttName.CHANNEL_ID));
//		baseData.SetData ("sign", userID + "|" + userToken + "|" + ""+"|"+platform.GetData(U3DTypeAttName.CHANNEL_ID));

//		string dataArr = changeBaseDataToHttpData (baseData);
//		Debug.Log ("login sent to server data " + dataArr);

        DataProxy.Ins.ServerLogic.RequestLogin(this, baseData, ServerCBK_login, null);
        //send user info to server and exchange playerinfo;
    }
Beispiel #2
0
        /// <summary>
        /// 初始化(包含友盟初始化) - 参数:成功回调
        /// </summary>
        public void InitSDK(Action onComplete)
        {
            gameObject.name = "TypeSDK";

#if YaoLing
            #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK
            Channelid   = ((int)U3DTypeSDKPlatName.YaoLing).ToString();
            Cpid        = "yaolingcpid";
            ChannelName = U3DTypeSDKPlatName.YaoLing.ToString();
            Debug.LogWarning("初始化成功!!!!当前得到的渠道id为:" + Channelid);
            //初始化友盟sdk
            UmengManager.Instance.Init(ChannelName);
            onComplete();
            #endregion
#else
            //监听回调
            U3DTypeEventListener.Instance.onSDKInitComplete = (evtData) =>
            {
                foreach (var v in evtData.attMap())
                {
                    Debug.LogWarning("初始化得到参数:key:" + v.Key + "Value:" + v.Value);
                }

                U3DTypeBaseData platformData = U3DTypeSDK.Instance.GetPlatformData();
                Channelid = platformData.GetData(U3DTypeAttName.CHANNEL_ID);
                Cpid      = platformData.GetData(U3DTypeAttName.CP_ID);
                try
                {
                    ChannelName = ((U3DTypeSDKPlatName)int.Parse(Channelid)).ToString();
                }
                catch (Exception e)
                {
                    Debug.LogError("平台参数获取错误:" + e.Message);
                    ChannelName = platformData.GetData("channelName");
                    if (string.IsNullOrEmpty(ChannelName))
                    {
                        ChannelName = Channelid;
                    }
                }



                // Cpid = evtData.GetData("cp_id");//游戏代码
                //Channelid = evtData.GetData("channelid");//渠道代码
                Debug.LogWarning("初始化成功!!!!当前得到的游戏id为:" + Cpid + "        |渠道id为:" + Channelid);
                //初始化友盟sdk
                UmengManager.Instance.Init(ChannelName);
                onComplete();
            };

            U3DTypeEventListener.Instance.InitSelf();
            Instance.selfInit();
#endif
        }
    void ServerCBK_createOrder(string data, UnityEngine.Object crossData)
    {
        U3DTypeBaseData result = new U3DTypeBaseData();

        result.StringToData(data);
        if (null != result && "" != result.GetData("oid"))
        {
            localPayData.SetData(U3DTypeAttName.BILL_NUMBER, result.GetData("oid"));
        }

        messageStr = data;

        //pay bill
        this.ActionPayCurrentOrder();
    }
Beispiel #4
0
    void ActionCreatePayOrder(string _in_item_id, string _in_item_price)
    {
        U3DTypeBaseData data = DataProxy.Ins.LocalLogic.userInfo();

//		string userName = data.GetData(U3DTypeAttName.USER_NAME);
        string userID = data.GetData(U3DTypeAttName.USER_ID);
//		string userToken = data.GetData(U3DTypeAttName.USER_TOKEN);


        U3DTypeBaseData platform = DataProxy.Ins.LocalLogic.platform();
        U3DTypeBaseData baseData = new U3DTypeBaseData();

        baseData.SetData("uid", userID);
        baseData.SetData("pid", _in_item_id);
        baseData.SetData("sid", "1");
        baseData.SetData("cid", platform.GetData(U3DTypeAttName.CHANNEL_ID));
//		baseData.freshSign();

//		string dataArr = changeBaseDataToHttpData (baseData);

        localPayData.SetData(U3DTypeAttName.USER_ID, userID);
        localPayData.SetData(U3DTypeAttName.ITEM_SERVER_ID, _in_item_id);
        localPayData.SetData(U3DTypeAttName.REAL_PRICE, _in_item_price);

        Debug.Log("local pay data change to " + localPayData.DataToString());
        Debug.Log("login sent to server data " + baseData.DataToString());
        DataProxy.Ins.ServerLogic.RequestCreateOrder(this, baseData, ServerCBK_createOrder, null);
    }
Beispiel #5
0
        void LoginResult(U3DTypeEvent evt)
        {
            Debug.Log("LoginResult");

            U3DTypeBaseData data   = evt.evtData;
            string          userID = data.GetData(U3DTypeAttName.USER_ID);

            user_token = data.GetData(U3DTypeAttName.USER_TOKEN);

            var platdata  = U3DTypeSDK.Instance.GetPlatformData();
            var channelid = platdata.GetData(U3DTypeAttName.CHANNEL_ID);
            var cpid      = platdata.GetData(U3DTypeAttName.CP_ID);

            var tokens = user_token.Split('|');

            if (tokens.Length > 2)
            {
                Logger.Error("tokens split error!!! token=" + user_token);
                return;
            }

            //增加了注册类型
            tokenforPay = tokens[0].Trim();
            var loginType = tokens[1].Trim();
            //更换分隔符|为@_@,腾讯的userID中含有|
            var uid = string.Format("{0}@_@{1}@_@{2}", cpid, channelid, userID);

            LoginLogic.instance.StartCoroutine(LoginLogic.LoginByThirdCoroutine("typeSDK", GameSetting.Channel, uid, tokenforPay));

            //账号或者游客登陆 = 0
            //账号注册 = 1
            //游客注册 = 2
            if (loginType == "1" || loginType == "2")
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                JsonWriter writer            = new JsonWriter(sb);

                writer.WriteObjectStart();
                writer.WritePropertyName("type");
                writer.Write("onRegister");
                writer.WritePropertyName("playerId");
                writer.Write(userID);
                writer.WriteObjectEnd();

                PlatformHelper.OnRegister(sb.ToString());
            }
        }
    void LoginResult(U3DTypeEvent evt)
    {
        Debug.Log("LoginResult");

        U3DTypeBaseData data      = evt.evtData;
        string          userID    = data.GetData(U3DTypeAttName.USER_ID);
        string          userToken = data.GetData(U3DTypeAttName.USER_TOKEN);

        U3DTypeBaseData platform = U3DTypeSDK.Instance.GetPlatformData();

        U3DTypeBaseData baseData = new U3DTypeBaseData();

        baseData.SetData("id", userID);
        baseData.SetData("token", userToken);
        baseData.SetData("data", "");
        baseData.SetData("cid", platform.GetData(U3DTypeAttName.CHANNEL_ID));

        DataProxy.Ins.ServerLogic.RequestLogin(this, baseData, ServerCBK_login, null);
    }
    //
    /////server logic///////
    /// ;
    void ServerCBK_login(string data, UnityEngine.Object crossData)
    {
        U3DTypeBaseData result = new U3DTypeBaseData();

        result.StringToData(data);
        if (null == result.attMap())
        {
            Debug.Log("error string to data in server cbk login");
        }
        if (null != result && "" != result.GetData("uid"))
        {
            U3DTypeBaseData userinfo = U3DTypeSDK.Instance.GetUserData();
            userinfo.SetData(U3DTypeAttName.USER_ID, result.GetData("uid"));
            userinfo.SetData(U3DTypeAttName.USER_TOKEN, result.GetData("token"));

            ActionGetAccount();
        }
        current_ui_model = UI_MENU;         // go to menu
        messageStr       = data;
    }
    void Extrafunction(U3DTypeEvent evt)
    {
        Debug.Log("unityr receive 额外函数" + evt.evtData.DataToString());
        TypeSDKTool.AlartMessage.ShowMessage("额外函数", evt.evtData.DataToString());
        U3DTypeBaseData evtData  = evt.evtData;
        string          func_key = evtData.GetData(U3DTypeAttName.EXTERN_FUNCTION_KEY);
        string          data_1   = evtData.GetData(U3DTypeAttName.EXTERN_FUNCTION_VALUE);

        //		string data_2 = evtData.GetData (U3DTypeAttName.EXTERN_FUNCTION_VALUE_2);
        switch (func_key)
        {
        case "http_get":
        {
            this.StartCoroutine(DataProxy.Ins.ServerLogic.HttpGet(data_1, ServerCBK_CommonShowMSG, null));
        }
        break;

        case "http_post":
        {
            DataProxy.Ins.ServerLogic.HttpPost(data_1, new Dictionary <string, object>(), ServerCBK_CommonShowMSG, null);
            break;
        }
        }
    }
    void AcitonCreatAccount()
    {
        U3DTypeBaseData userInfo = DataProxy.Ins.LocalLogic.userInfo();
        string          userID   = userInfo.GetData(U3DTypeAttName.USER_ID);
        U3DTypeBaseData platform = DataProxy.Ins.LocalLogic.platform();
        U3DTypeBaseData baseData = new U3DTypeBaseData();

        baseData.SetData("uid", userID);
        baseData.SetData("sid", "1");
        baseData.SetData("cid", platform.GetData(U3DTypeAttName.CHANNEL_ID));
        //        baseData.freshSign();

        //		string dataArr = changeBaseDataToHttpData (baseData);
        DataProxy.Ins.ServerLogic.RequestCreateAccount(this, baseData, ServerCBK_createAccount, null);
    }
Beispiel #10
0
    void ActionPayCurrentOrder()
    {
//		if (0 != datalock_pay_progress)
//		{
//			Debug.Log("wait pay finish");en

//			return;
//		}
        U3DTypeBaseData userInfo = U3DTypeSDK.Instance.GetUserData();
        U3DTypeBaseData payData  = localPayData;

        //用户ID,渠道返回,没有填空

        //商品支付价格(单位:分)

        //商品名称
        payData.SetData(U3DTypeAttName.ITEM_NAME, "TwinkleItem");
        //商品数量
        payData.SetData(U3DTypeAttName.ITEM_COUNT, "1");
        //所在服务器id(如果没有填“0”)

        //所在服务器名字(如果没有填“sever_name”)
        payData.SetData(U3DTypeAttName.SERVER_NAME, "安卓一区");
        //所在服务器数字标记(如果没有填“1”)
        payData.SetData(U3DTypeAttName.SERVER_ID, "1");
        //内部订单号(如果没有填“0”)
        //商品在渠道上的id(如果没有填“0”)如果大于0 认为是购买商品
        //has setted by function:ActionCreate ActionCreatePayOrder

        //商品描述
        payData.SetData(U3DTypeAttName.ITEM_DESC, "desc");
        //玩家在游戏中的角色ID
        payData.SetData(U3DTypeAttName.ROLE_ID, "role_1234");
        //玩家在游戏中的角色名字
        payData.SetData(U3DTypeAttName.ROLE_NAME, "玩家编号001");
        //传递的额外参数(建议传入需要用来做订单标识的信息)
        payData.SetData(U3DTypeAttName.EXTRA, "extra");

        payData.SetData(U3DTypeAttName.USER_ID, userInfo.GetData(U3DTypeAttName.USER_ID));
        U3DTypeSDK.Instance.PayItem(payData);

//		datalock_pay_progress = 1;
    }
Beispiel #11
0
        //显示登录平台的方法
        public void Login(Action onComplete)
        {
            //重置数据
            RefreshLoginData();


#if YaoLing
            #region 2018年8月17日14:18:09 qiubin添加 曜灵 116 聚合 SDK
            //监听回调
            Debug.LogWarning("调用曜灵116sdk 登入!");
            YaoLingSDKCallBackManager.Instance.onSDKLoginComplete = (evtData) =>
            {
                if (evtData == null)
                {
                    Debug.LogWarning("登陆失败!");
                    //HSGameEngine.GameFramework.Logic.Super.ShowMessageBox(HSGameEngine.GameFramework.Logic.Super.MainWindowRoot, 0, HSGameEngine.GameEngine.Logic.Global.GetLang("提示"), HSGameEngine.GameEngine.Logic.Global.GetLang("登录失败!"));
                }
                else
                {
                    Debug.LogWarning("登陆回调参数如下:token:" + evtData.token + "username:"******"登陆回调参数如下:");
                foreach (var v in evtData.attMap())
                {
                    Debug.LogWarning(v.Key + "  " + v.Value);
                }
                //Token = evtData.GetData("user_token");
                //Debug.LogWarning("登录成功!收到登录回调token:" + Token);
                if (Token == null)
                {
                    U3DTypeBaseData userData = U3DTypeSDK.Instance.GetUserData();
                    UserId = userData.GetData(U3DTypeAttName.USER_ID);
                    Token  = userData.GetData(U3DTypeAttName.USER_TOKEN);

                    Debug.LogWarning("重新获取到的token为:" + Token + "serid为:" + UserId);
                    if (Token == null)
                    {
                        Token = evtData.GetData("user_token");
                        Debug.LogWarning("登录成功!收到登录回调token:" + Token);
                    }
                }
                //判空处理(保证数据不为null,服务器不会解析出错)
                if (Token == null)
                {
                    Token = "";
                }
                if (UserId == null)
                {
                    UserId = "";
                }

                onComplete();
            };

            //if has not self init return and wait receive update event
            if (!selfInit())
            {
                Debug.Log("has not self init");
                return;
            }
            Debug.Log("do login ");
            bonjour.ShowLogin();
#endif
        }
    void ServerCBK_getAccount(string data, UnityEngine.Object crossData)
    {
        Debug.Log("ServerCBK_getAccount is :" + data);
        U3DTypeBaseData result = new U3DTypeBaseData();

        result.StringToData(data);
        if (null != result)
        {
            Debug.Log("null != result :");
            if (0 != result.GetInt("code"))
            {
                Debug.Log("AcitonCreatAccount:");
                AcitonCreatAccount();
            }
            else
            {
                Debug.Log("localUserData is ///////:" + U3DTypeSDK.Instance.GetUserData().DataToString());
                if (null == localUserData)
                {
                    localUserData = U3DTypeSDK.Instance.GetUserData();
                }
                localUserData.SetData(U3DTypeAttName.USER_ID, result.GetData("uid"));
                localUserData.SetData(U3DTypeAttName.USER_TOKEN, result.GetData("token"));

                //以下内容请开发者如实填写实际内容,demo仅供参考
                //如果没有该内容,请填"0"
                localUserData.SetData(U3DTypeAttName.ROLE_TYPE, "createRole");
                localUserData.SetData(U3DTypeAttName.SAVED_BALANCE, "0");
                localUserData.SetData(U3DTypeAttName.USER_NAME, "qudaoyonghu_001");
                localUserData.SetData(U3DTypeAttName.USER_HEAD_ID, "head_001");
                localUserData.SetData(U3DTypeAttName.USER_HEAD_URL, "head_url_001");
                localUserData.SetData(U3DTypeAttName.VIP_LEVEL, "v10");
                localUserData.SetData(U3DTypeAttName.PARTY_NAME, "gonghui");
                localUserData.SetData(U3DTypeAttName.ROLE_ID, "role_001");
                localUserData.SetData(U3DTypeAttName.ROLE_NAME, "role_name_001");
                localUserData.SetData(U3DTypeAttName.ROLE_LEVEL, "99");
                localUserData.SetData(U3DTypeAttName.ROLE_CREATE_TIME, "1234567890");
                localUserData.SetData(U3DTypeAttName.ROLE_LEVELUP_TIME, "2345678901");
                localUserData.SetData(U3DTypeAttName.ZONE_ID, "zone_1");
                localUserData.SetData(U3DTypeAttName.SERVER_ID, "1");
                localUserData.SetData(U3DTypeAttName.SERVER_NAME, "server_name");
                localUserData.SetData(U3DTypeAttName.EXTRA, "1");
                //end
                U3DTypeSDK.Instance.UpdatePlayerInfo();
                Debug.Log("UpdatePlayerInfo is ///////:" + U3DTypeSDK.Instance.GetUserData().DataToString());

                localUserData.attMap()["data"] = result.attMap()["data"];

                int tempBalance = getUserBalance();
                if (userBalance != tempBalance)
                {
                    StopRepeatRequestIntoAccount();
                    userBalance = tempBalance;
                }
                messageStr = "id " + result.GetData("uid") + "update余额 " + userBalance;

                //				U3DTypeSDK.Instance.GetUserData() ;
                //				U3DTypeSDK.Instance.UpdatePlayerInfo();

                Debug.Log("U3DTypeSDK.Instance.GetUserData() is :" + U3DTypeSDK.Instance.GetUserData().DataToString());
            }
        }
    }