Cute_demon_attacks/meng_yao/Assets/script/ConnactServer/Logo_in.cs

156 lines
4.5 KiB
C#
Raw Normal View History

2024-10-30 19:42:59 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using UnityEngine;
2024-10-30 22:03:04 +08:00
using UnityEngine.SceneManagement;
2024-10-30 19:42:59 +08:00
using UnityEngine.UI;
2024-10-30 22:03:04 +08:00
2024-10-30 19:42:59 +08:00
public class Logo_in : mount
{
public Slider sceneslider;
public Button logo_inbtn;
2024-10-30 22:03:04 +08:00
public float loadSpeed = 0.5f; // <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
private float progress = 0f;
private bool isLoading = false;
2024-10-31 13:27:31 +08:00
public override void Awake()
{
}
2024-10-30 19:42:59 +08:00
// Start is called before the first frame update
void Start()
{
//sceneslider.gameObject.SetActive(false);
//logo_inbtn.onClick.AddListener(ShowLogoin);
2024-10-30 22:03:04 +08:00
if (sceneslider != null)
{
sceneslider.value = 0f; // <20><>ʼֵ<CABC><D6B5>Ϊ0
}
2024-10-30 19:42:59 +08:00
login_in_screen();
2024-10-30 22:03:04 +08:00
2024-10-30 19:42:59 +08:00
}
2024-10-30 22:03:04 +08:00
2024-10-30 19:42:59 +08:00
public void login_in_screen()//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
{
List<BoxType> boxTypes = new List<BoxType>();
boxTypes.Add(new BoxType { Name = "account_number", textName = " <20>ֻ<EFBFBD><D6BB><EFBFBD>", prompt = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>", Type = 1, is_required = true });
boxTypes.Add(new BoxType { Name = "verification_code", textName = " <20><>֤<EFBFBD><D6A4>", prompt = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>", Type = 0, is_required = true });
boxTypes.Add(new BoxType { Name = "submit", textName = " ȡ<><C8A1>ȷ<EFBFBD><C8B7> ", Type = 5 });
2024-11-05 14:29:51 +08:00
boxTypes.Add(new BoxType { Name = "submit", textName = " ȡ<><C8A1>ȷ<EFBFBD><C8B7> ", Type = 11 });
2024-10-30 19:42:59 +08:00
GameObject gameObject = add_pop_up(true);//<2F><><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>ĸ<EFBFBD><C4B8>
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "<22><>¼");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
//gameObjects[0].GetComponent<input_box_pop_up_window_item>().register_click((BoxType boxType, int type) =>//<2F>ֻ<EFBFBD><D6BB>Ż<EFBFBD>ȡ<EFBFBD><C8A1>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//{
// if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content))
// {
// Promptmgr.Instance.PromptBubble("<22>벻Ҫ" + boxType.textName + "Ϊ<><CEAA>");
// return;
// }
// Debug.Log("<22><>ȡ<EFBFBD><C8A1>֤<EFBFBD><D6A4>");
//});
gameObjects[2].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//<2F><>¼ȷ<C2BC><C8B7><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
{
if (type == 0)//ע<><D7A2>
{
Login login = new Login();
2024-10-30 22:03:04 +08:00
login.Phone = boxTypes[0].content;
2024-10-30 19:42:59 +08:00
//register.Code = boxTypes[0].content;
string jsonString = JsonUtility.ToJson(login);
2024-11-03 19:07:13 +08:00
string response = await web.SendRequest(web.URL+"/Player/Register", "POST", jsonString);
2024-10-30 19:42:59 +08:00
Debug.Log(response);
}
else if (type == 1)//<2F><>¼
{
Login login = new Login();
2024-10-30 22:03:04 +08:00
login.Phone = boxTypes[0].content;
2024-10-31 13:27:31 +08:00
Debug.Log(boxTypes[0].content);
2024-10-30 19:42:59 +08:00
//register.Code = boxTypes[0].content;
string jsonString = JsonUtility.ToJson(login);
2024-11-03 19:07:13 +08:00
string response = await web.SendRequest(web.URL+"/Player/Login", "POST", jsonString);
2024-10-30 19:42:59 +08:00
Debug.Log(response);
2024-11-03 15:09:40 +08:00
2024-10-30 22:03:04 +08:00
Rootobject root = JsonUtility.FromJson<Rootobject>(response);
2024-10-31 01:19:19 +08:00
2024-10-31 16:50:35 +08:00
if (root.ErrorMessage=="" && boxTypes[0].content!= "")
2024-10-30 22:03:04 +08:00
{
gameObject.SetActive(false);
Promptmgr.Instance.PromptBubble("<22><>¼<EFBFBD>ɹ<EFBFBD>");
isLoading = true;
}
else
{
Promptmgr.Instance.PromptBubble("<22><>¼ʧ<C2BC><CAA7>,<2C><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>");
}
2024-10-30 19:42:59 +08:00
}
});
2024-11-05 14:29:51 +08:00
gameObjects[3].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//<2F><>¼ȷ<C2BC><C8B7><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
{
gameObject.SetActive(false);
Promptmgr.Instance.PromptBubble("<22><>¼<EFBFBD>ɹ<EFBFBD>");
isLoading = true;
});
2024-10-30 19:42:59 +08:00
}
// Update is called once per frame
void Update()
{
2024-10-30 22:03:04 +08:00
// ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4A3AC><EFBFBD>Ը<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ʵ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>߼<EFBFBD>
if (isLoading && progress < 1f)
{
progress += loadSpeed * Time.deltaTime;
sceneslider.value = progress;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󣬽<EFBFBD><F3A3ACBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>ת
if (progress >= 1f && isLoading)
{
LoadNextScene();
}
}
private void LoadNextScene()
{
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
SceneManager.LoadScene(JumpScene.main_scene);
2024-10-30 19:42:59 +08:00
}
2024-10-30 22:03:04 +08:00
2024-10-30 23:18:31 +08:00
2024-10-30 22:03:04 +08:00
2024-10-30 19:42:59 +08:00
}
2024-10-30 22:03:04 +08:00
public class Rootobject
{
public int ErrorCode;
public string ErrorMessage;
}
public class JsonParser
{
public static Rootobject ParseJson(string json)
{
return JsonUtility.FromJson<Rootobject>(json);
}
}