Shop ist jetzt funktional in der MainMenueScene
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Xml.Serialization;
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using Unity.VisualScripting.Antlr3.Runtime;
|
||||
using UnityEngine;
|
||||
using UnityEngine.U2D;
|
||||
|
||||
@@ -8,8 +9,9 @@ public class ShopScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject shopPanel;
|
||||
[SerializeField] GameObject errorPanel;
|
||||
[SerializeField] GameObject backgroundPanel;
|
||||
|
||||
private bool paymentSystemActive = false;
|
||||
[SerializeField]public bool paymentSystemActive = false;
|
||||
|
||||
//TMP_Text textfeld;
|
||||
[SerializeField] TMP_Text textfeld;
|
||||
@@ -32,12 +34,17 @@ public class ShopScript : MonoBehaviour
|
||||
[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<InventoryScript>();
|
||||
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
InventoryScript inventory = GetComponent<InventoryScript>();
|
||||
|
||||
shopPanel.SetActive(false);
|
||||
errorPanel.SetActive(false);
|
||||
@@ -50,9 +57,11 @@ public class ShopScript : MonoBehaviour
|
||||
{
|
||||
|
||||
textfeld.text = inventory.Gems.ToString();
|
||||
|
||||
textfeldA.text = inventory.Energy.ToString();
|
||||
textfeldB.text = inventory.Health.ToString();
|
||||
textfeldC.text = moneten.ToString();
|
||||
|
||||
|
||||
ShowDevMode();
|
||||
}
|
||||
|
||||
public void OpenShop()
|
||||
@@ -72,29 +81,57 @@ public class ShopScript : MonoBehaviour
|
||||
|
||||
public void AddLife()
|
||||
{
|
||||
inventory.Health++;
|
||||
|
||||
if (inventory.Gems - updateCost < 0)
|
||||
{
|
||||
errorText.text = "Not enough gems!";
|
||||
}
|
||||
|
||||
inventory.Gems -= updateCost;
|
||||
else
|
||||
{
|
||||
inventory.Health++;
|
||||
|
||||
inventory.Gems -= updateCost;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddEnergy()
|
||||
{
|
||||
inventory.Energy++;
|
||||
if (inventory.Gems - updateCost <0)
|
||||
{
|
||||
errorText.text = "Not enough gems!";
|
||||
}
|
||||
|
||||
inventory.Gems -= updateCost;
|
||||
else
|
||||
{
|
||||
inventory.Energy++;
|
||||
|
||||
inventory.Gems -= updateCost;
|
||||
}
|
||||
}
|
||||
|
||||
public void BuyGems()
|
||||
{
|
||||
if (paymentSystemActive)
|
||||
{
|
||||
moneten -= gemsCost;
|
||||
Debug.Log("Ich mag Moeneten");
|
||||
|
||||
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!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,13 +140,23 @@ public class ShopScript : MonoBehaviour
|
||||
|
||||
if (paymentSystemActive)
|
||||
{
|
||||
moneten -= manyGemsCost;
|
||||
Debug.Log("Ich mag Moeneten");
|
||||
}
|
||||
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!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,26 +168,26 @@ public class ShopScript : MonoBehaviour
|
||||
//textfeldB = textB;
|
||||
//textfeldC = textC;
|
||||
|
||||
textfeldA.text = inventory.Energy.ToString();
|
||||
textfeldB.text = inventory.Health.ToString();
|
||||
textfeldC.text = moneten.ToString();
|
||||
//textfeldA.text = inventory.Energy.ToString();
|
||||
//textfeldB.text = inventory.Health.ToString();
|
||||
//textfeldC.text = moneten.ToString();
|
||||
}
|
||||
|
||||
public void ChangeActivation()
|
||||
{
|
||||
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
|
||||
if (paymentSystemActive)
|
||||
if (!paymentSystemActive)
|
||||
{
|
||||
paymentSystemActive = false;
|
||||
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("T_11_no.png");
|
||||
paymentSystemActive = true;
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("T_12_ok.png");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
paymentSystemActive = true;
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("T_12_ok.png");
|
||||
paymentSystemActive = false;
|
||||
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("T_11_no.png");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class InventoryScript : MonoBehaviour
|
||||
[SerializeField] int health = 1;
|
||||
|
||||
//Gems
|
||||
[SerializeField] int gems;
|
||||
[SerializeField] int gems = 100;
|
||||
|
||||
|
||||
public InventoryScript(int energy, int health, int gems)
|
||||
@@ -25,7 +25,7 @@ public class InventoryScript : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
Gems = 10;
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
Reference in New Issue
Block a user