Weitergebaut an Shop, LeanTween eingebaut
This commit is contained in:
@@ -3,10 +3,13 @@ using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using Unity.VisualScripting.Antlr3.Runtime;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.VirtualTexturing;
|
||||
using UnityEngine.U2D;
|
||||
|
||||
public class ShopScript : MonoBehaviour
|
||||
{
|
||||
[Header("Panels")]
|
||||
|
||||
[SerializeField] GameObject shopPanel;
|
||||
[SerializeField] GameObject errorPanel;
|
||||
[SerializeField] GameObject backgroundPanel;
|
||||
@@ -17,13 +20,16 @@ public class ShopScript : MonoBehaviour
|
||||
[SerializeField] TMP_Text textfeld;
|
||||
InventoryScript inventory;
|
||||
|
||||
private float moneten = 1000; //als vorerstiger Ersatz für tatsächliches Geld
|
||||
private float moneten = 10.00f; //als vorerstiger Ersatz für tatsächliches Geld
|
||||
|
||||
private int gemsCost = 100; //1€
|
||||
private int manyGemsCost = 200; //2€
|
||||
private float gemsCost = 1.00f; //1€
|
||||
private float manyGemsCost = 2.00f; //2€
|
||||
private int updateCost = 100;
|
||||
|
||||
private float duration = 4f;
|
||||
|
||||
#region DevMode
|
||||
[Header("DevMode")]
|
||||
|
||||
[SerializeField] GameObject devPanel;
|
||||
|
||||
@@ -35,7 +41,13 @@ public class ShopScript : MonoBehaviour
|
||||
[SerializeField] TMP_Text textfeldB;
|
||||
[SerializeField] TMP_Text textfeldC;
|
||||
[SerializeField] TMP_Text errorText;
|
||||
|
||||
|
||||
[Header("ShopTextfieldCost")]
|
||||
|
||||
[SerializeField] TMP_Text healthCost;
|
||||
[SerializeField] TMP_Text energyCost;
|
||||
[SerializeField] TMP_Text gemCost;
|
||||
[SerializeField] TMP_Text moreGemsCost;
|
||||
|
||||
#endregion
|
||||
private void Awake()
|
||||
@@ -50,6 +62,11 @@ public class ShopScript : MonoBehaviour
|
||||
errorPanel.SetActive(false);
|
||||
devPanel.SetActive(false);
|
||||
|
||||
healthCost.text = updateCost.ToString();
|
||||
energyCost.text = updateCost.ToString();
|
||||
gemCost.text = gemsCost.ToString() + " €";
|
||||
moreGemsCost.text = manyGemsCost.ToString() + " €";
|
||||
|
||||
//textfeld = this.text;
|
||||
}
|
||||
|
||||
@@ -58,24 +75,28 @@ public class ShopScript : MonoBehaviour
|
||||
|
||||
textfeld.text = inventory.Gems.ToString();
|
||||
|
||||
textfeldA.text = inventory.Energy.ToString();
|
||||
textfeldB.text = inventory.Health.ToString();
|
||||
textfeldC.text = moneten.ToString();
|
||||
textfeldA.text = "Energy: " + inventory.Energy.ToString();
|
||||
textfeldB.text = "Health: " + inventory.Health.ToString();
|
||||
textfeldC.text = "Moneten: " + moneten.ToString();
|
||||
|
||||
}
|
||||
|
||||
public void OpenShop()
|
||||
{
|
||||
shopPanel.SetActive(true);
|
||||
LeanTween.scale(shopPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
|
||||
}
|
||||
|
||||
public void CloseShop()
|
||||
{
|
||||
LeanTween.scale(shopPanel, transform.localScale * 0f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
shopPanel.SetActive(false);
|
||||
}
|
||||
|
||||
public void ClosePanel()
|
||||
{
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
errorPanel.SetActive(false);
|
||||
}
|
||||
|
||||
@@ -84,7 +105,9 @@ public class ShopScript : MonoBehaviour
|
||||
|
||||
if (inventory.Gems - updateCost < 0)
|
||||
{
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "Not enough gems!";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -99,7 +122,9 @@ public class ShopScript : MonoBehaviour
|
||||
{
|
||||
if (inventory.Gems - updateCost <0)
|
||||
{
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "Not enough gems!";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -115,9 +140,11 @@ public class ShopScript : MonoBehaviour
|
||||
if (paymentSystemActive)
|
||||
{
|
||||
|
||||
if (moneten - gemsCost <= 0)
|
||||
if (moneten - gemsCost < 0)
|
||||
{
|
||||
errorText.text = "Payment System inactive!";
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "Your card is empty!";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -132,6 +159,7 @@ public class ShopScript : MonoBehaviour
|
||||
{
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "Payment System inactive!";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,9 +168,11 @@ public class ShopScript : MonoBehaviour
|
||||
|
||||
if (paymentSystemActive)
|
||||
{
|
||||
if (moneten - manyGemsCost <= 0)
|
||||
if (moneten - manyGemsCost < 0)
|
||||
{
|
||||
errorText.text = "Payment System inactive!";
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "Your card is empty!";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -157,12 +187,14 @@ public class ShopScript : MonoBehaviour
|
||||
{
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "Payment System inactive!";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowDevMode()
|
||||
{
|
||||
devPanel.SetActive(true);
|
||||
LeanTween.scale(devPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
|
||||
//textfeldA = textA;
|
||||
//textfeldB = textB;
|
||||
@@ -181,6 +213,11 @@ public class ShopScript : MonoBehaviour
|
||||
{
|
||||
paymentSystemActive = true;
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("T_12_ok.png");
|
||||
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "PaymentSystem active";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
@@ -189,11 +226,18 @@ public class ShopScript : MonoBehaviour
|
||||
|
||||
spriteRenderer.sprite = Resources.Load<Sprite>("T_11_no.png");
|
||||
|
||||
errorPanel.SetActive(true);
|
||||
errorText.text = "PaymentSystem inactive!";
|
||||
LeanTween.scale(errorPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseDevPanel()
|
||||
{
|
||||
LeanTween.scale(devPanel, transform.localScale * 0f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
|
||||
devPanel.SetActive(false);
|
||||
|
||||
ClosePanel();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user