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

137 lines
2.8 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:16:46 +08:00
using Unity.VisualScripting;
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:16:46 +08:00
2024-10-31 02:49:53 +08:00
2024-10-31 16:50:35 +08:00
public Text name;
2024-10-31 20:16:46 +08:00
public Text userid;
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);
2024-10-31 20:16:46 +08:00
//name.text = parsedData.Info.Name;
//userid.text = "id :" + parsedData.Info.Id;
2024-10-31 16:50:35 +08:00
GetListByPhone getlistbyphone = new GetListByPhone();
getlistbyphone.Phone = "1";
string jsonString = JsonUtility.ToJson(getlistbyphone);
2024-10-31 20:16:46 +08:00
2024-10-31 16:50:35 +08:00
string userponse = await web.SendRequest("http://47.109.133.52/Player/GetListByPhone", "POST", jsonString);
2024-10-31 20:16:46 +08:00
2024-10-31 16:50:35 +08:00
Debug.Log(userponse);
2024-10-31 20:16:46 +08:00
//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<73><74>");
//Debug.Log(rootData.);
}
// Debug.Log(rootData.Info.Id);
2024-10-31 16:50:35 +08:00
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:16:46 +08:00
[System.Serializable]
public class PlayerData
2024-10-31 02:49:53 +08:00
{
2024-10-31 20:16:46 +08:00
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;
2024-10-31 02:49:53 +08:00
}
2024-10-31 20:16:46 +08:00
[Serializable]
public class InfoData
2024-10-31 02:49:53 +08:00
{
2024-10-31 16:50:35 +08:00
public string Id;
public string Name;
2024-10-31 20:16:46 +08:00
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;
2024-10-31 02:49:53 +08:00
}
2024-10-31 16:50:35 +08:00