using System.Xml.Serialization; using TMPro; using Unity.VisualScripting; using Unity.VisualScripting.Antlr3.Runtime; using UnityEngine; using UnityEngine.U2D; public class ShopScript : MonoBehaviour { [SerializeField] GameObject shopPanel; [SerializeField] GameObject errorPanel; [SerializeField] GameObject backgroundPanel; [SerializeField]public bool paymentSystemActive = false; //TMP_Text textfeld; [SerializeField] TMP_Text textfeld; InventoryScript inventory; private float moneten = 1000; //als vorerstiger Ersatz für tatsächliches Geld private int gemsCost = 100; //1€ private int manyGemsCost = 200; //2€ private int updateCost = 100; #region DevMode [SerializeField] GameObject devPanel; //TMP_Text textfeldA; //als textfeld //TMP_Text textfeldB; //TMP_Text textfeldC; [SerializeField] TMP_Text textfeldA; //als text [SerializeField] TMP_Text textfeldB; [SerializeField] TMP_Text textfeldC; [SerializeField] TMP_Text errorText; #endregion private void Awake() { inventory = backgroundPanel.GetComponent(); } void Start() { shopPanel.SetActive(false); errorPanel.SetActive(false); devPanel.SetActive(false); //textfeld = this.text; } void Update() { textfeld.text = inventory.Gems.ToString(); textfeldA.text = inventory.Energy.ToString(); textfeldB.text = inventory.Health.ToString(); textfeldC.text = moneten.ToString(); } public void OpenShop() { shopPanel.SetActive(true); } public void CloseShop() { shopPanel.SetActive(false); } public void ClosePanel() { errorPanel.SetActive(false); } public void AddLife() { if (inventory.Gems - updateCost < 0) { errorText.text = "Not enough gems!"; } else { inventory.Health++; inventory.Gems -= updateCost; } } public void AddEnergy() { if (inventory.Gems - updateCost <0) { errorText.text = "Not enough gems!"; } else { inventory.Energy++; inventory.Gems -= updateCost; } } public void BuyGems() { if (paymentSystemActive) { if (moneten - gemsCost <= 0) { errorText.text = "Payment System inactive!"; } else { moneten -= gemsCost; Debug.Log("Ich mag Moeneten"); inventory.Gems += 100; } } else { errorPanel.SetActive(true); errorText.text = "Payment System inactive!"; } } public void BuyMore() { if (paymentSystemActive) { if (moneten - manyGemsCost <= 0) { errorText.text = "Payment System inactive!"; } else { moneten -= manyGemsCost; Debug.Log("Ich mag Moeneten"); inventory.Gems += 200; } } else { errorPanel.SetActive(true); errorText.text = "Payment System inactive!"; } } public void ShowDevMode() { devPanel.SetActive(true); //textfeldA = textA; //textfeldB = textB; //textfeldC = textC; //textfeldA.text = inventory.Energy.ToString(); //textfeldB.text = inventory.Health.ToString(); //textfeldC.text = moneten.ToString(); } public void ChangeActivation() { SpriteRenderer spriteRenderer = GetComponent(); if (!paymentSystemActive) { paymentSystemActive = true; spriteRenderer.sprite = Resources.Load("T_12_ok.png"); } else { paymentSystemActive = false; spriteRenderer.sprite = Resources.Load("T_11_no.png"); } } public void CloseDevPanel() { devPanel.SetActive(false); } }