Browse Source

白名单请求修改

DESKTOP-5BUCSUT\LSR 1 year ago
parent
commit
7a2041e74f

+ 27 - 1
SFGgouhuo/Assets/Scripts/Manager/GameManager.cs

@@ -1,6 +1,9 @@
+using Assets;
+using LitJson;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.Networking;
 using UnityEngine.SceneManagement;
 using YooAsset;
 
@@ -14,6 +17,11 @@ public class GameManager : MonoBehaviour
     private YooAssetManager m_YooAssetManager;
     private CharacterManager m_CharacterManager;
     private StepManager m_StepManager;
+    public WhiteList whiteList;
+    /// <summary>
+    /// °×Ãûµ¥URL
+    /// </summary>
+    string urlWhiteList = "https://sfgdemo-1303083714.cos.ap-hongkong.myqcloud.com/WhiteList.json";
     private async void Awake()
     {
         Debug.Log("½øÈëGameManager");
@@ -31,8 +39,26 @@ public class GameManager : MonoBehaviour
         m_AudioManager = gameObject.AddComponent<AudioManager>();
         m_CharacterManager = gameObject.AddComponent<CharacterManager>();
         m_StepManager= gameObject.AddComponent<StepManager>();
+        StartCoroutine(GetWhiteList());
+    }
+    /// <summary>
+    /// ÇëÇó°×Ãûµ¥
+    /// </summary>
+    /// <returns></returns>
+    IEnumerator GetWhiteList()
+    {
+        UnityWebRequest request = UnityWebRequest.Get(urlWhiteList);
+        yield return request.SendWebRequest();
+        if (request.result == UnityWebRequest.Result.Success)
+        {
+            whiteList = JsonMapper.ToObject<WhiteList>(request.downloadHandler.text);
+            StepManager.timeStamp = whiteList.TimeStamp;
+        }
+        else
+        {
+            Debug.Log(request.error);
+        }
 
     }
-   
     public GameManager GetGameManager() { return this; }
 }

+ 2 - 2
SFGgouhuo/Assets/Scripts/UI/Loading/DlgLogin.cs

@@ -39,7 +39,7 @@ namespace Assets
         public override void OnInitWindow()
         {
             GetMacAddress();
-            StartCoroutine(GetWhiteList());
+            whiteList = GameManager.Instance.whiteList;
             confirmBtn.onClick.AddListener(async () =>
             {
                 if (isVerify)
@@ -237,7 +237,7 @@ namespace Assets
     /// <summary>
     /// 白名单数据
     /// </summary>
-    struct WhiteList
+    public struct WhiteList
     {
         public string[] table;
         public string TimeStamp;