79 lines
1.7 KiB
C#
79 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
public class AssestPanel : MonoBehaviour
|
|
{
|
|
public static AssestPanel instance;
|
|
|
|
public Text Stone;
|
|
public Text Coin;
|
|
public Text Ore;
|
|
public Text Forging;
|
|
|
|
|
|
void Start()
|
|
{
|
|
instance = this;
|
|
Stone.text = PlayerManager.Instance.Stones.ToString();
|
|
Forging.text=PlayerManager.Instance.Forging.ToString();
|
|
Coin.text=PlayerManager.Instance.Coins.ToString();
|
|
Ore.text=PlayerManager.Instance.Ore.ToString();
|
|
|
|
loding();
|
|
|
|
InvokeRepeating("ExecuteTask", 1.0f, 1.0f);
|
|
}
|
|
|
|
public async void loding()
|
|
{
|
|
Login login = new Login();
|
|
login.Phone = "1";
|
|
await web.SendRequest(web.URL + "/Player/Login", "POST", JsonUtility.ToJson(login));
|
|
|
|
}
|
|
|
|
async void ExecuteTask()
|
|
{
|
|
|
|
string userponse = await web.SendRequest(web.URL + "/Player/GetInfo", "POST");
|
|
//Debug.Log(userponse.ToString());
|
|
infopyler res = JsonUtility.FromJson<infopyler>(userponse);
|
|
SetCoinText(res.Info.Gold);
|
|
SetStoneText(res.Info.Gem);
|
|
|
|
}
|
|
|
|
public void SetStoneText(float num)
|
|
{
|
|
if (Stone!=null)
|
|
{
|
|
Stone.text=num.ToString();
|
|
}
|
|
|
|
}
|
|
public void SetCoinText(float num)
|
|
{
|
|
if (Coin != null)
|
|
{
|
|
Coin.text = num.ToString();
|
|
}
|
|
}
|
|
public void SetOreText(float num)
|
|
{
|
|
if (Ore != null)
|
|
{
|
|
Ore.text = num.ToString();
|
|
}
|
|
}
|
|
public void SetForgingText(float num)
|
|
{
|
|
if (Forging != null)
|
|
{
|
|
Forging.text = num.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
}
|