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

137 lines
2.8 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class InitInfo : MonoBehaviour
{
private MainObject parsedData;
public Text name;
public Text userid;
// Start is called before the first frame update
private async void Start()
{
string response = await web.SendRequest("http://47.109.133.52/Player/GetInfo", "POST");
Debug.Log(response);
parsedData = JsonUtility.FromJson<MainObject>(response);
Debug.Log(parsedData.Info.Gold);
AssestPanel.instance.SetCoinText(parsedData.Info.Gold);
AssestPanel.instance.SetStoneText(parsedData.Info.Gem);
//name.text = parsedData.Info.Name;
//userid.text = "id :" + parsedData.Info.Id;
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);
//RootData RootData = LitJson.JsonMapper.ToObject<RootData>(userponse);
RootData itemList = JsonUtility.FromJson<RootData>(userponse);
Debug.Log(itemList.List[0].Gold);
if (itemList.List == null)
{
Debug.Log("list¿Õ");
//Debug.Log(rootData.);
}
// Debug.Log(rootData.Info.Id);
}
// Update is called once per frame
void Update()
{
}
}
public class MainObject
{
public Info Info;
public int ErrorCode;
public string ErrorMessage;
}
[Serializable]
public class Info
{
public string Id;
public int Gold;
public int Gem;
public string Phone;
public string Name;
}
[System.Serializable]
public class PlayerData
{
public string Id;
public object IslandId;
public object IsLocked;
public object IsCanceled;
public string Phone;
public string Name;
public object Level;
public object Referrer;
public object Referrals;
public float Gold;
public object Gem;
public object Ore;
public object Forge;
public object FirstBlood;
public object LoginCount;
public object TeamLevel;
public object Contribution;
public object Stamina;
public object TreeLevel;
public object TreeExp;
public object Water;
public object CreateDateTime;
}
[Serializable]
public class InfoData
{
public string Id;
public string Name;
public float Gold;
public int Gem;
public int Forge;
public int Water;
public int Level;
}
[System.Serializable]
public class RootData
{
public PlayerData[] List;
public object Info ;
public int Stamina;
public int Count;
public int ErrorCode;
public string ErrorMessage;
}