少年修仙传客户端代码仓库
client_Hale
2018-09-07 066f80e377408a94635d5f044c66418d0dc07f26
Core/SDK/SDKUtility.cs
@@ -16,6 +16,14 @@
        ChargingFull = 3,
    }
    public enum E_ChannelPlatform
    {
        Free,
        Mr,
    }
    public E_ChannelPlatform ChannelPlatform { get; private set; }
    /// <summary>
    /// sdk初始化是否完成标识
    /// 客户端一般需要等待这个值为true才继续逻辑
@@ -86,6 +94,8 @@
    {
        RegistrationID = string.Empty;
        AssetCopyFinished = false;
        ChannelPlatform = E_ChannelPlatform.Free;
#if !UNITY_EDITOR
        if (InitFinished)
        {
@@ -254,16 +264,16 @@
        var _code = (int)_json["code"];
        switch (_code)
        {
         case CodeA2U.DeviceInfo:
            case CodeA2U.DeviceInfo:
            Device = new DeviceInfo ();
            Device.uniqueID = _json ["unique_id"].ToString ();
            Device.androidID = _json ["android_id"].ToString ();// ios平台下为idfa
            Device.userAgent = _json ["userAgent"].ToString ();
                Device = new DeviceInfo();
                Device.uniqueID = _json["unique_id"].ToString();
                Device.androidID = _json["android_id"].ToString();// ios平台下为idfa
                Device.userAgent = _json["userAgent"].ToString();
#if UNITY_ANDROID
            Device.macAddress = _json ["mac"].ToString ();
            Device.imei = _json ["imei"].ToString ();
            Device.totalMemory = (int)_json ["memoryTotal"];
                Device.macAddress = _json["mac"].ToString();
                Device.imei = _json["imei"].ToString();
                Device.totalMemory = (int)_json["memoryTotal"];
#endif
                if (OnDeviceInfoChanged != null)
                {
@@ -294,6 +304,19 @@
                break;
            case CodeA2U.SdkInitComplete:
                InitFinished = true;
                var _dict = _json as IDictionary;
                if (_dict != null && _dict.Contains("channelPlatform"))
                {
                    var _channelPlatform = _json["channelPlatform"].ToString();
                    if (!string.IsNullOrEmpty(_channelPlatform))
                    {
                        if (_channelPlatform.Equals("mr"))
                        {
                            ChannelPlatform = E_ChannelPlatform.Mr;
                            Debug.Log("当前渠道平台为猫耳渠道");
                        }
                    }
                }
                break;
            case CodeA2U.PushClientID:
                RegistrationID = _json["clientID"].ToString();
@@ -473,6 +496,8 @@
        public const int FreePlatformSwitchAccount = 103;
        public const int FreePlatformPay = 104;
        public const int PayFinished = 105;
        public const int CreateRole = 106;
        public const int RoleLogin = 107;
        /**
         * 极光推送
         * */
@@ -543,7 +568,6 @@
    public string platfromId = "1000";
    public UnityAction<FP_CheckIDAuthentication> onFreePlatfromCheckIDOK;
    public UnityAction<FP_DoIDAuthentication> onFreePlatfromDoIDAuthenticationOk;
    public void FreePlatformInit()
    {
@@ -619,6 +643,10 @@
        m_PaymentTable["OrderTitle"] = title;
        m_PaymentTable["OrderInfo"] = cpInfo;
        m_PaymentTable["AppID"] = VersionConfig.Get().appId;
        if (ChannelPlatform == E_ChannelPlatform.Mr)
        {
            m_PaymentTable["RechargeChannel"] = "1";
        }
        var _stringBuilder = new System.Text.StringBuilder();
        var _md5Body = _stringBuilder.Append(m_PaymentTable["AppID"]).
@@ -647,6 +675,7 @@
            {
                if (result)
                {
                    Debug.Log(" ------------------ : " + message);
                    JsonData _json = JsonMapper.ToObject(message);
                    int _callbackResult = (int)_json["result"];
@@ -660,6 +689,15 @@
                        m_Json["mount"] = money;
                        m_Json["cpInfo"] = cpInfo;
                        m_Json["title"] = title;
                        m_Json["notifyurl"] = _json["notifyurl"];
                        if (ChannelPlatform == E_ChannelPlatform.Mr)
                        {
                            m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID;
                            m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;
                            m_Json["level"] = PlayerDatas.Instance.baseData.LV.ToString();
                            m_Json["sid"] = "s" + ServerListCenter.Instance.currentServer.region_flag;
                        }
#if UNITY_IOS
                        m_Json["identifier"] = VersionConfig.Get().bundleIdentifier;
#endif
@@ -750,18 +788,25 @@
        if (_iDict.Contains("token"))
        {
            FreePlatformInfo.token = json["token"].ToString();
            Debug.Log("token: " + FreePlatformInfo.token);
        }
        if (_iDict.Contains("token_expire"))
        {
            FreePlatformInfo.tokenExpire = json["token_expire"].ToString();
        }
        else
        {
            FreePlatformInfo.tokenExpire = "";
        }
        if (_iDict.Contains("account"))
        {
            FreePlatformInfo.account = json["account"].ToString();
            Debug.Log("account: " + FreePlatformInfo.account);
        }
        if (_iDict.Contains("account_id"))
        {
            int.TryParse(json["account_id"].ToString(), out FreePlatformInfo.accountID);
            Debug.Log("account_id: " + FreePlatformInfo.accountID);
        }
        FreePlatformInfo.phone = 0;
@@ -799,6 +844,29 @@
        m_Json["money"] = (float)coin / 100;
        SendMessageToSDK(m_Json);
    }
    public void CreateRoleOk(string roleID, string roleName)
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.CreateRole;
        m_Json["roleID"] = roleID;
        m_Json["roleName"] = roleName;
        m_Json["sid"] = "s" + ServerListCenter.Instance.currentServer.region_flag;
        SendMessageToSDK(m_Json);
    }
    public void RoleLogin(string roleID, string roleName, string lv, string vipLV)
    {
        m_Json.Clear();
        m_Json["code"] = CodeU2A.RoleLogin;
        m_Json["roleID"] = roleID;
        m_Json["roleName"] = roleName;
        m_Json["sid"] = "s" + ServerListCenter.Instance.currentServer.region_flag;
        m_Json["level"] = lv;
        m_Json["vipLevel"] = vipLV;
        SendMessageToSDK(m_Json);
    }
    #endregion
    #region 极光推送相关