From 194e5ffafca8d2ecaae2822c1c29f8565b68c4ae Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Tue, 15 Dec 2020 09:37:09 +0800
Subject: [PATCH] 修改打点

---
 Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs |  145 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 100 insertions(+), 45 deletions(-)

diff --git a/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs b/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs
index 26c4370..4d5a9a3 100644
--- a/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs
+++ b/Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs
@@ -22,22 +22,31 @@
 
     private Text versionTxt;//版本号
     private Text resVersion;//资源版本号
+    float waitTime;//切换场景等待时间
 
+    [SerializeField]
+    private Sprite nextSprite;
+
+    [SerializeField]
+    private Image bg;
+
+    [SerializeField]
+    private List<GameObject> other;
 
     // Start is called before the first frame update
     void Start()
     {
         AudioSourceManager.Ins.Play(AudioEnum.BGM1);
+
         EventCenter.Ins.RemoveAllListener();
+        TDAA_SDKManager.Ins.AddListener();
 
         isLogining = false;
 
         repairBtn = transform.Find("Panel/RepairBtn").GetComponent<Button>();
-        noticeBtn = transform.Find("Panel/NoticeBtn").GetComponent<Button>();
         startBtn = transform.Find("Panel/StartBtn").GetComponent<Button>();
 
         versionTxt = transform.Find("Panel/Version").GetComponent<Text>();
-        resVersion = transform.Find("Panel/ResVersion").GetComponent<Text>();
 
         progressSlider = transform.Find("Panel/Progress").GetComponent<Slider>();
         progressSlider.value = 0;
@@ -53,39 +62,61 @@
 
         //transform.Find("Panel/Button (1)").GetComponent<Button>().onClick.AddListener(OnClickResetBtn);
 
-        
-        if (Application.platform == RuntimePlatform.Android)
+        if (!GameConfig.useSDK)
         {
-            //GetetDeviceIMEI();//获取安卓手机IMEI
-            imei0 = TDAA_SDKManager.Ins.GetDeviceId();//使用设备ID
-        }
-        else if (Application.platform == RuntimePlatform.WindowsEditor)
-        {
-            imei0 = "MyTestGemBattle123";
-        }
+            if (Application.platform == RuntimePlatform.Android)
+            {
+                //GetetDeviceIMEI();//获取安卓手机IMEI
+                imei0 = TDAA_SDKManager.Ins.GetDeviceId();//使用设备ID
+            }
+            else if (Application.platform == RuntimePlatform.WindowsEditor)
+            {
+                imei0 = "MyTestGemBattle123";
+            }
 
-        GameConfig.PlayerName = imei0;
+            GameConfig.Imei = imei0;
+        }
 
         versionTxt.text = "版本号:" + Application.version;
         //resVersion.text 暂时没有使用
         transform.Find("Panel/PlayerID").GetComponent<Text>().text = "玩家ID:" + imei0;
 
-
-        if (!GameConfig.isFirstStart)//后续直接加载
-        {
-            waitTime = 2f;
-
-            loginNext();
-        }
-        else
+        if (GameConfig.isFirstStart)
         {
             waitTime = 0f;
-            //第一次启动,初始化并且埋点
-            //TDAA_SDKManager.Ins.SDKInit(ChannelID.Gm.ToString());
-            //TDAA_SDKManager.Ins.Statistics(1);//成功加载登陆界面的人数
+            Debug.Log("初始化TDAA_SDKManager");
+            TDAA_SDKManager.Ins.SDKInit(ChannelID.Gm.ToString());
+            TDAA_SDKManager.Ins.Statistics(1);//成功加载登陆界面的人数
+        }
+
+        SetStart();
+    }
+
+    /// <summary>
+    /// 设置开始状态
+    /// </summary>
+    private void SetStart()
+    {
+        startBtn.gameObject.SetActive(true);
+        int resId = Mathf.FloorToInt(Mathf.Clamp01(GameConfig.GameCompletedCount));
+        Image img = startBtn.transform.GetChild(0).GetComponent<Image>();
+        img.sprite = Resources.Load<Sprite>($"UI/Loading/{resId}");
+        img.SetNativeSize();
+
+        if (GameConfig.GameCompletedCount > 0)
+        {
+            for (int i = 0; i < other.Count; ++i)
+            {
+                other[i].SetActive(false);
+            }
+            bg.sprite = nextSprite;
+            bg.SetNativeSize();
         }
     }
 
