Cute_demon_attacks/meng_yao/Assets/communal/mount.cs
舒荣森 35c17756ee add
2024-10-31 20:16:46 +08:00

131 lines
4.2 KiB
C#
Raw Blame History

using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using static UnityEditor.PlayerSettings;
[System.Serializable]
public struct Register
{
public string Phone;
}
public struct AddGold
{
public int Gold;
}
public struct Login
{
public string Phone;
}
public struct GetListByPhone
{
public string Phone;
}
public class mount : MonoBehaviour
{
public static mount mountitem;
// Start is called before the first frame update
public virtual void Awake()
{
mountitem = this;
DontDestroyOnLoad(this);
//mountitem.login_screen();
}
[System.Serializable]
public class MyJsonData
{
public object list;
}
private async void Start()
{
string jsonString = "{\"list\":1.2333333}";
MyJsonData itemList = JsonUtility.FromJson<MyJsonData>(jsonString);
Debug.Log(itemList.list);
Debug.Log((float)itemList.list);
Debug.Log("======");
//AddGold AddGold = new AddGold();
//AddGold.Gold = 100;
//string jsonString1 = JsonUtility.ToJson(AddGold);
//string response_1 = await web.SendRequest(web.URL + "/Player/Login", "POST", jsonString1);
//de
//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);
//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");
//Debug.Log(response_2);
}
public GameObject add_pop_up(bool is_force = false)//<2F><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>
{
GameObject prefab = Resources.Load<GameObject>("preform/gui/pop_up_ui");
GameObject ranking_list_item = Instantiate(prefab, this.transform);
ranking_list_item.GetComponent<input_box_pop_up_window>().is_force = is_force;
return ranking_list_item;
}
//0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
//2 ȡ<><C8A1><EFBFBD><EFBFBD>ť ȷ<><C8B7><EFBFBD><EFBFBD>ť
//3 <20><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>item
//4 <20><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
public void login_screen()//ע<><D7A2><EFBFBD><EFBFBD><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 = 2});
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, <><D7A2>");//<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){
gameObject.GetComponent<input_box_pop_up_window>().destroy();
}
else if (type == 1){
Register register = new Register();
register.Phone = boxTypes[0].content;
//register.Code = boxTypes[0].content;
string jsonString = JsonUtility.ToJson(register);
string response = await web.SendRequest("http://47.109.133.52/Player/Register", "POST", jsonString);
Debug.Log(response);
}
});
}
}