From 228192a5c1bdd08cfeb53b04b470460075411409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=92=E8=8D=A3=E6=A3=AE?= <7716842+shurongsen@user.noreply.gitee.com> Date: Wed, 30 Oct 2024 22:03:04 +0800 Subject: [PATCH] add --- meng_yao/Assets/Scenes/loading.unity | 110 +++++++++++++++++- meng_yao/Assets/communal/mount.cs | 20 +++- meng_yao/Assets/communal/web/web.cs | 4 + .../Assets/script/ConnactServer/Logo_in.cs | 82 +++++++++++-- 4 files changed, 195 insertions(+), 21 deletions(-) diff --git a/meng_yao/Assets/Scenes/loading.unity b/meng_yao/Assets/Scenes/loading.unity index db2e98a4c..7eac41c4b 100644 --- a/meng_yao/Assets/Scenes/loading.unity +++ b/meng_yao/Assets/Scenes/loading.unity @@ -122,6 +122,107 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1001 &107147069 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_Pivot.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_Pivot.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166433, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166437, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_Name + value: pop + objectReference: {fileID: 0} + - target: {fileID: 1125018133084166437, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 4d328a61046e1d2498391895fd2c11d7, type: 3} --- !u!1 &111255128 GameObject: m_ObjectHideFlags: 0 @@ -467,7 +568,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &603807337 MonoBehaviour: m_ObjectHideFlags: 0 @@ -894,6 +995,7 @@ MonoBehaviour: m_EditorClassIdentifier: sceneslider: {fileID: 2057344806} logo_inbtn: {fileID: 603807337} + loadSpeed: 0.5 --- !u!1 &1348751385 GameObject: m_ObjectHideFlags: 0 @@ -1344,7 +1446,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 10, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1980015289 MonoBehaviour: @@ -1366,8 +1468,8 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 80ac668eebc18274da102d1113d48c44, type: 3} - m_Type: 1 + m_Sprite: {fileID: 21300000, guid: b7d0b95aa29194545b1bad8da63bea19, type: 3} + m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 m_FillMethod: 0 diff --git a/meng_yao/Assets/communal/mount.cs b/meng_yao/Assets/communal/mount.cs index a1070131d..f2c3c89d8 100644 --- a/meng_yao/Assets/communal/mount.cs +++ b/meng_yao/Assets/communal/mount.cs @@ -16,6 +16,11 @@ public struct AddGold public int Gold; } +public struct Login +{ + public string Phone; +} + public class mount : MonoBehaviour { @@ -42,14 +47,17 @@ public class mount : MonoBehaviour + //Login register = new Login(); + //register.phonenumble = "13667637952"; + //string jsonString = JsonUtility.ToJson(register); + //string response_1 = await web.SendRequest("http://47.109.133.52/Player/Login", "POST", jsonString); + //Register register = new Register(); + //register.Phone = "13667637952"; + //string jsonString = JsonUtility.ToJson(register); - Register register = new Register(); - register.Phone = "13667637952"; - string jsonString = JsonUtility.ToJson(register); - - string response_1 = await web.SendRequest("http://47.109.133.52/Player/Login", "POST", jsonString); - Debug.Log(response_1); + //string response_1 = await web.SendRequest("http://47.109.133.52/Player/Login", "POST", jsonString); + //Debug.Log(response_1); //string response_2 = await web.SendRequest("http://47.109.133.52/MinerElf/GetList", "POST"); diff --git a/meng_yao/Assets/communal/web/web.cs b/meng_yao/Assets/communal/web/web.cs index a4f7e0031..d4a6cadc9 100644 --- a/meng_yao/Assets/communal/web/web.cs +++ b/meng_yao/Assets/communal/web/web.cs @@ -51,10 +51,14 @@ public class web : MonoBehaviour } else { + // 处理返回的Cookie string setCookieHeader; + string str = request.downloadHandler.text; + Debug.Log(str); if (request.GetResponseHeaders().TryGetValue("Set-Cookie", out setCookieHeader)) { + string[] cookies = setCookieHeader.Split(';'); foreach (var cookie in cookies) { diff --git a/meng_yao/Assets/script/ConnactServer/Logo_in.cs b/meng_yao/Assets/script/ConnactServer/Logo_in.cs index cec0e046f..e2e1301d5 100644 --- a/meng_yao/Assets/script/ConnactServer/Logo_in.cs +++ b/meng_yao/Assets/script/ConnactServer/Logo_in.cs @@ -2,32 +2,38 @@ using System.Collections; using System.Collections.Generic; using System.Net.NetworkInformation; using UnityEngine; +using UnityEngine.SceneManagement; using UnityEngine.UI; -public struct Login -{ - public string phonenumble; -} + public class Logo_in : mount { public Slider sceneslider; public Button logo_inbtn; + public float loadSpeed = 0.5f; // 填充速度 + private float progress = 0f; + private bool isLoading = false; + // Start is called before the first frame update void Start() { //sceneslider.gameObject.SetActive(false); //logo_inbtn.onClick.AddListener(ShowLogoin); + if (sceneslider != null) + { + sceneslider.value = 0f; // 初始值设为0 + } + login_in_screen(); + + } - void ShowLogoin() - { - login_in_screen(); - } + public void login_in_screen()//登录界面 @@ -54,7 +60,7 @@ public class Logo_in : mount if (type == 0)//注册 { Login login = new Login(); - login.phonenumble = boxTypes[0].prompt; + login.Phone = boxTypes[0].content; //register.Code = boxTypes[0].content; string jsonString = JsonUtility.ToJson(login); string response = await web.SendRequest("http://47.109.133.52/Player/Register", "POST", jsonString); @@ -63,12 +69,26 @@ public class Logo_in : mount else if (type == 1)//登录 { Login login = new Login(); - login.phonenumble = boxTypes[0].prompt; + login.Phone = boxTypes[0].content; //register.Code = boxTypes[0].content; string jsonString = JsonUtility.ToJson(login); string response = await web.SendRequest("http://47.109.133.52/Player/Login", "POST", jsonString); Debug.Log(response); + Rootobject root = JsonUtility.FromJson(response); + + Debug.Log(root.ErrorMessage); + if (root.ErrorMessage =="") + { + gameObject.SetActive(false); + Promptmgr.Instance.PromptBubble("登录成功"); + isLoading = true; + } + else + { + Promptmgr.Instance.PromptBubble("登录失败,请先注册"); + } + } }); @@ -78,6 +98,46 @@ public class Logo_in : mount // Update is called once per frame void Update() { - + // 模拟进度条填充,可以改为你的实际加载逻辑 + if (isLoading && progress < 1f) + { + progress += loadSpeed * Time.deltaTime; + sceneslider.value = progress; + } + + // 当进度条填满后,进行场景跳转 + if (progress >= 1f && isLoading) + { + LoadNextScene(); + } + } + + private void LoadNextScene() + { + // 这里使用场景管理器进行跳转 + SceneManager.LoadScene(JumpScene.main_scene); + GameObject.Destroy(this.gameObject); + } + + + +} + +public class Rootobject +{ + public int ErrorCode; + public string ErrorMessage; + +} + + +public class JsonParser +{ + public static Rootobject ParseJson(string json) + { + return JsonUtility.FromJson(json); } } + + +