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

86 lines
1.7 KiB
C#
Raw Normal View History

2024-10-31 16:50:35 +08:00
using System;
2024-10-31 02:49:53 +08:00
using System.Collections;
using System.Collections.Generic;
2024-10-31 20:40:09 +08:00
using UnityEditor.Hardware;
using UnityEditorInternal.VersionControl;
2024-10-31 02:49:53 +08:00
using UnityEngine;
2024-10-31 16:50:35 +08:00
using UnityEngine.UI;
2024-10-31 02:49:53 +08:00
public class InitInfo : MonoBehaviour
{
2024-10-31 16:50:35 +08:00
private MainObject parsedData;
2024-10-31 20:40:09 +08:00
private Username userdata;
2024-10-31 02:49:53 +08:00
2024-10-31 16:50:35 +08:00
public Text name;
2024-10-31 02:49:53 +08:00
// Start is called before the first frame update
2024-10-31 16:50:35 +08:00
private async void Start()
2024-10-31 02:49:53 +08:00
{
2024-10-31 16:50:35 +08:00
string response = await web.SendRequest("http://47.109.133.52/Player/GetInfo", "POST");
2024-10-31 02:49:53 +08:00
Debug.Log(response);
2024-10-31 16:50:35 +08:00
parsedData = JsonUtility.FromJson<MainObject>(response);
Debug.Log(parsedData.Info.Gold);
AssestPanel.instance.SetCoinText(parsedData.Info.Gold);
AssestPanel.instance.SetStoneText(parsedData.Info.Gem);
GetListByPhone getlistbyphone = new GetListByPhone();
getlistbyphone.Phone = "1";
string jsonString = JsonUtility.ToJson(getlistbyphone);
string userponse = await web.SendRequest("http://47.109.133.52/Player/GetListByPhone", "POST", jsonString);
Debug.Log(userponse);
2024-10-31 20:40:09 +08:00
userdata = JsonUtility.FromJson<Username>(userponse);
Debug.Log(userdata.ErrorCode);
2024-10-31 16:50:35 +08:00
2024-10-31 20:40:09 +08:00
//name.text=userdata.nameitem.Name;
2024-10-31 02:49:53 +08:00
}
// Update is called once per frame
void Update()
{
2024-10-31 16:50:35 +08:00
}
2024-10-31 02:49:53 +08:00
2024-10-31 16:50:35 +08:00
}
public class MainObject
2024-10-31 02:49:53 +08:00
{
2024-10-31 16:50:35 +08:00
public Info Info;
public int ErrorCode;
public string ErrorMessage;
2024-10-31 02:49:53 +08:00
}
2024-10-31 16:50:35 +08:00
[Serializable]
public class Info
2024-10-31 02:49:53 +08:00
{
2024-10-31 16:50:35 +08:00
public string Id;
2024-10-31 02:49:53 +08:00
public int Gold;
2024-10-31 16:50:35 +08:00
public int Gem;
public string Phone;
public string Name;
2024-10-31 02:49:53 +08:00
}
2024-10-31 20:40:09 +08:00
public class Username
2024-10-31 02:49:53 +08:00
{
2024-10-31 20:40:09 +08:00
public List<nameitem> namelist;
public int ErrorCode;
public string ErrorMessage;
2024-10-31 02:49:53 +08:00
}
2024-10-31 20:40:09 +08:00
public class nameitem
2024-10-31 02:49:53 +08:00
{
2024-10-31 16:50:35 +08:00
public string Id;
2024-10-31 20:40:09 +08:00
public string Phone;
2024-10-31 16:50:35 +08:00
public string Name;
2024-10-31 02:49:53 +08:00
}
2024-10-31 16:50:35 +08:00