Health and Energy Logic ausgeführt, GameOver und LevelTime Scripte angelegt, Timer (aber keinen krassen coolen) eingebaut
This commit is contained in:
File diff suppressed because it is too large
Load Diff
82
Assets/Scripts/Button Functions/GameOver.cs
Normal file
82
Assets/Scripts/Button Functions/GameOver.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
using static UnityEngine.Rendering.DebugUI;
|
||||||
|
|
||||||
|
public class GameOver : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("UI and HUB")]
|
||||||
|
|
||||||
|
[SerializeField] GameObject deathPanel;
|
||||||
|
private float duration = 4f;
|
||||||
|
[SerializeField] float timer;
|
||||||
|
[SerializeField] TMP_Text deathTime;
|
||||||
|
[SerializeField] bool recentDeath;
|
||||||
|
|
||||||
|
[Header("ScriptPile")]
|
||||||
|
|
||||||
|
[SerializeField] GameObject scriptPile;
|
||||||
|
|
||||||
|
|
||||||
|
InventoryScript inventory;
|
||||||
|
ChangeHealth healthScript;
|
||||||
|
HandleEnergy battery;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
inventory = scriptPile.GetComponent<InventoryScript>();
|
||||||
|
healthScript = scriptPile.GetComponent<ChangeHealth>();
|
||||||
|
battery = scriptPile.GetComponent<HandleEnergy>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
deathPanel.SetActive(false);
|
||||||
|
recentDeath = true;
|
||||||
|
timer = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (recentDeath)
|
||||||
|
{
|
||||||
|
deathTime.text = Convert.ToInt32(timer -= Time.deltaTime).ToString();
|
||||||
|
|
||||||
|
if(timer >= 0)
|
||||||
|
{
|
||||||
|
StopBothering();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StopBothering();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowDeathScreen()
|
||||||
|
{
|
||||||
|
deathPanel.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void StopBothering()
|
||||||
|
{
|
||||||
|
recentDeath = false;
|
||||||
|
Time.timeScale = 1; //UNSICHER OB LAden VON SCENE DEN WERT AUTO. AUF 1 SETZT
|
||||||
|
SceneManager.LoadSceneAsync(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void NewChance()
|
||||||
|
{
|
||||||
|
inventory.Health = healthScript.standardHealth;
|
||||||
|
|
||||||
|
if (battery.standardEnergy <= (inventory.Energy + battery.addEnergyValue))
|
||||||
|
{
|
||||||
|
inventory.Energy += battery.addEnergyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Button Functions/GameOver.cs.meta
Normal file
2
Assets/Scripts/Button Functions/GameOver.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1765a05fbe2c3cd408dca42fafe71d5d
|
||||||
@@ -18,7 +18,14 @@ public class ShopScript : MonoBehaviour
|
|||||||
|
|
||||||
//TMP_Text textfeld;
|
//TMP_Text textfeld;
|
||||||
[SerializeField] TMP_Text textfeld;
|
[SerializeField] TMP_Text textfeld;
|
||||||
|
|
||||||
|
[Header("Scripte")]
|
||||||
|
|
||||||
InventoryScript inventory;
|
InventoryScript inventory;
|
||||||
|
ChangeHealth healthScript;
|
||||||
|
HandleEnergy battery;
|
||||||
|
|
||||||
|
[Header("BuyValues")]
|
||||||
|
|
||||||
private float moneten = 10.00f; //als vorerstiger Ersatz für tatsächliches Geld
|
private float moneten = 10.00f; //als vorerstiger Ersatz für tatsächliches Geld
|
||||||
|
|
||||||
@@ -53,6 +60,8 @@ public class ShopScript : MonoBehaviour
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
inventory = backgroundPanel.GetComponent<InventoryScript>();
|
inventory = backgroundPanel.GetComponent<InventoryScript>();
|
||||||
|
healthScript = backgroundPanel.GetComponent<ChangeHealth>();
|
||||||
|
battery = backgroundPanel.GetComponent<HandleEnergy>();
|
||||||
|
|
||||||
}
|
}
|
||||||
void Start()
|
void Start()
|
||||||
@@ -112,7 +121,7 @@ public class ShopScript : MonoBehaviour
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inventory.Health++;
|
healthScript.standardHealth++;
|
||||||
|
|
||||||
inventory.Gems -= updateCost;
|
inventory.Gems -= updateCost;
|
||||||
}
|
}
|
||||||
@@ -129,7 +138,7 @@ public class ShopScript : MonoBehaviour
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inventory.Energy++;
|
battery.standardEnergy++;
|
||||||
|
|
||||||
inventory.Gems -= updateCost;
|
inventory.Gems -= updateCost;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,30 +4,29 @@ using static UnityEngine.EventSystems.EventTrigger;
|
|||||||
|
|
||||||
public class ChangeHealth : MonoBehaviour
|
public class ChangeHealth : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] GameObject panel;
|
|
||||||
[SerializeField] GameObject gameOverSceen;
|
|
||||||
|
|
||||||
|
|
||||||
[Header("UI and HUD")]
|
[Header("UI and HUD")]
|
||||||
|
|
||||||
[SerializeField] TMP_Text energyHUD;
|
[SerializeField] GameObject panel;
|
||||||
[SerializeField] TMP_Text healthHUD;
|
[SerializeField] TMP_Text healthHUD;
|
||||||
|
[SerializeField] public int standardHealth = 3;
|
||||||
|
|
||||||
|
[Header("ScriptPile")]
|
||||||
|
|
||||||
InventoryScript inventory;
|
InventoryScript inventory;
|
||||||
|
GameOver end;
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
inventory = panel.GetComponent<InventoryScript>();
|
inventory = panel.GetComponent<InventoryScript>();
|
||||||
|
end = panel.GetComponent<GameOver>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
energyHUD.text = inventory.Energy.ToString();
|
inventory.Health = standardHealth;
|
||||||
healthHUD.text = inventory.Health.ToString();
|
healthHUD.text = inventory.Health.ToString();
|
||||||
|
|
||||||
gameOverSceen.SetActive(false);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
@@ -40,18 +39,17 @@ public class ChangeHealth : MonoBehaviour
|
|||||||
|
|
||||||
public void GetHit()
|
public void GetHit()
|
||||||
{
|
{
|
||||||
|
inventory.Health -= 1; //MAGIC NUMBER BITTE BEACHTEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Die()
|
public void Die()
|
||||||
{
|
{
|
||||||
gameOverSceen.SetActive(true);
|
Time.timeScale = 0;
|
||||||
|
|
||||||
|
end.ShowDeathScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NewChance()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
46
Assets/Scripts/Player/HandleEnergy.cs
Normal file
46
Assets/Scripts/Player/HandleEnergy.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class HandleEnergy : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("Values")]
|
||||||
|
|
||||||
|
[SerializeField] public int standardEnergy = 10;
|
||||||
|
[SerializeField] public int addEnergyValue = 2;
|
||||||
|
|
||||||
|
[Header("UI and HUD")]
|
||||||
|
|
||||||
|
|
||||||
|
[SerializeField] TMP_Text energyHUD;
|
||||||
|
|
||||||
|
[Header("ScriptPile")]
|
||||||
|
|
||||||
|
[SerializeField] GameObject scriptPile;
|
||||||
|
|
||||||
|
InventoryScript inventory;
|
||||||
|
GameOver end;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
inventory = scriptPile.GetComponent<InventoryScript>();
|
||||||
|
end = scriptPile.GetComponent<GameOver>(); //UNNÖTIG, BEI ENEGRY 0 IST JA KEIN GAMEOVER
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
inventory.Energy = standardEnergy;
|
||||||
|
energyHUD.text = inventory.Energy.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoseEnergy()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Player/HandleEnergy.cs.meta
Normal file
2
Assets/Scripts/Player/HandleEnergy.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a55b227e958a84b4fa0f0b375b48aa87
|
||||||
@@ -7,13 +7,13 @@ public class InventoryScript : MonoBehaviour
|
|||||||
|
|
||||||
[Header("Variables")]
|
[Header("Variables")]
|
||||||
//Energy
|
//Energy
|
||||||
[SerializeField] int energy = 10;
|
[SerializeField] int energy;
|
||||||
|
|
||||||
//Health
|
//Health
|
||||||
[SerializeField] int health = 1;
|
[SerializeField] int health;
|
||||||
|
|
||||||
//Gems
|
//Gems
|
||||||
[SerializeField] int gems = 100;
|
[SerializeField] int gems;
|
||||||
|
|
||||||
|
|
||||||
public InventoryScript(int energy, int health, int gems)
|
public InventoryScript(int energy, int health, int gems)
|
||||||
|
|||||||
36
Assets/Scripts/Player/LevelScripts.cs
Normal file
36
Assets/Scripts/Player/LevelScripts.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEditor.Rendering;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class LevelScripts : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] float clock;
|
||||||
|
[SerializeField] TMP_Text gameTime;
|
||||||
|
[SerializeField] bool onShift;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
onShift = true;
|
||||||
|
clock = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (onShift)
|
||||||
|
{
|
||||||
|
gameTime.text = Convert.ToInt32(clock += Time.deltaTime).ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EndShift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EndShift()
|
||||||
|
{
|
||||||
|
onShift = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Player/LevelScripts.cs.meta
Normal file
2
Assets/Scripts/Player/LevelScripts.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c5cf3a8c12b09bf4389983567f33be98
|
||||||
Reference in New Issue
Block a user