Cute_demon_attacks/meng_yao/Assets/script/scene_Main/AssetsPanel.cs
wulongxiao dcf050a2ea add
2024-11-14 17:18:51 +08:00

106 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AssetsPanel : MonoBehaviour
{
[Header("按钮,记得对应关系")]
public Button but1;
public Button but2;
public Button but3;
public Button but4;
[Header("按下按钮显示的panel目前是同一个")]
public GameObject mygameObject;
public bool is_one = false;
public Text Stone;
public Text Coin;
public Text Ore;
public Text Forging;
// Start is called before the first frame update
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;
}
if (but1 != null)
{
but1.onClick.AddListener(() => {
mygameObject.SetActive(true);
});
}
if (but2 != null)
{
but2.onClick.AddListener(() => {
mygameObject.SetActive(true);
});
}
if (but3 != null)
{
but3.onClick.AddListener(() => {
mygameObject.SetActive(true);
});
}
if (but4 != null)
{
but4.onClick.AddListener(() => {
mygameObject.SetActive(true);
});
}
}
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();
}
}