Cute_demon_attacks/meng_yao/Assets/script/Panel/AssestPanel.cs

78 lines
1.7 KiB
C#
Raw Normal View History

2024-10-30 21:49:13 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AssestPanel : MonoBehaviour
{
2024-11-05 14:29:51 +08:00
public bool is_one = false;
2024-10-30 21:49:13 +08:00
public Text Stone;
public Text Coin;
public Text Ore;
public Text Forging;
2024-10-31 16:50:35 +08:00
2024-10-30 21:49:13 +08:00
void Start()
{
2024-11-05 14:29:51 +08:00
2024-11-04 23:20:25 +08:00
2024-11-05 14:29:51 +08:00
if (Promptmgr.assestPanel == null)
{
Promptmgr.assestPanel = 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();
Promptmgr.assestPanel.is_one = true;
Promptmgr.assestPanel.InvokeRepeating("Tloding", 1.0f, 1.0f);
}
2024-11-03 21:08:15 +08:00
}
2024-11-02 11:19:48 +08:00
2024-11-05 14:29:51 +08:00
async void Tloding()
2024-11-02 11:19:48 +08:00
{
2024-10-31 16:50:35 +08:00
2024-11-03 01:08:39 +08:00
string userponse = await web.SendRequest(web.URL + "/Player/GetInfo", "POST");
2024-11-05 17:31:45 +08:00
Debug.Log(userponse.ToString());
2024-11-02 11:19:48 +08:00
infopyler res = JsonUtility.FromJson<infopyler>(userponse);
SetCoinText(res.Info.Gold);
SetStoneText(res.Info.Gem);
2024-11-05 17:31:45 +08:00
SetOreText(res.Info.Ore);
SetForgingText(res.Info.Forge);
2024-11-04 06:56:09 +08:00
2024-10-30 21:49:13 +08:00
}
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();
}
}
2024-10-31 16:50:35 +08:00
2024-11-04 06:56:09 +08:00
2024-10-30 21:49:13 +08:00
}