Villeicht fix 3, villeicht ultimatieve zerstörung
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
using UnityEngine;
|
||||
using TMPro; // WICHTIG: Erforderlich für TextMeshPro!
|
||||
|
||||
public class AmmoUI : MonoBehaviour
|
||||
{
|
||||
[Header("Referenzen")]
|
||||
[Tooltip("Ziehe hier dein TextMeshPro Text-Objekt rein")]
|
||||
public TextMeshProUGUI ammoText;
|
||||
|
||||
[Tooltip("Ziehe hier das Objekt mit deinem WeaponReload-Skript rein")]
|
||||
public WeaponReload weapon;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (ammoText != null && weapon != null)
|
||||
{
|
||||
// Zeigt z. B. "30 / 30" im Textfeld an
|
||||
ammoText.text = weapon.currentAmmo + " / " + weapon.maxAmmo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d012b46a6ebe1e34598d94f22195a13e
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ee40f80839af164b8507cf892937394
|
||||
guid: ca0af482cda994d49a63d47b3d487ba9
|
||||
@@ -1,73 +0,0 @@
|
||||
//Morten
|
||||
using UnityEngine;
|
||||
|
||||
public class Door_Rotate : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float openAngle = 90f;
|
||||
[SerializeField] private float rotationSpeed = 2f;
|
||||
[SerializeField] private float interactionDistance = 5f;
|
||||
[SerializeField] private Vector3 rotationOffset = Vector3.zero;
|
||||
|
||||
private float targetRotation = 0f;
|
||||
private float currentRotation = 0f;
|
||||
private bool isOpen = false;
|
||||
private Camera playerCamera;
|
||||
private Vector3 pivotPoint;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
playerCamera = Camera.main;
|
||||
currentRotation = transform.localEulerAngles.y;
|
||||
targetRotation = currentRotation;
|
||||
|
||||
pivotPoint = transform.position + rotationOffset;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PauseMenu.GameIsPaused) return;
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.E) && IsPlayerLooking())
|
||||
{
|
||||
ToggleDoor();
|
||||
}
|
||||
|
||||
SmoothRotateDoor();
|
||||
}
|
||||
|
||||
private void ToggleDoor()
|
||||
{
|
||||
isOpen = !isOpen;
|
||||
targetRotation = isOpen ? currentRotation + openAngle : currentRotation - openAngle;
|
||||
}
|
||||
//glatte bewegung der tür
|
||||
private void SmoothRotateDoor()
|
||||
{
|
||||
currentRotation = Mathf.Lerp(currentRotation, targetRotation, Time.deltaTime * rotationSpeed);
|
||||
|
||||
transform.RotateAround(pivotPoint, Vector3.up, (currentRotation - transform.localEulerAngles.y));
|
||||
transform.localEulerAngles = new Vector3(
|
||||
transform.localEulerAngles.x,
|
||||
currentRotation,
|
||||
transform.localEulerAngles.z
|
||||
);
|
||||
}
|
||||
//checkt ob der spieler auf die Tür schaut und ob er nah genug ist, um sie zu öffnen https://docs.unity3d.com/6000.4/Documentation/ScriptReference/Physics.Raycast.html
|
||||
private bool IsPlayerLooking()
|
||||
{
|
||||
if (playerCamera == null) return false;
|
||||
|
||||
Ray ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward);
|
||||
float distanceToPlayer = Vector3.Distance(playerCamera.transform.position, transform.position);
|
||||
|
||||
if (distanceToPlayer > interactionDistance) return false;
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, interactionDistance))
|
||||
{
|
||||
return hit.collider.gameObject == gameObject;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06852f09d119f7647b099917df7e799a
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2665e725aa6c7642bb84ea1a671970a
|
||||
guid: 5982caa3acb278745833a9715ba43e9d
|
||||
@@ -1,72 +0,0 @@
|
||||
//Oliver
|
||||
using UnityEngine;
|
||||
|
||||
public class EquipmentManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public GameObject AR;
|
||||
[SerializeField]public GameObject Pistole;
|
||||
[SerializeField]public GameObject Verband;
|
||||
[SerializeField]public GameObject Knife;
|
||||
public bool ARisOn = true;
|
||||
public bool PistoleIsOn = false;
|
||||
public bool VerbandIsOn = false;
|
||||
public bool KnifeIsOn = false;
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (PauseMenu.GameIsPaused) return;
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.Alpha2) && PistoleIsOn == false)
|
||||
{
|
||||
AR.SetActive(false);
|
||||
Pistole.SetActive(true);
|
||||
Verband.SetActive(false);
|
||||
Knife.SetActive(false);
|
||||
ARisOn = false;
|
||||
PistoleIsOn = true;
|
||||
VerbandIsOn = false;
|
||||
KnifeIsOn = false;
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1) && ARisOn == false)
|
||||
{
|
||||
AR.SetActive(true);
|
||||
Pistole.SetActive(false);
|
||||
Verband.SetActive(false);
|
||||
Knife.SetActive(false);
|
||||
ARisOn = true;
|
||||
PistoleIsOn = false;
|
||||
VerbandIsOn = false;
|
||||
KnifeIsOn = false;
|
||||
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Alpha3) && VerbandIsOn == false)
|
||||
{
|
||||
AR.SetActive(false);
|
||||
Pistole.SetActive(false);
|
||||
Verband.SetActive(true);
|
||||
Knife.SetActive(false);
|
||||
ARisOn = false;
|
||||
PistoleIsOn = false;
|
||||
VerbandIsOn = true;
|
||||
KnifeIsOn = false;
|
||||
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Alpha4) && KnifeIsOn == false)
|
||||
{
|
||||
AR.SetActive(false);
|
||||
Pistole.SetActive(false);
|
||||
Verband.SetActive(false);
|
||||
Knife.SetActive(true);
|
||||
ARisOn = false;
|
||||
PistoleIsOn = false;
|
||||
VerbandIsOn = false;
|
||||
KnifeIsOn = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57a6119ff88b0eb45940808859180edd
|
||||
@@ -1,26 +0,0 @@
|
||||
//Oliver
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
public class Health : MonoBehaviour
|
||||
{
|
||||
public int maxHP = 100;
|
||||
public int curHP;
|
||||
void Start()
|
||||
{
|
||||
curHP = maxHP;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(curHP <= 0)
|
||||
{
|
||||
die();
|
||||
}
|
||||
}
|
||||
public void die()
|
||||
{
|
||||
Destroy(this);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a187176846a552d4e8321e8645b42c94
|
||||
@@ -1,18 +0,0 @@
|
||||
using UnityEngine;
|
||||
using TMPro; // Erforderlich für TextMeshPro
|
||||
|
||||
public class HealthUI : MonoBehaviour
|
||||
{
|
||||
[Header("Referenzen")]
|
||||
public TextMeshProUGUI healthText;
|
||||
public PlayerHealth playerHealth;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (healthText != null && playerHealth != null)
|
||||
{
|
||||
// Zeigt z. B. "HP: 100 / 100" an
|
||||
healthText.text = "HP: " + playerHealth.currentHealth + " / " + playerHealth.maxHealth;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2820b4f73584b72408d4d3609f434403
|
||||
@@ -1,45 +0,0 @@
|
||||
// Oliver
|
||||
using UnityEngine;
|
||||
|
||||
public class Map_Generator : MonoBehaviour
|
||||
{
|
||||
public Texture2D tex;
|
||||
public int width;
|
||||
public int heigt;
|
||||
public Color[] pixelFarbe;
|
||||
public GameObject blockPrefab;
|
||||
void Start()
|
||||
{
|
||||
width = tex.width;
|
||||
heigt = tex.height;
|
||||
|
||||
pixelFarbe = new Color[width * heigt];
|
||||
|
||||
for (int i = 0; i < heigt; i++)
|
||||
{
|
||||
for (int k = 0; k < width; k++)
|
||||
{
|
||||
pixelFarbe[k + i * width] = tex.GetPixel(k, i);
|
||||
}
|
||||
|
||||
}
|
||||
for (int i = 0; i < heigt; i++)
|
||||
{
|
||||
for (int k = 0; k < width; k++)
|
||||
{
|
||||
if (pixelFarbe[k + i * width].grayscale >= Color.gray.grayscale)
|
||||
{
|
||||
GameObject block = Instantiate(blockPrefab);
|
||||
block.transform.position = new Vector3(k, 0, i);
|
||||
block.GetComponent<Renderer>().material.color = Color.black;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 079eca2fab980b94ea6d88afb4570141
|
||||
@@ -1,65 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PauseMenu : MonoBehaviour
|
||||
{
|
||||
[Header("UI Elemente")]
|
||||
public GameObject pauseMenuUI; // Das Pausenmenü-Panel
|
||||
public GameObject hudUI; // Die Lebens- und Munitionsanzeige (HUD)
|
||||
|
||||
public static bool GameIsPaused = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
ResumeGame();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Überprüft, ob die ESC-Taste gedrückt wurde
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if (GameIsPaused)
|
||||
{
|
||||
ResumeGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
PauseGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PauseGame()
|
||||
{
|
||||
pauseMenuUI.SetActive(true); // Pausenmenü anzeigen
|
||||
hudUI.SetActive(false); // Lebens- & Munitionsanzeige ausblenden
|
||||
Time.timeScale = 0f; // Spielzeit anhalten
|
||||
GameIsPaused = true;
|
||||
|
||||
// MAUSZEIGER FREIGEBEN (damit man Knöpfe drücken kann)
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
|
||||
public void ResumeGame()
|
||||
{
|
||||
pauseMenuUI.SetActive(false); // Pausenmenü ausblenden
|
||||
hudUI.SetActive(true); // Lebens- & Munitionsanzeige wieder anzeigen
|
||||
Time.timeScale = 1f; // Spielzeit weiterlaufen lassen
|
||||
GameIsPaused = false;
|
||||
|
||||
// MAUSZEIGER WIEDER SPERREN (fürs Gameplay)
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4a749aaa304ec14b98518e63fda8cdb
|
||||
@@ -1,53 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PausenManager : MonoBehaviour
|
||||
{
|
||||
// Damit andere Skripte (wie deine Waffe) wissen, ob pausiert ist
|
||||
public static bool GameIsPaused = false;
|
||||
|
||||
// Ziehe dein Pause-Menü UI-Panel hier im Inspector rein
|
||||
public GameObject pauseMenuUI;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if (GameIsPaused)
|
||||
{
|
||||
Resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
pauseMenuUI.SetActive(false);
|
||||
Time.timeScale = 1f; // Zeit läuft wieder normal
|
||||
GameIsPaused = false;
|
||||
|
||||
// Maus wieder verstecken und im Spiel festhalten
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
|
||||
void Pause()
|
||||
{
|
||||
pauseMenuUI.SetActive(true);
|
||||
Time.timeScale = 0f; // Spiel friert ein
|
||||
GameIsPaused = true;
|
||||
|
||||
// Maus anzeigen und entsperren, damit du klicken kannst
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Debug.Log("Spiel wird verlassen...");
|
||||
Application.Quit(); // Beendet das Spiel (funktioniert nur im fertigen Build, nicht im Editor)
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33345f0f372370e4d903e361cc6ec87c
|
||||
@@ -1,47 +0,0 @@
|
||||
//Oliver
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] int speed;
|
||||
private Vector3 position = Vector3.zero;
|
||||
private Text score;
|
||||
private int points;
|
||||
private Rigidbody rb;
|
||||
void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PauseMenu.GameIsPaused)
|
||||
{
|
||||
position = Vector3.zero;
|
||||
return;
|
||||
}
|
||||
|
||||
position = Vector3.zero;
|
||||
if (Input.GetKey(KeyCode.W))
|
||||
{
|
||||
position += Vector3.forward * speed;
|
||||
}
|
||||
if (Input.GetKey(KeyCode.A))
|
||||
{
|
||||
position += Vector3.left * speed;
|
||||
}
|
||||
if (Input.GetKey(KeyCode.S))
|
||||
{
|
||||
position += Vector3.back * speed;
|
||||
}
|
||||
if (Input.GetKey(KeyCode.D))
|
||||
{
|
||||
position += Vector3.right * speed;
|
||||
}
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = position.normalized * speed;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e857b6f5c4484c449d9e726f2fc5d36
|
||||
@@ -1,46 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerHealth : MonoBehaviour
|
||||
{
|
||||
[Header("Gesundheitseinstellungen")]
|
||||
public int maxHealth = 100;
|
||||
public int currentHealth;
|
||||
|
||||
void Start()
|
||||
{
|
||||
currentHealth = maxHealth; // Startet mit 100 Leben
|
||||
}
|
||||
|
||||
// Funktion, um Schaden zu bekommen
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
currentHealth -= damage;
|
||||
|
||||
// Verhindert, dass das Leben unter 0 fällt
|
||||
if (currentHealth < 0)
|
||||
{
|
||||
currentHealth = 0;
|
||||
}
|
||||
|
||||
if (currentHealth == 0)
|
||||
{
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: Funktion zum Heilen
|
||||
public void Heal(int amount)
|
||||
{
|
||||
currentHealth += amount;
|
||||
if (currentHealth > maxHealth)
|
||||
{
|
||||
currentHealth = maxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
void Die()
|
||||
{
|
||||
Debug.Log("Spieler ist gestorben!");
|
||||
// Hier kannst du z.B. einen Game Over Screen anzeigen oder die Szene neu laden
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db77dcbb78925b543b84b7789c1903b9
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a10d4b5b33d924c428453e46c9513163
|
||||
guid: 8430865c86093d34ea989fc550b322d3
|
||||
@@ -1,26 +0,0 @@
|
||||
// Oliver
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIHandler : MonoBehaviour
|
||||
{
|
||||
public void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ChangeScene(string sceneName)
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 039d8264ac1c9ed42a3657361d73ced5
|
||||
@@ -1,69 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class WeaponReload : MonoBehaviour
|
||||
{
|
||||
[Header("Munitionseinstellungen")]
|
||||
public int maxAmmo = 30; // Maximale Munition im Magazin
|
||||
public int currentAmmo; // Aktuelle Munition
|
||||
public float reloadTime = 1.5f; // Wie lange das Nachladen dauert (in Sekunden)
|
||||
|
||||
private bool isReloading = false; // Verhindert Doppelklicks / Aktionen während des Nachladens
|
||||
|
||||
void Start()
|
||||
{
|
||||
currentAmmo = maxAmmo; // Beim Start ist das Magazin voll
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PauseMenu.GameIsPaused) return;
|
||||
|
||||
// Während nachgeladen wird, keine Aktionen zulassen
|
||||
if (isReloading)
|
||||
return;
|
||||
|
||||
// --- PUNKT 1: Auslösen auf R ODER wenn Magazin leer ist ---
|
||||
// 1. Manuelles Nachladen mit R (nur wenn Magazin nicht schon voll ist)
|
||||
if (Input.GetKeyDown(KeyCode.R) && currentAmmo < maxAmmo)
|
||||
{
|
||||
StartCoroutine(Reload());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool UseAmmo()
|
||||
{
|
||||
if (PauseMenu.GameIsPaused || isReloading) return false;
|
||||
|
||||
if (currentAmmo <= 0)
|
||||
{
|
||||
StartCoroutine(Reload());
|
||||
return false;
|
||||
}
|
||||
|
||||
currentAmmo--;
|
||||
Debug.Log("Schuss gefeuert! Verbleibende Munition: " + currentAmmo);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Coroutine für die Nachlade-Verzögerung
|
||||
IEnumerator Reload()
|
||||
{
|
||||
isReloading = true;
|
||||
Debug.Log("Nachladen gestartet...");
|
||||
|
||||
// Hier könntest du z.B. eine Nachlade-Animation oder einen Sound abspielen:
|
||||
// animator.SetTrigger("Reload");
|
||||
|
||||
// Warten, bis die Nachladezeit abgelaufen ist
|
||||
yield return new WaitForSeconds(reloadTime);
|
||||
|
||||
// --- PUNKT 2: Munition wieder voll wenn fertig ---
|
||||
currentAmmo = maxAmmo;
|
||||
|
||||
isReloading = false;
|
||||
Debug.Log("Nachladen abgeschlossen! Munition wieder voll: " + currentAmmo);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a3d6d3eb3a1b7845801a59185c759a3
|
||||
Reference in New Issue
Block a user