Browse Source

add StaticsManager & Singleton

gsgundam 8 years ago
parent
commit
39feee628d

+ 9 - 0
Assets/Script/ThirdParty/DataEyeStatics.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 0cfa100fca8eddf468363edadbe58f07
+folderAsset: yes
+timeCreated: 1501177265
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 338 - 0
Assets/Script/ThirdParty/DataEyeStatics/DataEyeGA.cs

@@ -0,0 +1,338 @@
+using System.Collections.Generic;
+using System.Net.NetworkInformation;
+using System.Net.Sockets;
+using UnityEngine;
+
+public class DataEyeGA
+{
+
+    public enum PlatformType
+    {
+        IOS = 1,
+        ADR = 2,
+        WP = 3
+    }
+
+    public enum AccountType
+    {
+        _Anonymous = 0,
+        _Registered = 1,
+        _SinaWeibo = 2,
+        _QQ = 3,
+        _QQWeibo = 4,
+        _ND91 = 5,
+        _GooglePlay = 6,
+        _Facebook = 7,
+        Type3 = 8,
+        Type4 = 9,
+        Type5 = 10,
+        Type6 = 11,
+        Type7 = 12,
+        Type8 = 13,
+        Type9 = 14,
+        Type10 = 15,
+    }
+
+    public enum Gender
+    {
+        _UNKNOWN = 0,
+        _MALE = 1,
+        _FEMALE = 2
+    }
+
+    public enum NetType
+    {
+        _3G = 1,
+        WIFI = 2,
+        OTHER = 3,
+        _2G = 4,
+        _4G = 14
+    }
+
+    public enum TaskType
+    {
+        GuideLine = 1,
+        MainLine = 2,
+        BranchLine = 3,
+        Daily = 4,
+        Activity = 5,
+        Other = 6,
+    }
+
+    public enum RequestType
+    {
+        ActOrReg,
+        Online,
+        Pay,
+        VirtualCurrency,
+        BuyItem,
+        UseItem,
+        GetItem,
+        Task,
+        LevelUp,
+        CustomEvent,
+    }
+
+    public static bool isInited = false;
+    public static bool isAccountSet = false;
+
+    private static Dictionary<RequestType, string> requestDict;
+    private static string urlPrefix = "http://ext.gdatacube.net/dc/rest/";
+
+    //必填
+    private static string appId;
+    private static string accountId;
+    private static int platform;
+    private static string gameRegion;
+    private static string channel;
+    //选填
+    private static string appVersion;
+    private static string roleId;
+    private static string roleName;
+    private static string roleClass;
+    private static string roleRace;
+    private static int accountType;
+    // private static string mac;
+    private static string imei;
+    private static int gender;
+    private static int age;
+    private static string resolution;
+    private static string osVersion;
+    private static string brand;
+    private static string language;
+    private static int netType;
+    private static string ip;
+    private static string country;
+    private static string province;
+    private static string operators;
+
+    public static void MakeDict()
+    {
+        if (requestDict == null)
+        {
+            requestDict = new Dictionary<RequestType, string>();
+            requestDict.Add(RequestType.ActOrReg, "actOrReg?");
+            requestDict.Add(RequestType.Online, "online?");
+            requestDict.Add(RequestType.Pay, "pay?");
+            requestDict.Add(RequestType.VirtualCurrency, "coin?");
+            requestDict.Add(RequestType.BuyItem, "itemBuy?");
+            requestDict.Add(RequestType.UseItem, "itemUse?");
+            requestDict.Add(RequestType.GetItem, "itemGet?");
+            requestDict.Add(RequestType.Task, "task?");
+            requestDict.Add(RequestType.LevelUp, "levelUp?");
+            requestDict.Add(RequestType.CustomEvent, "event?");
+        }
+    }
+
+    public static void Init(string appId, PlatformType platform, string gameRegion, string channel)
+    {
+        MakeDict();
+
+        DataEyeGA.appId = appId;
+        DataEyeGA.platform = platform.GetHashCode();
+        DataEyeGA.gameRegion = gameRegion;
+        DataEyeGA.channel = channel;
+        appVersion = Application.version;
+        string hostName = System.Net.Dns.GetHostName();
+        ip = System.Net.Dns.GetHostEntry(hostName).AddressList.GetValue(0).ToString();
+        imei = SystemInfo.deviceUniqueIdentifier;
+        resolution = Screen.width + "*" + Screen.height;
+        osVersion = SystemInfo.operatingSystem;
+        brand = SystemInfo.deviceModel;
+        language = Application.systemLanguage.ToString();
+        if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
+            netType = NetType._4G.GetHashCode();
+        else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
+            netType = NetType.WIFI.GetHashCode();
+
+        isInited = true;
+    }
+
+    public static void SetAccount(string accountId, AccountType accountType, bool sendOnline = false)
+    {
+        DataEyeGA.accountId = accountId;
+        DataEyeGA.accountType = accountType.GetHashCode();
+        if(sendOnline)
+            Online();
+
+        isAccountSet = true;
+    }
+
+    public static void ActOrReg()
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("actTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        paramList.Add(new KeyValuePair<string, string>("regTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.ActOrReg, paramList);
+    }
+
+    public static void Online(int level = 0)
+    {
+        if (DateUtil.GetRealTimeSinceStart() <= 60)
+            return;
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("loginTime", DateUtil.GetStandardTimeExistByTimeStamp().ToString()));
+        paramList.Add(new KeyValuePair<string, string>("onlineTime", DateUtil.GetRealTimeSinceStart().ToString()));
+
+        paramList.Add(new KeyValuePair<string, string>("level", level.ToString()));
+        SendUrl(RequestType.Online, paramList);
+    }
+
+    /// <param name="currencyAmount"></param>
+    /// <param name="currencyType"></param>
+    /// <param name="iapid">付费点</param>
+    /// <param name="orderId">订单ID</param>
+    public static void Pay(int currencyAmount, string currencyType, string iapid, string orderId)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("currencyAmount", currencyAmount.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("currencyType", currencyType));
+        paramList.Add(new KeyValuePair<string, string>("iapid", iapid));
+        paramList.Add(new KeyValuePair<string, string>("orderId", orderId));
+        paramList.Add(new KeyValuePair<string, string>("payTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.Pay, paramList);
+    }
+
+    /// <param name="coinNum"></param>
+    /// <param name="coinType">虚拟币类型</param>
+    /// <param name="type">获得虚拟的途径</param>
+    /// <param name="isGain">是否获得 0 消耗 1 获得</param>
+    /// <param name="totalCoin">该玩家手里最终持有的货币数量</param>
+    public static void VirtualCurrency(int coinNum, string coinType, string type, bool isGain, int totalCoin)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("coinNum", coinNum.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("coinType", coinType));
+        paramList.Add(new KeyValuePair<string, string>("type", type));
+        paramList.Add(new KeyValuePair<string, string>("isGain", isGain ? "1" : "0"));
+        paramList.Add(new KeyValuePair<string, string>("totalCoin", totalCoin.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("msgTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.VirtualCurrency, paramList);
+    }
+
+    /// <param name="itemId"></param>
+    /// <param name="itemType"></param>
+    /// <param name="itemCnt">购买的道具数量</param>
+    /// <param name="coinNum">消耗虚拟币数量</param>
+    /// <param name="coinType">虚拟币种类</param>
+    public static void BuyItem(string itemId, string itemType, string itemCnt, int coinNum, string coinType)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("itemId", itemId));
+        paramList.Add(new KeyValuePair<string, string>("itemType", itemType));
+        paramList.Add(new KeyValuePair<string, string>("itemCnt", itemCnt));
+        paramList.Add(new KeyValuePair<string, string>("coinNum", coinNum.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("coinType", coinType));
+        paramList.Add(new KeyValuePair<string, string>("msgTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.BuyItem, paramList);
+    }
+
+    /// <param name="itemId"></param>
+    /// <param name="itemType"></param>
+    /// <param name="itemCnt">购买的道具数量</param>
+    /// <param name="reason">道具消耗的途径</param>
+    public static void UseItem(string itemId, string itemType, string itemCnt, string reason)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("itemId", itemId));
+        paramList.Add(new KeyValuePair<string, string>("itemType", itemType));
+        paramList.Add(new KeyValuePair<string, string>("itemCnt", itemCnt));
+        paramList.Add(new KeyValuePair<string, string>("reason", reason));
+        paramList.Add(new KeyValuePair<string, string>("msgTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.UseItem, paramList);
+    }
+
+    /// <param name="itemId"></param>
+    /// <param name="itemType"></param>
+    /// <param name="itemCnt">购买的道具数量</param>
+    /// <param name="reason">道具获得的途径</param>
+    public static void GetItem(string itemId, string itemType, int itemCnt, string reason)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("itemId", itemId));
+        paramList.Add(new KeyValuePair<string, string>("itemType", itemType));
+        paramList.Add(new KeyValuePair<string, string>("itemCnt", itemCnt.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("reason", reason));
+        paramList.Add(new KeyValuePair<string, string>("msgTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.GetItem, paramList);
+    }
+
+    /// <param name="taskId">任务ID</param>
+    /// <param name="taskType">任务类型</param>
+    /// <param name="duration">任务耗时</param>
+    /// <param name="isSucc">是否失败 0 任务失败 1 任务完成</param>
+    /// <param name="reason">任务失败原因</param>
+    public static void Task(string taskId, TaskType taskType, int duration, bool isSucc, string reason)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("taskId", taskId));
+        paramList.Add(new KeyValuePair<string, string>("taskType", taskType.GetHashCode().ToString()));
+        paramList.Add(new KeyValuePair<string, string>("duration", duration.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("isSucc", isSucc ? "1" : "0"));
+        paramList.Add(new KeyValuePair<string, string>("reason", reason));
+        paramList.Add(new KeyValuePair<string, string>("msgTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.Task, paramList);
+    }
+
+    /// <param name="startLevel">开始等级</param>
+    /// <param name="endLevel">结束等级</param>
+    /// <param name="interval">升级时长(秒)</param>
+    public static void LevelUp(int startLevel, int endLevel, int interval)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("startLevel", startLevel.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("endLevel", endLevel.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("interval", interval.ToString()));
+        paramList.Add(new KeyValuePair<string, string>("msgTime", DateUtil.GetCurrentTimeByStandardTime().ToString()));
+        SendUrl(RequestType.LevelUp, paramList);
+    }
+
+    /// <summary>
+    /// 触发自定义事件
+    /// </summary>
+    /// <param name="eventId">事件id</param>
+    /// <param name="duration">事件耗时(秒)</param>
+    /// <param name="keyValueList">参数列表</param>
+    public static void CustomEvent(string eventId, int duration, List<KeyValuePair<string, string>> labelMapList)
+    {
+        List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
+        paramList.Add(new KeyValuePair<string, string>("eventId", eventId));
+        paramList.Add(new KeyValuePair<string, string>("duration", duration.ToString()));
+        string labelMap = "{";
+        for(int i=0; i<labelMapList.Count; i++)
+            labelMap += labelMapList[i].Key + ":" + labelMapList[i].Value;
+        labelMap += "}";
+        paramList.Add(new KeyValuePair<string, string>("labelMap", labelMap));
+        SendUrl(RequestType.CustomEvent, paramList);
+    }
+
+    private static string SendUrl(RequestType requestType, List<KeyValuePair<string, string>> specialParamList = null)
+    {
+        string url = urlPrefix + requestDict[requestType];
+        url += "appId=" + appId;
+        url += "&accountId=" + accountId;
+        url += "&platform=" + platform;
+        url += "&gameRegion=" + gameRegion;
+        url += "&channel=" + channel;
+        url += "&appVersion=" + appVersion;
+        url += "&accountType=" + accountType;
+        // url += "&mac=" + mac;
+        url += "&ip=" + ip;
+        url += "&imei=" + imei;
+        url += "&resolution=" + resolution;
+        url += "&osVersion=" + WWW.EscapeURL(osVersion);
+        url += "&brand=" + WWW.EscapeURL(brand);
+        url += "&language=" + language;
+        url += "&netType=" + netType;
+        if(specialParamList != null)
+        {
+            for(int i=0; i<specialParamList.Count; i++)
+                url += "&" + specialParamList[i].Key + "=" + WWW.EscapeURL(specialParamList[i].Value);
+        }
+        //Debuger.LogError("[DataEye GA]" + url);
+
+        URLRequest.CreateStrURLRequest(url, null, null, URLRequest.Method.GET);
+
+        return url;
+    }
+}

+ 12 - 0
Assets/Script/ThirdParty/DataEyeStatics/DataEyeGA.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 8e9837dbd24ea544dacf51f817c40945
+timeCreated: 1501177299
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 356 - 0
Assets/Script/ThirdParty/DataEyeStatics/StaticsManager.cs

@@ -0,0 +1,356 @@
+using System;
+using System.Collections.Generic;
+
+
+public class StaticsManager
+{
+    public enum ConsumeType
+    {
+        None,
+        Purchase,
+        Use,
+        Reward,
+    }
+
+    public enum ConsumeModule
+    {
+        None,
+        Charge,
+        Shop,
+        Checkin,
+    }
+
+    private static StaticsManager instance;
+    public static StaticsManager GetInstance()
+    {
+        if (instance == null)
+            instance = new StaticsManager();
+        return instance;
+    }
+
+    public static string currencyType = "USD"; //请使用国际标准组织 ISO 4217 中规范的 3 位字母代码标记货币类型。点击查看参考例:人民币 CNY;美元 USD;欧元 EUR
+
+    public void StartSession()
+    {
+        if (DataEyeGA.isAccountSet)
+            DataEyeGA.Online();
+        //AnySDKAnalytics.getInstance().startSession();
+    }
+
+    public void StopSession()
+    {
+#if UNITY_EDITOR
+        if (DataEyeGA.isAccountSet)
+            DataEyeGA.Online();
+#endif
+        //AnySDKAnalytics.getInstance().stopSession();
+    }
+
+    public void Online()
+    {
+        if (DataEyeGA.isAccountSet)
+            DataEyeGA.Online();
+    }
+
+    public void SetSessionInterval(long interval)
+    {
+        //AnySDKAnalytics.getInstance().setSessionContinueMillis(interval);
+    }
+
+    public void SetCaptureUncaughtException(bool value)
+    {
+        //AnySDKAnalytics.getInstance().setCaptureUncaughtException(value);
+    }
+
+    //public void SetAccount(int userId, string nickname, AccountType accountType, int teamRank, AccountOperate operate)
+    //{
+    //    Dictionary<string, string> paramMap = new Dictionary<string, string>();
+    //    paramMap["Account_Id"] = userId.ToString();
+    //    paramMap["Account_Name"] = nickname;
+    //    paramMap["Account_Type"] = Convert.ToString((int)accountType);
+    //    paramMap["Account_Level"] = teamRank.ToString();
+    //    paramMap["Account_Operate"] = Convert.ToString((int)operate);
+    //    paramMap["Server_Id"] = Config.GetHostIp();
+    //    //AnySDKParam param = new AnySDKParam(paramMap);
+    //    //AnySDKAnalytics.getInstance().callFuncWithParam("setAccount", param);
+    //}
+
+    /// <summary>
+    /// 注册与激活
+    /// </summary>
+    /// <param name="accountId">帐号id</param>
+    /// <param name="accountType">帐号类型</param>
+    public void ActOrReg(string accountId, DataEyeGA.AccountType accountType)
+    {
+        if (DataEyeGA.isInited)
+        {
+            DataEyeGA.SetAccount(accountId, accountType);
+            DataEyeGA.ActOrReg();
+        }
+        else
+            Debuger.LogWarning("[DataEyeGA] is not inited!!");
+    }
+
+    /// <summary>
+    /// 设置帐号
+    /// </summary>
+    /// <param name="accountId">帐号id</param>
+    /// <param name="accountType">帐号类型</param>
+    public void SetAccount(string accountId, DataEyeGA.AccountType accountType)
+    {
+        if (DataEyeGA.isInited)
+        {
+            DataEyeGA.SetAccount(accountId, accountType);
+            DataEyeGA.Online();
+        }
+    }
+
+    /// <summary>
+    /// 支付请求
+    /// </summary>
+    /// <param name="requestTimeStamp">订单唯一标示符,目前建议使用时间戳</param>
+    /// <param name="productName">商品名</param>
+    /// <param name="currencyAmount">现金数额(元)</param>
+    /// <param name="currencyType">请使用国际标准组织 ISO 4217 中规范的 3 位字母代码标记货币类型。点击查看参考例:人民币 CNY;美元 USD;欧元 EUR</param>
+    /// <param name="paymentType">支付的途径,最多 16 个字符。例如:“支付宝”“苹果官方”“XX 支付 SDK</param>
+    /// <param name="virtualCurrencyAmount">虚拟币数值</param>
+    public void ChargeRequest(int requestTimeStamp, string productName, int currencyAmount, string currencyType, string paymentType, int virtualCurrencyAmount)
+    {
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Order_Id"] = requestTimeStamp.ToString();
+        //map["Product_Name"] = productName;
+        //map["Currency_Amount"] = currencyAmount.ToString();
+        //map["Currency_Type"] = currencyType;
+        //map["Payment_Type"] = paymentType;
+        //map["Virtual_Currency_Amount"] = virtualCurrencyAmount.ToString();
+        //AnySDKParam param = new AnySDKParam(map);
+        //AnySDKAnalytics.getInstance().callFuncWithParam("onChargeRequest", param);
+    }
+
+    /// <summary>
+    /// 支付成功
+    /// </summary>
+    /// <param name="requestTimeStamp">订单唯一标示符,目前建议使用时间戳</param>
+    public void ChargeSuccess(int requestTimeStamp)
+    {
+        //AnySDKParam param = new AnySDKParam(requestTimeStamp.ToString());
+        //AnySDKAnalytics.getInstance().callFuncWithParam("onChargeSuccess", param);
+    }
+
+    /// <summary>
+    /// 支付请求
+    /// </summary>
+    /// <param name="requestTimeStamp">订单唯一标示符,目前建议使用时间戳</param>
+    /// <param name="productName">商品名</param>
+    /// <param name="currencyAmount">现金数额(元)</param>
+    /// <param name="currencyType">请使用国际标准组织 ISO 4217 中规范的 3 位字母代码标记货币类型。点击查看参考例:人民币 CNY;美元 USD;欧元 EUR</param>
+    /// <param name="paymentType">支付的途径,最多 16 个字符。例如:“支付宝”“苹果官方”“XX 支付 SDK</param>
+    /// <param name="virtualCurrencyAmount">虚拟币数值</param>
+    public void ChargeSuccess(int requestTimeStamp, string productName, int currencyAmount, string currencyType, string paymentType, int virtualCurrencyAmount)
+    {
+        DataEyeGA.Pay(currencyAmount, currencyType, productName, requestTimeStamp.ToString());
+        //TODO: 获取玩家自身的钻石数量
+        // DataEyeGA.VirtualCurrency(virtualCurrencyAmount, "钻石", GetStringByConsumeModule(ConsumeModule.Charge), true, Session.GetInstance().myPlayer.diamond);
+        //AnySDKParam param = new AnySDKParam(requestTimeStamp.ToString());
+        //AnySDKAnalytics.getInstance().callFuncWithParam("onChargeSuccess", param);
+    }
+
+    /// <summary>
+    /// 支付失败
+    /// </summary>
+    /// <param name="requestTimeStamp">订单唯一标示符,目前建议使用时间戳</param>
+    /// <param name="failReason">失败原因</param>
+    public void ChargeFailed(int requestTimeStamp, string failReason)
+    {
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Order_Id"] = requestTimeStamp.ToString();
+        //map["Fail_Reason"] = failReason;
+        //AnySDKParam param = new AnySDKParam(map);
+       // AnySDKAnalytics.getInstance().callFuncWithParam("onChargeFail", param);
+    }
+
+    /// <summary>
+    /// 购买 - 钻石消费
+    /// </summary>
+    /// <param name="itemId">物品标示符</param>
+    /// <param name="string">物品类型</param>
+    /// <param name="itemCount">物品数量</param>
+    /// <param name="virtualCurrency">虚拟金额</param>
+    public void PurchaseItem(int itemId, string itemType, int itemCount, int virtualCurrency, ConsumeModule consumeModule)
+    {
+        DataEyeGA.BuyItem(itemId.ToString(), itemType.ToString(), itemCount.ToString(), virtualCurrency, "钻石");
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Item_Id"] = itemId.ToString();
+        //map["Item_Type"] = GetStringByItemType(itemType);
+        //map["Item_Count"] = itemCount.ToString();
+        //map["Virtual_Currency"] = virtualCurrency.ToString();
+        //map["Currency_Type"] = AnySDK.getInstance().getChannelId();
+        //AnySDKParam param = new AnySDKParam(map);
+        //AnySDKAnalytics.getInstance().callFuncWithParam("onPurchase", param);
+    }
+
+    /// <summary>
+    /// 使用道具 - 包括金币、竞技券、体力等,不包括钻石
+    /// </summary>
+    /// <param name="itemId">物品标示符</param>
+    /// <param name="string">物品类型</param>
+    /// <param name="itemCount">物品数量</param>
+    /// <param name="useReason">用途说明: 暂定显示为模块</param>
+    public void UseItem(int itemId, string itemType, int itemCount, ConsumeModule module)
+    {
+        DataEyeGA.UseItem(itemId.ToString(), itemType.ToString(), itemCount.ToString(), GetStringByConsumeModule(module));
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Item_Id"] = itemId.ToString();
+        //map["Item_Type"] = GetStringByItemType(itemType);
+        //map["Item_Count"] = itemCount.ToString();
+        //map["Use_Reason"] = GetStringByConsumeModule(module);
+        //AnySDKParam param = new AnySDKParam(map);
+        //AnySDKAnalytics.getInstance().callFuncWithParam("onUse", param);
+    }
+
+    /// <summary>
+    /// 奖励道具 - 包括钻石、金币、竞技券、体力等
+    /// </summary>
+    /// <param name="itemId">物品标示符</param>
+    /// <param name="string">物品类型</param>
+    /// <param name="itemCount">物品数量</param>
+    /// <param name="useReason">用途说明: 暂定显示为模块</param>
+    public void RewardItem(int itemId, string itemType, int itemCount, ConsumeModule module)
+    {
+        //TODO: 如果是钻石则记录为钻石,否则全部记录为道具
+        // if (itemId == Item.SpecialType.Diamond.GetHashCode())
+        //     DataEyeGA.VirtualCurrency(itemCount, "钻石", GetStringByConsumeModule(module), true, Session.GetInstance().myPlayer.diamond);
+        // else
+        //     DataEyeGA.GetItem(itemId.ToString(), itemType.ToString(), itemCount, GetStringByConsumeModule(module));
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Item_Id"] = itemId.ToString();
+        //map["Item_Type"] = GetStringByItemType(itemType);
+        //map["Item_Count"] = itemCount.ToString();
+        //map["Use_Reason"] = GetStringByConsumeModule(module);
+        // AnySDKParam param = new AnySDKParam(map);
+        //AnySDKAnalytics.getInstance().callFuncWithParam("onReward", param);
+    }
+
+    public static string GetStringByConsumeModule(ConsumeModule module)
+    {
+        switch (module)
+        {
+            case ConsumeModule.Charge:
+                return "充值";
+            case ConsumeModule.Checkin:
+                return "签到";
+            case ConsumeModule.Shop:
+                return "商店";
+            default:return "未知";
+        }
+    }
+
+    /// <summary>
+    /// 开始关卡
+    /// </summary>
+    /// <param name="levelId">关卡id</param>
+    /// <param name="seqNum">关卡顺序 - 可直接使用关卡id</param>
+    public void StartLevel(int levelId, int seqNum)
+    {
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Level_Id"] = levelId.ToString();
+        //map["Seq_Num"] = Convert.ToString(seqNum);
+        //AnySDKParam param = new AnySDKParam(map);
+       // AnySDKAnalytics.getInstance().callFuncWithParam("startLevel", param);
+    }
+
+    /// <summary>
+    /// 关卡通过
+    /// </summary>
+    /// <param name="levelId">关卡id</param>
+    public void FinishLevel(int levelId)
+    {
+        DataEyeGA.Task(levelId.ToString(), DataEyeGA.TaskType.MainLine, 0, true, "");
+       // AnySDKParam param = new AnySDKParam(levelId);
+       // AnySDKAnalytics.getInstance().callFuncWithParam("finishLevel", param);
+    }
+
+    /// <summary>
+    /// 关卡失败
+    /// </summary>
+    /// <param name="levelId">关卡id</param>
+    /// <param name="failReason">失败原因</param>
+    public void FailLevel(int levelId, string failReason)
+    {
+        DataEyeGA.Task(levelId.ToString(), DataEyeGA.TaskType.MainLine, 0, true, failReason);
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Level_Id"] = levelId.ToString();
+        //map["Fail_Reason"] = failReason;
+        //AnySDKParam param = new AnySDKParam(map);
+        //AnySDKAnalytics.getInstance().callFuncWithParam("failLevel", param);
+    }
+
+    /// <summary>
+    /// 开始任务
+    /// </summary>
+    /// <param name="taskId">任务id</param>
+    /// <param name="string">任务类型</param>
+    public void StartTask(int taskId, string taskType)
+    {
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Task_Id"] = taskId.ToString();
+        //map["Task_Type"] = Convert.ToString((int)taskType);
+        //AnySDKParam param = new AnySDKParam(map);
+        //AnySDKAnalytics.getInstance().callFuncWithParam("startTask", param);
+    }
+
+    /// <summary>
+    /// 任务完成
+    /// </summary>
+    /// <param name="taskId">任务id</param>
+    public void FinishTask(int taskId)
+    {
+        List<KeyValuePair<string, string>> labelMapList = new List<KeyValuePair<string, string>>();
+        labelMapList.Add(new KeyValuePair<string, string>("id", taskId.ToString()));
+        DataEyeGA.CustomEvent("任务完成", 0, labelMapList);
+        //DataEyeGA.Task(taskId.ToString(), DataEyeGA.TaskType.Activity, 0, true, "");
+        //AnySDKAnalytics.getInstance().callFuncWithParam("finishTask", new AnySDKParam(taskId));
+    }
+
+    /// <summary>
+    /// 任务失败
+    /// </summary>
+    /// <param name="taskId">任务id</param>
+    /// <param name="failReason">失败原因</param>
+    public void FailTask(int taskId, string failReason)
+    {
+        //DataEyeGA.Task(taskId.ToString(), DataEyeGA.TaskType.Activity, 0, false, failReason);
+        //Dictionary<string, string> map = new Dictionary<string, string>();
+        //map["Task_Id"] = taskId.ToString();
+        //map["Fail_Reason"] = failReason.ToString();
+        //AnySDKParam param = new AnySDKParam(map);
+        //AnySDKAnalytics.getInstance().callFuncWithParam("failTask", param);
+    }
+
+    public void LevelUp(int startLevel, int endLevel, int interval)
+    {
+        DataEyeGA.LevelUp(startLevel, endLevel, interval);
+    }
+
+    /// <summary>
+    /// 完成引导
+    /// </summary>
+    /// <param name="id">引导id</param>
+	public void TutoComplete(int id)
+	{
+		DataEyeGA.CustomEvent("tuto"+id, 0, new List<KeyValuePair<string, string>>());
+	}
+
+    /// <summary>
+    /// 点击广告
+    /// </summary>
+    /// <param name="id">类型id:0为技能冷却,1为金币,2为钻石</param>
+    public void AdClicked(int id){
+        DataEyeGA.CustomEvent("点击广告-"+id, 0, new List<KeyValuePair<string, string>>());
+        DataEyeGA.CustomEvent("点击广告", 0, new List<KeyValuePair<string, string>>());
+    }
+
+    public void AdFinished(){
+        DataEyeGA.CustomEvent("广告播放完毕", 0, new List<KeyValuePair<string, string>>());
+    }
+}

+ 12 - 0
Assets/Script/ThirdParty/DataEyeStatics/StaticsManager.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 138d8141aa9fff149a2b779fce49074c
+timeCreated: 1462418481
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 157 - 0
Assets/Script/Tool/Singleton.cs

@@ -0,0 +1,157 @@
+using UnityEngine;
+using System.Collections;
+
+public abstract class Singleton<T> where T : new()
+{
+	private static T _instance;
+	static object _lock = new object();
+	public static T Instance
+	{
+		get
+		{
+			if (_instance == null)
+			{
+				lock (_lock)
+				{
+					if (_instance == null)
+						_instance = new T();
+				}
+			}
+			return _instance;
+		}
+	}
+}
+
+
+/// <summary>
+/// Be aware this will not prevent a non singleton constructor5.
+///   such as `T myT = new T();`
+/// To prevent that, add `protected T () {}` to your singleton class.
+/// </summary>
+public class UnitySingleton<T> : MonoBehaviour where T : MonoBehaviour
+{
+	private static T _instance;
+	private static object _lock = new object ();
+
+	public static T Instance {       
+		get {         
+			lock (_lock) {
+				if (applicationIsQuitting) {
+					return null;
+				}
+
+				if (_instance == null) {
+					_instance = (T)FindObjectOfType (typeof(T));
+					if (_instance == null) {
+						string goName = typeof(T).ToString ();
+
+						GameObject go = GameObject.Find (goName);
+						if (go == null) {
+							go = new GameObject ();
+							_instance = go.AddComponent<T> ();
+							go.name = "(singleton) " + typeof(T).ToString ();
+							//go.hideFlags = HideFlags.HideAndDontSave;
+							DontDestroyOnLoad (go);
+						}
+					} else {
+
+					}
+				}
+				return _instance;
+			}
+		}
+	}
+
+	private static bool applicationIsQuitting = false;
+
+	// private static bool ClearMode = false;
+
+	public static void DestorySingleton ()
+	{
+		lock (_lock) {
+			applicationIsQuitting = true;
+
+			if (_instance != null) {
+				// ClearMode = true;
+				GameObject.Destroy (_instance.gameObject);
+				_instance = null;
+			}
+		}
+	}
+
+	// public void OnDestroy() {
+	// 	//Debug.LogError ("unitySingle OnDestroy");
+
+	// 	lock (_lock) {
+	// 		applicationIsQuitting = true;
+
+	// 		if (_instance != null) {
+	// 			GameObject.Destroy (_instance.gameObject);
+	// 			_instance = null;
+	// 		}
+	// 	}
+	// }
+}
+
+public class UnitySingletonLoadDestory<T> : MonoBehaviour where T : MonoBehaviour
+{
+	private static T _instance;
+	private static object _lock = new object ();
+
+	public static T Instance {       
+		get {         
+			if (applicationIsQuitting) {
+				return null;
+			}
+
+			lock (_lock) {
+				if (_instance == null) {
+					_instance = (T)FindObjectOfType (typeof(T));
+					if (_instance == null) {
+						string goName = typeof(T).ToString ();
+
+						GameObject go = GameObject.Find (goName);
+						if (go == null) {
+							go = new GameObject ();
+							_instance = go.AddComponent<T> ();
+							go.name = "(singleton) " + typeof(T).ToString ();
+							//go.hideFlags = HideFlags.HideAndDontSave;
+							go.hideFlags = HideFlags.DontSave;
+						}
+					} else {
+
+					}
+				}
+				return _instance;
+			}
+		}
+	}
+
+	private static bool applicationIsQuitting = false;
+
+	public static void DestorySingleton ()
+	{
+
+		lock (_lock) {
+			applicationIsQuitting = true;
+
+			if (_instance != null) {
+				GameObject.Destroy (_instance.gameObject);
+				_instance = null;
+			}
+		}
+	}
+
+	public void OnDestroy()
+	{
+		lock (_lock) {
+			applicationIsQuitting = true;
+
+			if (_instance != null) {
+				GameObject.Destroy (_instance.gameObject);
+				_instance = null;
+			}
+		}
+	}
+}
+

+ 12 - 0
Assets/Script/Tool/Singleton.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 29499756765f4cc4cb2f1500426ec797
+timeCreated: 1501174787
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: