Komplett Lauffähig + Vibration + Boni + Enemie "Jumpscares" - Audio
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.EventSystems.EventTrigger;
|
||||
|
||||
@@ -8,26 +9,50 @@ public class ChangeHealth : MonoBehaviour
|
||||
|
||||
|
||||
[SerializeField] public int deathCounter;
|
||||
[SerializeField] GameObject panel;
|
||||
[SerializeField] GameObject scriptPile;
|
||||
[SerializeField] GameObject scriptPileAgain;
|
||||
[SerializeField] GameObject guessWhatAgain;
|
||||
[SerializeField] TMP_Text healthHUD;
|
||||
[SerializeField] public int standardHealth = 3;
|
||||
//[SerializeField] GameObject levelScript; //wird aktuell nicht genutzt
|
||||
|
||||
|
||||
[Header("Enemies")]
|
||||
[SerializeField] GameObject eFie;
|
||||
[SerializeField] GameObject eSilv;
|
||||
[SerializeField] GameObject eHai;
|
||||
|
||||
[Header("ScriptPile")]
|
||||
|
||||
LevelBehavior level;
|
||||
InventoryScript inventory;
|
||||
GameOver end;
|
||||
|
||||
|
||||
FieScript fie;
|
||||
SilvScript silv;
|
||||
HaiScript hai;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
inventory = panel.GetComponent<InventoryScript>();
|
||||
end = panel.GetComponent<GameOver>();
|
||||
inventory = scriptPileAgain.GetComponent<InventoryScript>(); //TO DO: FIXEN
|
||||
end = guessWhatAgain.GetComponent<GameOver>();
|
||||
level = scriptPile.GetComponent<LevelBehavior>();
|
||||
|
||||
fie = eFie.GetComponent<FieScript>();
|
||||
silv = eSilv.GetComponent<SilvScript>();
|
||||
hai = eHai.GetComponent<HaiScript>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (level.gameOngoing == true)
|
||||
{
|
||||
Debug.Log("ich existiere!");
|
||||
}
|
||||
|
||||
deathCounter = 0;
|
||||
inventory.Health = standardHealth;
|
||||
inventory.Health = inventory.StandardHealth;
|
||||
Debug.Log(inventory.Health);
|
||||
}
|
||||
|
||||
@@ -40,6 +65,8 @@ public class ChangeHealth : MonoBehaviour
|
||||
|
||||
public void GetHit() //MUSS NOCH MIT ENEMIES VERKNÜPFT WERDEN
|
||||
{
|
||||
|
||||
Vibrator.Vibrate();
|
||||
if (inventory.Health > 0)
|
||||
{
|
||||
inventory.Health -= 1; //MAGIC NUMBER BITTE BEACHTEN
|
||||
@@ -55,6 +82,7 @@ public class ChangeHealth : MonoBehaviour
|
||||
|
||||
public void GetHitHard() //MUSS NOCH MIT ENEMIES VERKNÜPFT WERDEN
|
||||
{
|
||||
Vibrator.Vibrate();
|
||||
if (inventory.Health > 0)
|
||||
{
|
||||
inventory.Health -= 2; //MAGIC NUMBER BITTE BEACHTEN
|
||||
@@ -76,6 +104,10 @@ public class ChangeHealth : MonoBehaviour
|
||||
//Time.timeScale = 0; //Wieder umlegen
|
||||
end.ShowDeathScreen();
|
||||
Debug.Log("rest in pizza");
|
||||
|
||||
level.gameOngoing = false;
|
||||
|
||||
end.StopEnemies();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@ public class HandleEnergy : MonoBehaviour
|
||||
{
|
||||
[Header("Values")]
|
||||
|
||||
[SerializeField] public int standardEnergy = 10;
|
||||
[SerializeField] public int addEnergyValue = 2;
|
||||
[SerializeField] public int addEnergyValue = 4;
|
||||
|
||||
[Header("UI and HUD")]
|
||||
|
||||
@@ -29,7 +28,7 @@ public class HandleEnergy : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
inventory.Energy = standardEnergy;
|
||||
inventory.Energy = inventory.StandardEnergy;
|
||||
Debug.Log(inventory.Energy);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,17 @@ public class InventoryData
|
||||
//Gems
|
||||
public int gems;
|
||||
|
||||
public InventoryData(int energy, int health, int gems)
|
||||
public int standardHealth;
|
||||
|
||||
public int standardEnergy;
|
||||
|
||||
public InventoryData(int energy, int health, int gems, int standardHealth, int standardEnergy)
|
||||
{
|
||||
this.energy = energy;
|
||||
this.health = health;
|
||||
this.gems = gems;
|
||||
this.standardHealth = standardHealth;
|
||||
this.standardEnergy = standardEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +47,10 @@ public class InventoryScript : MonoBehaviour
|
||||
//Gems
|
||||
[SerializeField] int gems;
|
||||
|
||||
[SerializeField] int standardHealth = 3;
|
||||
|
||||
[SerializeField] int standardEnergy = 10;
|
||||
|
||||
|
||||
|
||||
private void Awake()
|
||||
@@ -74,6 +84,18 @@ public class InventoryScript : MonoBehaviour
|
||||
set { gems = value; ValChanged(); }
|
||||
}
|
||||
|
||||
public int StandardHealth
|
||||
{
|
||||
get { return standardHealth; }
|
||||
set { standardHealth = value; ValChanged(); }
|
||||
}
|
||||
|
||||
public int StandardEnergy
|
||||
{
|
||||
get { return standardEnergy; }
|
||||
set { standardEnergy = value; ValChanged(); }
|
||||
}
|
||||
|
||||
// Achtung, ValChanged wird NICHT aufgerufen, wenn man die Werte im Inspector verändert,
|
||||
// weil das nur die Felder, nicht die Properties setzt.
|
||||
// Ändert man aber per Script die Property, wird ValChanged aufgerufen und sofort die Werte ins File gespeichert.
|
||||
@@ -98,7 +120,7 @@ public class InventoryScript : MonoBehaviour
|
||||
}
|
||||
private void SaveInventoryData()
|
||||
{
|
||||
inventoryData = new InventoryData(energy, health, gems); // erstellt ein neues Objekt InventoryData aus den Werten dieses Scripts
|
||||
inventoryData = new InventoryData(energy, health, gems, standardHealth, standardEnergy); // erstellt ein neues Objekt InventoryData aus den Werten dieses Scripts
|
||||
string datastring = JsonUtility.ToJson(inventoryData); // macht einen JSON String aus diesem Objekt (dafür brauchen wir es auch nur)
|
||||
File.WriteAllText(path, datastring);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user