using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AssestPanel : MonoBehaviour { public bool is_one = false; public Text Stone; public Text Coin; public Text Ore; public Text Forging; public Button StoneBtn; public Button CoinBtn; public Button OreBtn; public Button ForgingBtn; public GameObject AssetDetails; void Start() { 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); } AssetDetails.gameObject.SetActive(false); StoneBtn.onClick.AddListener(AsClick); CoinBtn.onClick.AddListener(AsClick); OreBtn.onClick.AddListener(AsClick); ForgingBtn.onClick.AddListener(AsClick); } private void AsClick() { Debug.Log("点击资产明细按钮"); AssetDetails.gameObject.SetActive(true); } public void CloseClick() { AssetDetails.gameObject.SetActive(false); } async void Tloding() { //string userponse = await web.SendRequest(web.URL + "/Player/GetInfo", "POST"); // Debug.Log(userponse.ToString()); // infopyler res = JsonUtility.FromJson(userponse); // SetCoinText(res.Info.Gold); // SetStoneText(res.Info.Gem); // SetOreText(res.Info.Ore); // SetForgingText(res.Info.Forge); } 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(); } } private void Update() { Stone.text = PlayerManager.Instance.Stones.ToString(); Coin.text = PlayerManager.Instance.Coins.ToString(); Ore.text = PlayerManager.Instance.Ore.ToString(); Forging.text = PlayerManager.Instance.Forging.ToString(); } }