using UnityEngine;  
 | 
using LitJson;  
 | 
using UnityEngine.Events;  
 | 
using System.Collections;  
 | 
using System.Collections.Generic;  
 | 
using System.IO;  
 | 
using System;  
 | 
using UnityEngine.Android;  
 | 
using vnxbqy.UI;  
 | 
using StartAotSDK;  
 | 
  
 | 
public class ynmbxxjUtil : SingletonMonobehaviour<ynmbxxjUtil>  
 | 
{  
 | 
    public enum E_ChargingType  
 | 
    {  
 | 
        NoCharging = 1,  
 | 
        Charging = 2,  
 | 
        ChargingFull = 3,  
 | 
    }  
 | 
  
 | 
    public enum E_ChannelPlatform  
 | 
    {  
 | 
        Free = 1,// 自由  
 | 
        Mr = 2,// 猫耳  
 | 
        Sp = 3,// 思璞  
 | 
        Js = 4,// 极速  
 | 
        Yj = 5,// 易接  
 | 
        Yl = 6,// 易乐  
 | 
        Xn = 7,// 小牛  
 | 
        Cjm = 8,// 超级梦  
 | 
        Ky = 9,//恺英  
 | 
        Quick = 10, //quick  
 | 
        SanXia = 11, //三峡(港台使用)  
 | 
        SanXiaiOS = 12, //三峡 (港台ios使用)  
 | 
        Hy = 15, //欢游  
 | 
        hygt = 16, //欢游港台  
 | 
        mlgt = 17, //咪噜港台  
 | 
        newyn = 19, //新的越南(欢游0.1)  
 | 
        en = 20, //英文版  
 | 
    }  
 | 
  
 | 
    //权限申请回调  
 | 
    private Action<string, int> onPermissionCallBack;  
 | 
  
 | 
    public event Action<int, JsonData> onSdkMsg;  
 | 
  
 | 
    //bug1 :玩家在A地图充值过程中,切换到B地图,在B地图未登录成功 充值到账,因玩家不存在或者未登录成功导致充值延迟到账,此时玩家可能做了二次充值操作;    
 | 
    //用此标记在有操作行为后的下一次切换地图成功 再主动请求一次兑换充值  
 | 
    public bool RechargeHasDone = false;  
 | 
  
 | 
    public E_ChannelPlatform ChannelPlatform { get; set; }  
 | 
  
 | 
    public static string Yj_AppID  
 | 
    {  
 | 
        get; private set;  
 | 
    }  
 | 
  
 | 
    public static string ThirdPartVersion  
 | 
    {  
 | 
        get; private set;  
 | 
    }  
 | 
  
 | 
    public static string Yj_SpID  
 | 
    {  
 | 
        get; private set;  
 | 
    }  
 | 
  
 | 
    public static string ThirdPartAppID  
 | 
    {  
 | 
        get; private set;  
 | 
    }  
 | 
  
 | 
    public static string Yj_BanHao  
 | 
    {  
 | 
        get; private set;  
 | 
    }  
 | 
  
 | 
    // 是否同意隐私政策  
 | 
    public bool IsAgreeSecret = false;  
 | 
  
 | 
    /// <summary>  
 | 
    /// sdk初始化是否完成标识  
 | 
    /// 客户端一般需要等待这个值为true才继续逻辑  
 | 
    /// </summary>  
 | 
    public bool InitFinished { get; private set; }  
 | 
  
 | 
    #region 基础定义与回调  
 | 
  
 | 
    /// <summary>  
 | 
    /// 当前设备电量值  
 | 
    /// </summary>  
 | 
    public int BatteryLevel { get; private set; }  
 | 
    /// <summary>  
 | 
    /// 设备电量值改变回调  
 | 
    /// </summary>  
 | 
    public UnityAction<int> OnBatteryLevelChanged;  
 | 
  
 | 
    /// <summary>  
 | 
    /// 当前充电状态  
 | 
    /// </summary>  
 | 
    public E_ChargingType ChargingType { get; private set; }  
 | 
    /// <summary>  
 | 
    /// 当前充电状态改变回调  
 | 
    /// </summary>  
 | 
    public UnityAction<E_ChargingType> OnChargingTypeChanged;  
 | 
  
 | 
    /// <summary>  
 | 
    /// 设备信息  
 | 
    /// </summary>  
 | 
    public DeviceInfo Device { get; private set; }  
 | 
    /// <summary>  
 | 
    /// 设备信息改变回调  
 | 
    /// </summary>  
 | 
    public UnityAction<DeviceInfo> OnDeviceInfoChanged;  
 | 
  
 | 
    /// <summary>  
 | 
    /// 当前网络状态  
 | 
    /// </summary>  
 | 
    public NetworkReachability NetworkType { get; private set; }  
 | 
    /// <summary>  
 | 
    /// 当前网络状态改变回调  
 | 
    /// </summary>  
 | 
    public UnityAction<NetworkReachability> OnNetworkStatusChanged;  
 | 
  
 | 
    public static bool builtinAssetCopyFinished { get; private set; }  
 | 
  
 | 
    /// <summary>  
 | 
    /// 是否已经将StreamingAsset拷贝至目标路径  
 | 
    /// </summary>  
 | 
    public bool AssetCopyFinished { get; private set; }  
 | 
  
 | 
    /// <summary>  
 | 
    /// 安卓设备根目录  
 | 
    /// </summary>  
 | 
    public string DeviceRootPath { get; private set; }  
 | 
  
 | 
    #endregion  
 | 
  
 | 
    #region 极光推送  
 | 
    public string RegistrationID { get; private set; }  
 | 
    #endregion  
 | 
  
 | 
    #region 自由sdk  
 | 
    public FP_LoginOk FreePlatformInfo { get; private set; }  
 | 
    #endregion  
 | 
  
 | 
    private JsonData m_Json = new JsonData();  
 | 
  
 | 
    public void Init()  
 | 
    {  
 | 
        Device = new DeviceInfo();  
 | 
        string uid = LocalSave.GetString("Device_uniqueID");  
 | 
        //Debug.Log(Math.Abs(System.Environment.TickCount));  
 | 
        if (uid.Length <= 5)  
 | 
        {  
 | 
            long tick = Math.Abs(System.Environment.TickCount);  
 | 
            uid = tick.ToString() + UnityEngine.Random.Range(1, 100000000).ToString();  
 | 
            LocalSave.SetString("Device_uniqueID", uid);  
 | 
        }  
 | 
        Device.uniqueID = uid;  
 | 
  
 | 
        Debug.Log(Device.uniqueID);  
 | 
  
 | 
        Yj_AppID = string.Empty;  
 | 
        Yj_SpID = string.Empty;  
 | 
        ThirdPartVersion = string.Empty;  
 | 
        RegistrationID = string.Empty;  
 | 
        AssetCopyFinished = false;  
 | 
        ChannelPlatform = E_ChannelPlatform.Free;  
 | 
        NetworkType = NetworkReachability.NotReachable;  
 | 
        BatteryLevel = 100;  
 | 
  
 | 
#if !UNITY_EDITOR  
 | 
        if (InitFinished)  
 | 
        {  
 | 
            return;  
 | 
        }  
 | 
#if UNITY_ANDROID  
 | 
        var builtinAssetsCopyFinishVersion = LocalSave.GetString("BuiltInAssetCopyCompleted_Android");  
 | 
        if (string.IsNullOrEmpty(builtinAssetsCopyFinishVersion))  
 | 
        {  
 | 
            builtinAssetCopyFinished = false;  
 | 
        }  
 | 
        else  
 | 
        {  
 | 
            builtinAssetCopyFinished = VersionConfig.Get().version == builtinAssetsCopyFinishVersion;  
 | 
        }  
 | 
#endif  
 | 
#if UNITY_IOS || UNITY_STANDALONE  
 | 
        var builtinAssetsCopyFinishVersion = LocalSave.GetString("BuiltInAssetCopyCompleted_IOSorStandalone");  
 | 
        if (string.IsNullOrEmpty(builtinAssetsCopyFinishVersion))  
 | 
        {  
 | 
            builtinAssetCopyFinished = false;  
 | 
        }  
 | 
        else  
 | 
        {  
 | 
            builtinAssetCopyFinished = VersionConfig.Get().version == builtinAssetsCopyFinishVersion;  
 | 
        }  
 | 
  
 | 
        var assetsCopyFinishVersion = LocalSave.GetString("AssetCopyCompleted_IOSorStandalone");  
 | 
        if (string.IsNullOrEmpty(assetsCopyFinishVersion))  
 | 
        {  
 | 
            AssetCopyFinished = false;  
 | 
        }  
 | 
        else  
 | 
        {  
 | 
            AssetCopyFinished = VersionConfig.Get().version == assetsCopyFinishVersion;  
 | 
        }  
 | 
  
 | 
#elif UNITY_ANDROID  
 | 
        SyncClientPackageID();  
 | 
#endif  
 | 
  
 | 
        InitFinished = false;  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.Init;  
 | 
        m_Json["appID"] = VersionConfig.Get().appId;  
 | 
        m_Json["gameID"] = VersionConfig.Get().gameId;  
 | 
        SendMessageToSDK(m_Json);  
 | 
#endif  
 | 
        StartCoroutine("ProcessNetworkStatus");  
 | 
    }  
 | 
  
 | 
    private void OnApplicationFocus(bool focus)  
 | 
    {  
 | 
#if !UNITY_EDITOR  
 | 
        m_Json.Clear();  
 | 
        if (focus)  
 | 
        {  
 | 
            m_Json["code"] = CodeU2A.BatteryListenStart;  
 | 
            StopCoroutine("ProcessNetworkStatus");  
 | 
            StartCoroutine("ProcessNetworkStatus");  
 | 
        }  
 | 
        else  
 | 
        {  
 | 
            m_Json["code"] = CodeU2A.BatteryListenStop;  
 | 
            StopCoroutine("ProcessNetworkStatus");  
 | 
        }  
 | 
        SendMessageToSDK(m_Json);  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    private IEnumerator ProcessNetworkStatus()  
 | 
    {  
 | 
        while (true)  
 | 
        {  
 | 
            if (Application.internetReachability != NetworkType)  
 | 
            {  
 | 
                NetworkType = Application.internetReachability;  
 | 
  
 | 
                if (OnNetworkStatusChanged != null)  
 | 
                {  
 | 
                    OnNetworkStatusChanged(NetworkType);  
 | 
                }  
 | 
            }  
 | 
            yield return WaitingForSecondConst.WaitMS1000;  
 | 
        }  
 | 
    }  
 | 
  
 | 
    #region 业务层定义相关逻辑  
 | 
  
 | 
    public void InstallAPK(string path)  
 | 
    {  
 | 
        if (Application.platform == RuntimePlatform.Android)  
 | 
        {  
 | 
            var dllPath1 = ResourcesPath.Instance.ExternalStorePath + "Assembly-CSharp-firstpass.dll";  
 | 
            if (File.Exists(dllPath1))  
 | 
            {  
 | 
                File.Delete(dllPath1);  
 | 
            }  
 | 
  
 | 
            var dllPath2 = ResourcesPath.Instance.ExternalStorePath + "Assembly-CSharp.dll";  
 | 
            if (File.Exists(dllPath2))  
 | 
            {  
 | 
                File.Delete(dllPath2);  
 | 
            }  
 | 
        }  
 | 
  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.InstallAPK;  
 | 
        m_Json["path"] = path;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    //0 :拷贝所有资源 1:拷贝Config  
 | 
    public void CopyAsset(int copyType = 0)  
 | 
    {  
 | 
        if (AssetCopyFinished)  
 | 
        {  
 | 
            return;  
 | 
        }  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.CopyAsset;  
 | 
        m_Json["copyType"] = copyType;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void CopyOneAsset(string relationPath)  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.CopyOneAsset;  
 | 
        m_Json["fileName"] = relationPath;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void CopyContent(string content)  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.CopyContent;  
 | 
        m_Json["content"] = content;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void RestartApp()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.RestartApp;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void OpenUrl(string url)  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.OpenWebView;  
 | 
        m_Json["url"] = url;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void MakeKeyAndVisible()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.MakeKeyAndVisible;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void SyncClientPackageID()  
 | 
    {  
 | 
#if UNITY_ANDROID  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.ClientPackage;  
 | 
        m_Json["clientPkgID"] = VersionConfig.Get().clientPackageFlag;  
 | 
        SendMessageToSDK(m_Json);  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    //申请Android 权限  
 | 
    public void RequestAndroidPermission(string permission, Action<string, int> callBack)  
 | 
    {  
 | 
        onPermissionCallBack += callBack;  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.RequestPermission;  
 | 
        m_Json["permission"] = permission;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    //申请Android 权限 启动时  
 | 
    public void RequestAndroidPermissionStart()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.RequestPermissionStart;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
  
 | 
    //跳转应用商店  
 | 
    public void GoToAppStore(string url, string marketPkg = "")  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.GoToAppStore;  
 | 
        m_Json["marketPkg"] = marketPkg;  
 | 
        m_Json["url"] = url;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    #endregion  
 | 
  
 | 
    #region 处理与SDK交互的底层方法  
 | 
  
 | 
    public static AndroidJavaObject GetApplicationContext()  
 | 
    {  
 | 
        using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))  
 | 
        {  
 | 
            using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))  
 | 
            {  
 | 
                return jo.Call<AndroidJavaObject>("getApplicationContext");  
 | 
            }  
 | 
        }  
 | 
    }  
 | 
  
 | 
    public string GetSplicePackageID()  
 | 
    {  
 | 
        var _result = "default";  
 | 
        switch (Application.platform)  
 | 
        {  
 | 
            case RuntimePlatform.Android:  
 | 
                if (ChannelPlatform == E_ChannelPlatform.Sp)  
 | 
                {  
 | 
                    using (AndroidJavaClass _jc = new AndroidJavaClass("com.sp.sdk.utils.SDKManagerUtils"))  
 | 
                    {  
 | 
                        using (AndroidJavaObject _jo = _jc.CallStatic<AndroidJavaObject>("getAssetPropConfig", GetApplicationContext(), "plugin_config.properties"))  
 | 
                        {  
 | 
                            _result = _jo.Call<string>("get", "game_id");  
 | 
                        }  
 | 
                    }  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.Mr)  
 | 
                {  
 | 
                    using (AndroidJavaClass _jc = new AndroidJavaClass("com.secondworld.univeralsdk.UniversalUtil"))  
 | 
                    {  
 | 
                        _result = _jc.CallStatic<string>("getMetaString", "Mr_GAME_ID");  
 | 
                    }  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.Js)  
 | 
                {  
 | 
                    using (AndroidJavaClass _jc = new AndroidJavaClass("com.secondworld.univeralsdk.UniversalUtil"))  
 | 
                    {  
 | 
                        _result = _jc.CallStatic<string>("getMetaString", "LL_APPID");  
 | 
                    }  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.Free)  
 | 
                {  
 | 
                    _result = "freeplatform";  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.Yl)  
 | 
                {  
 | 
                    _result = "yileplatform";  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.Ky)  
 | 
                {  
 | 
                    _result = "kyplatform";  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.hygt)  
 | 
                {  
 | 
                    _result = "hygt";  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.newyn)  
 | 
                {  
 | 
                    _result = "vn";  
 | 
                }  
 | 
                else if (ChannelPlatform == E_ChannelPlatform.en)  
 | 
                {  
 | 
                    _result = "en";  
 | 
                }  
 | 
                break;  
 | 
            case RuntimePlatform.IPhonePlayer:  
 | 
                _result = "ios";//ios平台固定返回ios  
 | 
                break;  
 | 
        }  
 | 
  
 | 
        return _result;  
 | 
    }  
 | 
  
 | 
    private void SendMessageToSDK(JsonData json)  
 | 
    {  
 | 
  
 | 
#if !UNITY_EDITOR  
 | 
#if UNITY_ANDROID  
 | 
        using (AndroidJavaClass H2engineSDK = new AndroidJavaClass("com.secondworld.sdk.UnityMsgHandler"))  
 | 
        {  
 | 
            H2engineSDK.CallStatic("onUnityMessage", json.ToJson());  
 | 
        }  
 | 
#elif UNITY_IOS  
 | 
        AotSdkUtility.IOSUniyMessageHandle(json.ToJson());  
 | 
#elif UNITY_STANDALONE  
 | 
        InitFinished=true;  
 | 
#endif  
 | 
          
 | 
#endif  
 | 
  
 | 
    }  
 | 
  
 | 
    public void HandleMsgWithSDK(string jsonString)  
 | 
    {  
 | 
        Debug.Log("收到SDK发来的信息: " + jsonString);  
 | 
        var _json = JsonMapper.ToObject(jsonString);  
 | 
        var _code = (int)_json["code"];  
 | 
        switch (_code)  
 | 
        {  
 | 
            case CodeA2U.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();  
 | 
                if (_json["imei"] != null)  
 | 
                {  
 | 
                    Device.imei = _json["imei"].ToString();  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    Device.imei = Device.uniqueID;  
 | 
                }  
 | 
                Device.totalMemory = (int)_json["memoryTotal"];  
 | 
#endif  
 | 
                if (OnDeviceInfoChanged != null)  
 | 
                {  
 | 
                    OnDeviceInfoChanged(Device);  
 | 
                }  
 | 
  
 | 
                break;  
 | 
            case CodeA2U.AssetCopyFinished:  
 | 
                AssetCopyFinished = true;  
 | 
                break;  
 | 
            case CodeA2U.BatteryLevel:  
 | 
  
 | 
                BatteryLevel = (int)_json["level"];  
 | 
                if (OnBatteryLevelChanged != null)  
 | 
                {  
 | 
                    OnBatteryLevelChanged(BatteryLevel);  
 | 
                }  
 | 
  
 | 
                break;  
 | 
            case CodeA2U.BatteryCharging:  
 | 
  
 | 
                ChargingType = (E_ChargingType)((int)_json["status"]);  
 | 
                if (OnChargingTypeChanged != null)  
 | 
                {  
 | 
                    OnChargingTypeChanged(ChargingType);  
 | 
                }  
 | 
  
 | 
                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("hygame"))  
 | 
                        {  
 | 
                            ChannelPlatform = E_ChannelPlatform.Hy;  
 | 
                        }  
 | 
                        else if (_channelPlatform.Equals("quick"))  
 | 
                        {  
 | 
                            ChannelPlatform = E_ChannelPlatform.Quick;  
 | 
                        }  
 | 
                        else if (_channelPlatform.Equals("hyyn"))  
 | 
                        {  
 | 
                            ChannelPlatform = E_ChannelPlatform.newyn;  
 | 
                        }  
 | 
                        else if (_channelPlatform.Equals("hygtgame"))  
 | 
                        {  
 | 
                            ChannelPlatform = E_ChannelPlatform.hygt;  
 | 
                        }  
 | 
                        else if (_channelPlatform.Equals("hyenglish"))  
 | 
                        {  
 | 
                            ChannelPlatform = E_ChannelPlatform.en;  
 | 
                        }  
 | 
                    }  
 | 
                }  
 | 
  
 | 
                //Sdk 可能会修改渠道信息,所以需要重新获取  
 | 
                if (_dict.Contains("yj_appid"))  
 | 
                {  
 | 
                    Yj_AppID = _json["yj_appid"].ToString();  
 | 
                }  
 | 
  
 | 
                if (_dict.Contains("yj_spid"))  
 | 
                {  
 | 
                    Yj_SpID = _json["yj_spid"].ToString();  
 | 
                }  
 | 
  
 | 
                if (_dict.Contains("banhao"))  
 | 
                {  
 | 
                    Yj_BanHao = _json["banhao"].ToString();  
 | 
                }  
 | 
  
 | 
                break;  
 | 
            case CodeA2U.PushClientID:  
 | 
                RegistrationID = _json["clientID"].ToString();  
 | 
                break;  
 | 
            case CodeA2U.ExternalStorage:  
 | 
                DeviceRootPath = _json["path"].ToString();  
 | 
                break;  
 | 
            case CodeA2U.PermissionCallBack:  
 | 
                {  
 | 
                    var state = (int)_json["state"];  
 | 
                    var permission = (string)_json["permission"];  
 | 
                    onPermissionCallBack?.Invoke(permission, state);  
 | 
                    onPermissionCallBack = null;  
 | 
                    break;  
 | 
                }  
 | 
            case CodeA2U.FreePlatformInitOk:  
 | 
  
 | 
                if (onFreePlatformInitOk != null)  
 | 
                {  
 | 
                    onFreePlatformInitOk();  
 | 
                }  
 | 
  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformInitFail:  
 | 
                if (onFreePlatformInitFail != null)  
 | 
                {  
 | 
                    onFreePlatformInitFail();  
 | 
                }  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformRegisterOk:  
 | 
                // HandleFreePlatformRegisteOk(_json);  
 | 
                OperationLogCollect.Instance.RecordEvent(5);  
 | 
                var values = new JsonData();  
 | 
                if (_json.Keys.Contains("reg_type"))  
 | 
                    values["af_registration_method"] = _json["reg_type"];  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformLoginOk:  
 | 
                HandleFreePlatformLoginOk(_json["info"]);  
 | 
                OperationLogCollect.Instance.RecordEvent(6);  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformLoginFail:  
 | 
                if (onFreePlatformLoginFail != null)  
 | 
                {  
 | 
                    onFreePlatformLoginFail();  
 | 
                }  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformLogoutOk:  
 | 
                if (onFreePlatformLogoutOk != null)  
 | 
                {  
 | 
                    onFreePlatformLogoutOk();  
 | 
                }  
 | 
                FreePlatformInfo = null;  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformSwitchAccountOk:  
 | 
                BuildFreePlatformInfo(_json["info"]);  
 | 
                if (onFreePlatformLogoutOk != null)  
 | 
                {  
 | 
                    onFreePlatformLogoutOk();  
 | 
                }  
 | 
                FreePlatformInfo = null;  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformLogoutFail:  
 | 
                if (onFreePlatformLogoutFail != null)  
 | 
                {  
 | 
                    onFreePlatformLogoutFail();  
 | 
                }  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformPayOk:  
 | 
                if (onFreePlatformPayOk != null)  
 | 
                {  
 | 
                    onFreePlatformPayOk();  
 | 
                }  
 | 
                SnxxzGame.Instance.StartCoroutine(DelayQueryRecharge());  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformPayFail:  
 | 
                if (onFreePlatformPayFail != null)  
 | 
                {  
 | 
                    onFreePlatformPayFail();  
 | 
                }  
 | 
                break;  
 | 
            case CodeA2U.FreePlatformPayCancel:  
 | 
                if (onFreePlatformPayCancel != null)  
 | 
                {  
 | 
                    onFreePlatformPayCancel();  
 | 
                }  
 | 
                break;  
 | 
            case CodeA2U.ShareCallBack:  
 | 
                {  
 | 
                    var state = int.Parse(_json["state"].ToString());  
 | 
                    if (state == CallBackState.Success)  
 | 
                        LocalSave.SetInt("ShareToFBDay" + PlayerDatas.Instance.baseData.PlayerID, TimeUtility.ServerNow.DayOfYear);  
 | 
  
 | 
                    onShareFBResult?.Invoke();  
 | 
                    break;  
 | 
                }  
 | 
            case CodeA2U.ExitGame:  
 | 
                if (ChannelPlatform == E_ChannelPlatform.Free)  
 | 
                {  
 | 
                    vnxbqy.UI.WindowCenter.Instance.Open<vnxbqy.UI.ExitGameWin>();  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    //默认都是退出游戏  
 | 
                    Application.Quit();  
 | 
                }  
 | 
                break;  
 | 
        }  
 | 
        onSdkMsg?.Invoke(_code, _json);  
 | 
    }  
 | 
  
 | 
    #endregion  
 | 
  
 | 
    #region 交互相关约定编号  
 | 
  
 | 
    //回调的相关状态  
 | 
    public static class CallBackState  
 | 
    {  
 | 
        public const int Cancel = 0;  
 | 
        public const int Success = 1;  
 | 
        public const int Error = 2;  
 | 
    }  
 | 
  
 | 
    public static class CodeA2U  
 | 
    {  
 | 
        #region 基础sdk_code  
 | 
        /**  
 | 
         * 资源拷贝完成  
 | 
         */  
 | 
        public const int AssetCopyFinished = 0;  
 | 
        /**  
 | 
         * 电量改变  
 | 
         */  
 | 
        public const int BatteryLevel = 1;  
 | 
        /**  
 | 
         * 充电状态改变  
 | 
         */  
 | 
        public const int BatteryCharging = 2;  
 | 
        /**  
 | 
         * 回调sdk逻辑完毕  
 | 
         * */  
 | 
        public const int SdkInitComplete = 3;  
 | 
        /**  
 | 
         * 回调android设备信息  
 | 
         * */  
 | 
        public const int DeviceInfo = 4;  
 | 
        /**  
 | 
         * 回调推送的独立id  
 | 
         * */  
 | 
        public const int PushClientID = 5;  
 | 
        /**  
 | 
         * 回调外部存储根目录地址  
 | 
         */  
 | 
        public const int ExternalStorage = 6;  
 | 
        /**  
 | 
         * 触发了退出游戏逻辑, 打开二次确认界面  
 | 
         */  
 | 
        public const int ExitGame = 7;  
 | 
  
 | 
        /**  
 | 
        * 权限申请结果  
 | 
        */  
 | 
        public const int PermissionCallBack = 8;  
 | 
  
 | 
        #endregion  
 | 
  
 | 
        #region 自由sdk_code  
 | 
        public const int FreePlatformInitOk = 100;  
 | 
        public const int FreePlatformInitFail = 101;  
 | 
        public const int FreePlatformLoginOk = 102;  
 | 
        public const int FreePlatformLoginFail = 103;  
 | 
        public const int FreePlatformLoginCancel = 104;  
 | 
        public const int FreePlatformLogoutOk = 105;  
 | 
        public const int FreePlatformLogoutFail = 106;  
 | 
        public const int FreePlatformSwitchAccountOk = 107;  
 | 
        public const int FreePlatformPayOk = 108;  
 | 
        public const int FreePlatformPayFail = 109;  
 | 
        public const int FreePlatformPayCancel = 110;  
 | 
        public const int FreePlatformRegisterOk = 111;  
 | 
        public const int ShareCallBack = 112;  
 | 
        public const int PingfenCallBack = 113;  //评分回调 和 GotoShopOK 不一样 具体看使用区分  
 | 
        public const int GotoShopOK = 115;  //前往商店成功  
 | 
        public const int GotoFBOK = 116;  
 | 
        #endregion  
 | 
    }  
 | 
  
 | 
    private static class CodeU2A  
 | 
    {  
 | 
        /**  
 | 
         * 执行资源拷贝  
 | 
         */  
 | 
        public const int CopyAsset = 0;  
 | 
        /**  
 | 
         * 执行开始电量改变,充电状态改变监听  
 | 
         */  
 | 
        public const int BatteryListenStart = 1;  
 | 
        /**  
 | 
         * 执行停止电量改变,充电状态改变监听  
 | 
         */  
 | 
        public const int BatteryListenStop = 2;  
 | 
        /**  
 | 
         * 获取唯一识别码  
 | 
         */  
 | 
        public const int UniqueID = 3;  
 | 
        /**  
 | 
         * 申请在AndroidManifest文件中  
 | 
         */  
 | 
        public const int RequestManifestPermissions = 4;  
 | 
        /**  
 | 
         * 单独动态申请某一个权限  
 | 
         */  
 | 
        public const int RequestPermission = 5;  
 | 
        /**  
 | 
         * 重启应用  
 | 
         */  
 | 
        public const int RestartApp = 6;  
 | 
        /**  
 | 
         * 拷贝文本信息  
 | 
         */  
 | 
        public const int CopyContent = 7;  
 | 
        /**  
 | 
         * 打开网址  
 | 
         */  
 | 
        public const int OpenWebView = 8;  
 | 
        /**  
 | 
         * SDK初始化, 完全自动初始化的流程, 完成必要逻辑后再回调回去  
 | 
         */  
 | 
        public const int Init = 9;  
 | 
        /**  
 | 
         * 安装应用  
 | 
         */  
 | 
        public const int InstallAPK = 10;  
 | 
        /**  
 | 
         * 外部存储根目录地址  
 | 
         */  
 | 
        public const int ExteneralStorage = 11;  
 | 
        public const int CopyOneAsset = 12;  
 | 
  
 | 
        //打开应用商店  
 | 
        public const int GoToAppStore = 13;  
 | 
  
 | 
        // 启动时申请权限,申请规则sdk决定  
 | 
        public const int RequestPermissionStart = 14;  
 | 
  
 | 
        /**  
 | 
         * 自由sdk相关  
 | 
         * */  
 | 
        public const int FreePlatformInit = 100;  
 | 
        public const int FreePlatformLogin = 101;  
 | 
        public const int FreePlatformLogout = 102;  
 | 
        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;  
 | 
        public const int RoleLevelUp = 108;  
 | 
        public const int TencentLogin = 109;  
 | 
        public const int DownloadStart = 110;  
 | 
        public const int DownloadEnd = 111;  
 | 
        public const int ShareToFaceBook = 112;  
 | 
        public const int GoToPingfen = 113;  //前往评分  和 GotoShop = 121; 有区别  
 | 
        public const int ShowAccountView = 114;  
 | 
        public const int RoleLoginOut = 119; //角色登出  
 | 
        public const int FansHouse = 120; //粉丝屋 论坛等  
 | 
        public const int GotoShop = 121; //前往商店  
 | 
        public const int TrackEvent = 122; //自定义事件  
 | 
        /**  
 | 
         * 极光推送  
 | 
         * */  
 | 
        public const int JPushAddLocalMessage = 200;  
 | 
        public const int JPushRemoveLocalMessage = 201;  
 | 
        /**  
 | 
         * IOS特殊需求  
 | 
         */  
 | 
        public const int MakeKeyAndVisible = 300;  
 | 
        /**  
 | 
         * ClientPackage向sdk发送分包id  
 | 
         */  
 | 
        public const int ClientPackage = 400;  
 | 
        /**  
 | 
         * 发送注册事件  
 | 
         */  
 | 
        public static int SendRegistEvent = 500;  
 | 
        /**  
 | 
         * 发送注册事件  
 | 
         */  
 | 
        public static int SendLoginEvent = 600;  
 | 
        /**  
 | 
         * 隐藏悬浮窗  
 | 
         */  
 | 
        public static int HideFloatIcon = 700;  
 | 
        /**  
 | 
         * 显示悬浮窗  
 | 
         */  
 | 
        public static int ShowFloatIcon = 701;  
 | 
  
 | 
  
 | 
    }  
 | 
  
 | 
    #endregion  
 | 
    public class DeviceInfo  
 | 
    {  
 | 
        public string imei;  
 | 
        public string macAddress;  
 | 
        public string androidID;  
 | 
        public string uniqueID;  
 | 
        public string userAgent;  
 | 
        public int totalMemory;  
 | 
    }  
 | 
  
 | 
    #region 自由sdk相关  
 | 
  
 | 
    public UnityAction onFreePlatformInitOk;  
 | 
    public UnityAction onFreePlatformInitFail;  
 | 
    public UnityAction<FP_LoginOk> onFreePlatformLoginOk;  
 | 
    public UnityAction onFreePlatformLoginFail;  
 | 
    public UnityAction onFreePlatformLogoutOk;  
 | 
    public UnityAction onFreePlatformLogoutFail;  
 | 
    public UnityAction onFreePlatformPayOk;  
 | 
    public UnityAction onFreePlatformPayFail;  
 | 
    public UnityAction onFreePlatformPayCancel;  
 | 
    public UnityAction onFreePlatformBindOk;  
 | 
    public UnityAction onFreePlatformBindFail;  
 | 
    public UnityAction onShareFBResult;  
 | 
    public class FP_LoginOk  
 | 
    {  
 | 
        public string account;//必选,账号  
 | 
        public string token;//必选  
 | 
        public string tokenExpire;  
 | 
        public int phone;  
 | 
        public int accountID;  
 | 
        public string gameId;  
 | 
        public string timeStamp;  
 | 
        public string sessionID;  
 | 
        public string yjAppId;  
 | 
        public string yjSdkId;  
 | 
        public string qkUserName; // 目前当做原始UID使用,因为游戏中会统一小写  
 | 
    }  
 | 
  
 | 
    public struct FP_CheckIDAuthentication  
 | 
    {  
 | 
        public string errorcode;  
 | 
        public string errordesc;  
 | 
        public string type;  
 | 
        public string card_id;  
 | 
    }  
 | 
  
 | 
    public struct FP_DoIDAuthentication  
 | 
    {  
 | 
        public string errorcode;  
 | 
        public string errordesc;  
 | 
        public string card_id;  
 | 
    }  
 | 
  
 | 
    string authenticationCardId = "";  
 | 
    public string channelId = "1000";  
 | 
    public string platfromId = "1000";  
 | 
  
 | 
    public void FreePlatformInit()  
 | 
    {  
 | 
#if !UNITY_EDITOR  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.FreePlatformInit;  
 | 
        SendMessageToSDK(m_Json);  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    public void FreePlatformBindPhone()  
 | 
    {  
 | 
#if UNITY_ANDROID  
 | 
        AndroidJavaClass _jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");  
 | 
        AndroidJavaObject _jo = _jc.GetStatic<AndroidJavaObject>("currentActivity");  
 | 
        _jo.Call("BindPhone");  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    /// <summary>  
 | 
    /// 自由SDK登陆  
 | 
    /// </summary>  
 | 
    public void FreePlatformLogin()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.FreePlatformLogin;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void TencentLogin(string param)  
 | 
    {  
 | 
#if !UNITY_EDITOR  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.TencentLogin;  
 | 
        if (!string.IsNullOrEmpty(param))  
 | 
        {  
 | 
            m_Json["param"] = param;  
 | 
        }  
 | 
        SendMessageToSDK(m_Json);  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    /// <summary>  
 | 
    /// 自由SDK登出  
 | 
    /// </summary>  
 | 
    public void FreePlatformLoginout()  
 | 
    {  
 | 
#if !UNITY_EDITOR  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.FreePlatformLogout;  
 | 
        SendMessageToSDK(m_Json);  
 | 
        if (ChannelPlatform == E_ChannelPlatform.Yl)  
 | 
        {  
 | 
            FreePlatformLogin();  
 | 
        }  
 | 
#endif  
 | 
    }  
 | 
    public void ShowAccountView()  
 | 
    {  
 | 
#if !UNITY_EDITOR  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.ShowAccountView;  
 | 
        SendMessageToSDK(m_Json);  
 | 
        if (ChannelPlatform == E_ChannelPlatform.Yl)  
 | 
        {  
 | 
            FreePlatformLogin();  
 | 
        }  
 | 
#endif  
 | 
    }  
 | 
    public void FreePlatformSwitchAccount()  
 | 
    {  
 | 
#if UNITY_ANDROID  
 | 
        AndroidJavaClass _jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");  
 | 
        AndroidJavaObject _jo = _jc.GetStatic<AndroidJavaObject>("currentActivity");  
 | 
        _jo.Call("SwitchAccount");  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    private Dictionary<string, string> m_PaymentTable = new Dictionary<string, string>();  
 | 
    private string m_EncodeKey = "03sujm7gerywdvyd5vkkk772rs4by230";  
 | 
  
 | 
    private IEnumerator DelayQueryRecharge()  
 | 
    {  
 | 
        yield return WaitingForSecondConst.WaitMS10000;  
 | 
        var _package = new CA806_tagCMQueryRecharge();  
 | 
        GameNetSystem.Instance.SendInfo(_package);  
 | 
    }  
 | 
  
 | 
    /// <summary>  
 | 
    /// 自由SDK支付 fixed sdk 支付逻辑修改  
 | 
    /// </summary>  
 | 
    ///   
 | 
    public void FreePlatformPay(string title, float money, string cpInfo)  
 | 
    {  
 | 
        // 提示是否使用代金券  
 | 
        var gameCash = PlayerDatas.Instance.baseData.ExAttr11;  
 | 
  
 | 
        bool isBuyGameCash = false; //代金券本身的充值不能用代金券购买 造成循环  
 | 
        int ctgID = ModelCenter.Instance.GetModel<VipModel>().orderInfoToCTGID[cpInfo];  
 | 
        if (ctgID != 0)  
 | 
        {  
 | 
            isBuyGameCash = CTGConfig.Get(ctgID).PayType == 17;  
 | 
        }  
 | 
  
 | 
        if (!isBuyGameCash && gameCash < money && money < 5000)  
 | 
        {  
 | 
            // 代金券不足,切无法内购(低于0.23不能登记),并且不是国内quick版本  
 | 
            //WindowCenter.Instance.Open<VipRechargeWin>(false, 2);  
 | 
            WindowJumpMgr.Instance.WindowJumpToEx("VipRechargeWin", 1, 0, 2);  
 | 
            WindowCenter.Instance.Close<GotoChargeWin>();  
 | 
            return;  
 | 
        }  
 | 
  
 | 
        if (!isBuyGameCash && gameCash >= money)  
 | 
        {  
 | 
  
 | 
            WindowCenter.Instance.Close<GotoChargeWin>();  
 | 
            if (DayRemind.Instance.GetDayRemind(DayRemind.DJQTip))  
 | 
            {  
 | 
                var pack = new CA125_tagCMCoinBuyOrderInfo();  
 | 
                pack.AppID = VersionConfig.Get().appId;  
 | 
                pack.AppIDLen = (byte)pack.AppID.Length;  
 | 
                pack.OrderInfo = cpInfo;  
 | 
                pack.OrderInfoLen = (byte)pack.OrderInfo.Length;  
 | 
                GameNetSystem.Instance.SendInfo(pack);  
 | 
            }  
 | 
            else  
 | 
            {  
 | 
                ConfirmCancel.ToggleConfirmCancel(Language.Get("Mail101"), Language.Get("GameCashRule1", money), Language.Get("TodayNoNotify"), (bool isOk, bool isToggle) =>  
 | 
                {  
 | 
                    if (isOk)  
 | 
                    {  
 | 
                        var pack = new CA125_tagCMCoinBuyOrderInfo();  
 | 
                        pack.AppID = VersionConfig.Get().appId;  
 | 
                        pack.AppIDLen = (byte)pack.AppID.Length;  
 | 
                        pack.OrderInfo = cpInfo;  
 | 
                        pack.OrderInfoLen = (byte)pack.OrderInfo.Length;  
 | 
                        GameNetSystem.Instance.SendInfo(pack);  
 | 
                    }  
 | 
                    if (isToggle)  
 | 
                    {  
 | 
                        DayRemind.Instance.SetDayRemind(DayRemind.DJQTip, true);  
 | 
                    }  
 | 
                });  
 | 
            }  
 | 
        }  
 | 
        else  
 | 
        {   
 | 
            FreePlatformPayEx(title, money, cpInfo);  
 | 
        }  
 | 
    }  
 | 
  
 | 
    public void FreePlatformPayEx(string title, float money, string cpInfo)  
 | 
    {  
 | 
        OrderInfoConfig orderInfo = null;  
 | 
        VipModel vipModel = ModelCenter.Instance.GetModel<VipModel>();  
 | 
        if (vipModel.orderInfoToCTGID.ContainsKey(cpInfo) && vipModel.orderInfoToCTGID[cpInfo] != 0)  
 | 
        {  
 | 
            vipModel.TryGetOrderInfo(vipModel.orderInfoToCTGID[cpInfo], out orderInfo);  
 | 
        }  
 | 
        else  
 | 
        {  
 | 
            var keys = OrderInfoConfig.GetKeys();  
 | 
            for (int i = 0; i < keys.Count; i++)  
 | 
            {  
 | 
                orderInfo = OrderInfoConfig.Get(keys[i]);  
 | 
                if (orderInfo != null && orderInfo.OrderInfo == cpInfo)  
 | 
                {  
 | 
                    break;  
 | 
                }  
 | 
            }  
 | 
        }  
 | 
        money = orderInfo.UsdMoney;  
 | 
#if !(UNITY_IOS || UNITY_IPHONE)  
 | 
        string storeOrderInfo = orderInfo.StoreOrderInfo;  
 | 
        if (VersionConfig.Get().sdkFileName == "hyyngame2")  
 | 
            storeOrderInfo = orderInfo.StoreOrderInfo3;  
 | 
#else  
 | 
        string storeOrderInfo = orderInfo.StoreOrderInfo2;  
 | 
#endif  
 | 
  
 | 
#if UNITY_EDITOR  
 | 
        Debug.LogFormat("充值: {0}-{1}-{2} - {3}", title, money, cpInfo, storeOrderInfo);  
 | 
        return;  
 | 
#endif  
 | 
  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.FreePlatformPay;  
 | 
        m_Json["orderId"] = DateTime.Now.ToString("yyyyMMddHHmmss") + UnityEngine.Random.Range(100000, 999999).ToString();  
 | 
        m_Json["mount"] = money.ToString();  
 | 
        m_Json["cpInfo"] = cpInfo;  
 | 
        m_Json["storeOrderInfo"] = storeOrderInfo;  
 | 
        m_Json["title"] = title;  
 | 
        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"] = ServerListCenter.Instance.currentServer.region_flag;  
 | 
        m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;  
 | 
        m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;  
 | 
        m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();  
 | 
        m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();  
 | 
        m_Json["gameName"] = VersionConfig.Get().productName;  
 | 
        m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();  
 | 
        m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();  
 | 
        m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();  
 | 
        m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();  
 | 
  
 | 
#if UNITY_IOS  
 | 
        m_Json["identifier"] = VersionConfig.Get().bundleIdentifier;  
 | 
#endif  
 | 
        SendMessageToSDK(m_Json);  
 | 
        RechargeHasDone = true;  
 | 
    }  
 | 
  
 | 
  
 | 
    /// <summary>  
 | 
    ///  分享到facebook  
 | 
    /// /// </summary>  
 | 
    public void ShareToFaceBook(int type)  
 | 
    {  
 | 
        Debug.Log("越南分享");  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.ShareToFaceBook;  
 | 
        m_Json["type"] = type;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    /// <summary>  
 | 
    /// 去商店评论  
 | 
    /// </summary>  
 | 
    public void GoToPingfen()  
 | 
    {  
 | 
        Debug.Log("越南评分");  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.GoToPingfen;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    //前往商店  
 | 
    public void GoToShop()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.GotoShop;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
  
 | 
    /**  
 | 
     * @param context  
 | 
     * @param event 事件名  
 | 
     * @param value 事件值,如果没有可以传""  
 | 
     * @param isRepeatReport 是否重复上报。根据运营需求是否排重上报,true可以重复上报,false仅上报一次  
 | 
     */  
 | 
    public void TraceEvent(string eventName, string value, bool isRepeatReport)  
 | 
    {  
 | 
        Debug.Log("越南事件汇报 :" + eventName);  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.TrackEvent;  
 | 
        m_Json["eventName"] = eventName;  
 | 
        m_Json["value"] = value;  
 | 
        m_Json["isRepeatReport"] = isRepeatReport;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    private void BuildFreePlatformInfo(JsonData json)  
 | 
    {  
 | 
        if (FreePlatformInfo == null)  
 | 
        {  
 | 
            FreePlatformInfo = new FP_LoginOk();  
 | 
        }  
 | 
  
 | 
        IDictionary _iDict = json as IDictionary;  
 | 
  
 | 
        if (_iDict.Contains("token"))  
 | 
        {  
 | 
            FreePlatformInfo.token = json["token"].ToString();  
 | 
        }  
 | 
        if (_iDict.Contains("token_expire"))  
 | 
        {  
 | 
            FreePlatformInfo.tokenExpire = json["token_expire"].ToString();  
 | 
        }  
 | 
        else  
 | 
        {  
 | 
            FreePlatformInfo.tokenExpire = "";  
 | 
        }  
 | 
        if (_iDict.Contains("account"))  
 | 
        {  
 | 
            FreePlatformInfo.account = json["account"].ToString();  
 | 
        }  
 | 
  
 | 
        if (_iDict.Contains("account_id"))  
 | 
        {  
 | 
            int.TryParse(json["account_id"].ToString(), out FreePlatformInfo.accountID);  
 | 
        }  
 | 
  
 | 
        if (_iDict.Contains("session_id"))  
 | 
        {  
 | 
            FreePlatformInfo.sessionID = (string)json["session_id"];  
 | 
        }  
 | 
  
 | 
        if (_iDict.Contains("game_id"))  
 | 
        {  
 | 
            FreePlatformInfo.gameId = (string)json["game_id"];  
 | 
        }  
 | 
  
 | 
        if (_iDict.Contains("timeStamp"))  
 | 
        {  
 | 
            FreePlatformInfo.timeStamp = (string)json["timeStamp"];  
 | 
        }  
 | 
        if (_iDict.Contains("userName"))  
 | 
        {  
 | 
            FreePlatformInfo.qkUserName = json["userName"].ToString();  
 | 
        }  
 | 
        FreePlatformInfo.phone = 0;  
 | 
    }  
 | 
  
 | 
    private void HandleFreePlatformRegisteOk(JsonData json)  
 | 
    {  
 | 
        BuildFreePlatformInfo(json);  
 | 
    }  
 | 
  
 | 
    private void HandleFreePlatformLoginOk(JsonData data)  
 | 
    {  
 | 
        BuildFreePlatformInfo(data);  
 | 
  
 | 
        DebugEx.LogFormat("sdk登录成功:{0}", data.ToJson());  
 | 
        if (onFreePlatformLoginOk != null)  
 | 
        {  
 | 
            onFreePlatformLoginOk(FreePlatformInfo);  
 | 
        }  
 | 
    }  
 | 
  
 | 
  
 | 
    public void OnServerChargeOk(HA106_tagMCCoinToGoldReport pack)  
 | 
    {  
 | 
        string orderID = pack.OrderID;  
 | 
        uint coin = pack.Coin;  
 | 
        OperationLogCollect.Instance.RecordEvent(9, coin);  
 | 
  
 | 
        if (onFreePlatformPayOk != null)  
 | 
        {  
 | 
            onFreePlatformPayOk();  
 | 
        }  
 | 
  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.PayFinished;  
 | 
        m_Json["orderID"] = orderID;  
 | 
        m_Json["payType"] = "_default_";  
 | 
        m_Json["moneyType"] = "CNY";  
 | 
        m_Json["money"] = (float)coin / 100;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void SendRegistEvent(bool _ok, string _result)  
 | 
    {  
 | 
        if (_ok)  
 | 
        {  
 | 
            if (!_result.Equals("0"))  
 | 
            {  
 | 
                m_Json.Clear();  
 | 
                m_Json["code"] = CodeU2A.SendRegistEvent;  
 | 
                SendMessageToSDK(m_Json);  
 | 
            }  
 | 
        }  
 | 
    }  
 | 
  
 | 
    public void SendLoginEvent()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.SendLoginEvent;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void SendHideFloatWin()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.HideFloatIcon;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void SendShowFloatWin()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.ShowFloatIcon;  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void CreateRoleOk(string roleID, string roleName, string time)  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.CreateRole;  
 | 
  
 | 
        m_Json["roleID"] = roleID;  
 | 
        m_Json["roleName"] = roleName;  
 | 
        m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;  
 | 
        m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;  
 | 
        m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;  
 | 
        m_Json["level"] = "1";  
 | 
        m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();  
 | 
        m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();  
 | 
        m_Json["gameName"] = VersionConfig.Get().productName;  
 | 
        m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();  
 | 
        m_Json["createTime"] = time;  
 | 
        m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();  
 | 
        m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void DownloadStart()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.DownloadStart;  
 | 
  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void DownloadEnd()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.DownloadEnd;  
 | 
  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void RoleLogin()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.RoleLogin;  
 | 
  
 | 
        m_Json["roleID"] = PlayerDatas.Instance.baseData.PlayerID.ToString();  
 | 
        m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;  
 | 
        m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;  
 | 
        m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;  
 | 
        m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;  
 | 
        m_Json["level"] = PlayerDatas.Instance.baseData.LV;  
 | 
        m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();  
 | 
        m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();  
 | 
        m_Json["gameName"] = VersionConfig.Get().productName;  
 | 
        m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();  
 | 
        m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();  
 | 
        m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();  
 | 
        m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void RoleLevelUp()  
 | 
    {  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.RoleLevelUp;  
 | 
  
 | 
        m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString();  
 | 
        m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;  
 | 
        m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;  
 | 
        m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;  
 | 
        m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;  
 | 
        m_Json["level"] = PlayerDatas.Instance.baseData.LV;  
 | 
        m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();  
 | 
        m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();  
 | 
        m_Json["gameName"] = VersionConfig.Get().productName;  
 | 
        m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();  
 | 
        m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString();  
 | 
        m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();  
 | 
        m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();  
 | 
        m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
  
 | 
    public void RoleLoginOut()  
 | 
    {  
 | 
        if (PlayerDatas.Instance.PlayerId == 0 || PlayerDatas.Instance.hero == null)  
 | 
            return;  
 | 
        if (DTC0403_tagPlayerLoginLoadOK.neverLoginOk) return;  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.RoleLoginOut;  
 | 
  
 | 
        m_Json["roleID"] = PlayerDatas.Instance.PlayerId.ToString();  
 | 
        m_Json["roleName"] = PlayerDatas.Instance.baseData.PlayerName;  
 | 
        m_Json["sid"] = ServerListCenter.Instance.currentServer.region_flag;  
 | 
        m_Json["serverName"] = ServerListCenter.Instance.currentServer.name;  
 | 
        m_Json["familyName"] = PlayerDatas.Instance.baseData.FamilyName;  
 | 
        m_Json["level"] = PlayerDatas.Instance.baseData.LV;  
 | 
        m_Json["job"] = PlayerDatas.Instance.baseData.Job.ToString();  
 | 
        m_Json["money"] = PlayerDatas.Instance.baseData.diamond.ToString();  
 | 
        m_Json["gameName"] = VersionConfig.Get().productName;  
 | 
        m_Json["vipLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();  
 | 
        m_Json["levelUpTime"] = TimeUtility.AllSeconds.ToString();  
 | 
        m_Json["createTime"] = TimeUtility.CreateSeconds.ToString();  
 | 
        m_Json["familyID"] = PlayerDatas.Instance.baseData.FamilyId.ToString();  
 | 
        m_Json["fightPower"] = PlayerDatas.Instance.baseData.FightPoint.ToString();  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
    public void GotoFansHouse()  
 | 
    {  
 | 
        Debug.Log("越南点赞");  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.FansHouse;  
 | 
  
 | 
        SendMessageToSDK(m_Json);  
 | 
    }  
 | 
  
 | 
#endregion  
 | 
  
 | 
    #region 插件相关  
 | 
  
 | 
    #endregion  
 | 
  
 | 
    #region 极光推送相关  
 | 
    public void GeTui_SendLocalMessage(JsonData jsonData)  
 | 
    {  
 | 
        return;  
 | 
        DebugEx.Log("GeTui_SendLocalMessage:" + jsonData["id"]);  
 | 
        //      ------ 举例 ------  
 | 
        //        JsonData _params = new JsonData ();  
 | 
        //        _params ["code"] = 2005;  
 | 
        //        _params ["id"] = 5;// id 重要, 标示每个通知的更新或者移除  
 | 
        //        _params ["title"] = "the title";// 推送标题  
 | 
        //        _params ["subtitle"] = "the subtitle";// 副标题  
 | 
        //        _params ["content"] = "the content";// 具体内容  
 | 
        //        _params ["badge"] = -1;// 角标  
 | 
        //  
 | 
        //        // 以下为决定应该多久后弹出此通知  
 | 
        //        System.TimeSpan ts = System.DateTime.UtcNow - new System.DateTime (1970, 1, 1, 0, 0, 0, 0);  
 | 
        //        long ret = System.Convert.ToInt64 (ts.TotalSeconds) + 3;// 表示3秒后  
 | 
        //        _params ["fireTime"] = ret;  
 | 
#if !UNITY_EDITOR  
 | 
        jsonData["code"] = CodeU2A.JPushAddLocalMessage;  
 | 
#if UNITY_ANDROID  
 | 
        jsonData["fireTime"] = (long)jsonData["fireTime"] * 1000;  
 | 
#endif  
 | 
        SendMessageToSDK(jsonData);  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    public void GeTui_RemoveLocalMessage(string id)  
 | 
    {  
 | 
        return;  
 | 
        DebugEx.Log("GeTui_RemoveLocalMessage:" + id);  
 | 
#if !UNITY_EDITOR  
 | 
        m_Json.Clear();  
 | 
        m_Json["code"] = CodeU2A.JPushRemoveLocalMessage;  
 | 
        m_Json["id"] = id;// id 重要, 标示每个通知的更新或者移除  
 | 
  
 | 
        SendMessageToSDK(m_Json);  
 | 
#endif  
 | 
    }  
 | 
  
 | 
    #endregion  
 | 
}  
 |