+    /// <summary>
+    /// 开始游戏
+    /// </summary>
     void loginNext()
     {
         progressSlider.gameObject.SetActive(true);
@@ -98,24 +129,27 @@
         StartCoroutine(loginMy());
     }
 
-    float waitTime;
+    /// <summary>
+    /// 使用SDK登录
+    /// </summary>
+    void SDKloginNext()
+    {
+        Debug.Log("SDK登录,修改Imei");
+        GameConfig.Imei = SDKManager.ins.sdk.uid;
+        transform.Find("Panel/PlayerID").GetComponent<Text>().text = "玩家ID:" + GameConfig.Imei;
 
-    // private void OnEnable()
-    // {
-    //     SocketEvent.Ins.Add<IMessage>((int)Opcode.LoginS2C, LoginS2C);
-    // }
+        loginNext();
+    }
 
-    // private void OnDestroy()
-    // {
-    //     SocketEvent.Ins.Remove<IMessage>((int)Opcode.LoginS2C, LoginS2C);
-
-    // }
 
     #region 获得安卓手机上的IMEI号
     public string imei0 = "";
     public string imei1 = "";
     public string meid = "";
 
+    /// <summary>
+    /// 已弃用
+    /// </summary>
     void GetetDeviceIMEI()
     {
         var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
@@ -132,9 +166,12 @@
 
     private void OnClickResetBtn()
     {
-        Debug.LogError("清空了所有数据");
-        PlayerPrefs.DeleteAll();
-        TDAA_SDKManager.Ins.Reset();
+        if (!GameConfig.useSDK)
+        {
+            Debug.LogError("清空了所有数据");
+            PlayerPrefs.DeleteAll();
+            TDAA_SDKManager.Ins.Reset();
+        }
     }
 
 
@@ -142,18 +179,36 @@
     {
         if (!isLogining)
         {
-            // CoderM: 在这里要使用SDK来进行登录了
-            SDKCallBack.ins.setNextAction("login", loginNext);
-            SDKManager.ins.sdk.login();
+            isLogining = true;
+            if (GameConfig.isFirstStart)
+            {
+                // CoderM: 在这里要使用SDK来进行登录了
+                if (GameConfig.useSDK)
+                {
+                    Debug.Log("使用SDK来进行登录了");
+                    //设置login的回调
+                    SDKCallBack.ins.setNextAction("login", SDKloginNext);
+                    SDKManager.ins.sdk.login();
+                }
+                else
+                {
+                    Debug.Log("没有使用SDK");
 
-            //progressSlider.gameObject.SetActive(true);
-            //startBtn.gameObject.SetActive(false);
+                    //没有使用SDK
+                    loginNext();
+                }
+            }
+            else
+            {
+                Debug.Log("重玩");
+                progressSlider.gameObject.SetActive(true);
+                startBtn.gameObject.SetActive(false);
 
-            //AudioSourceManager.Ins.Play(AudioEnum.UI);
-            //TDAA_SDKManager.Ins.Statistics(2);//埋点
+                AudioSourceManager.Ins.Play(AudioEnum.UI);
+                TDAA_SDKManager.Ins.OnClickRestartBtn();//重玩
+                StartCoroutine(loginMy());
+            }
 
-            //GameConfig.isFirstStart = false;
-            //StartCoroutine(loginMy());
         }
         else
         {

--
Gitblit v1.9.1