waffen realoden reapriert

This commit is contained in:
NBTEMP\bib
2026-08-20 10:43:24 +02:00
parent e8d6a385c4
commit 4a23cacf12
8 changed files with 84 additions and 69 deletions
+2
View File
@@ -26,6 +26,8 @@ public class Door_Rotate : MonoBehaviour
void Update()
{
if (PauseMenu.GameIsPaused) return;
if (Input.GetKeyDown(KeyCode.E) && IsPlayerLooking())
{
ToggleDoor();
+2
View File
@@ -19,6 +19,8 @@ public class EquipmentManager : MonoBehaviour
// Update is called once per frame
void Update()
{
if (PauseMenu.GameIsPaused) return;
if(Input.GetKeyDown(KeyCode.Alpha2) && PistoleIsOn == false)
{
AR.SetActive(false);
+20 -5
View File
@@ -6,14 +6,19 @@ public class PauseMenu : MonoBehaviour
public GameObject pauseMenuUI; // Das Pausenmenü-Panel
public GameObject hudUI; // Die Lebens- und Munitionsanzeige (HUD)
private bool isPaused = false;
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 (isPaused)
if (GameIsPaused)
{
ResumeGame();
}
@@ -29,7 +34,7 @@ public class PauseMenu : MonoBehaviour
pauseMenuUI.SetActive(true); // Pausenmenü anzeigen
hudUI.SetActive(false); // Lebens- & Munitionsanzeige ausblenden
Time.timeScale = 0f; // Spielzeit anhalten
isPaused = true;
GameIsPaused = true;
// MAUSZEIGER FREIGEBEN (damit man Knöpfe drücken kann)
Cursor.lockState = CursorLockMode.None;
@@ -41,10 +46,20 @@ public class PauseMenu : MonoBehaviour
pauseMenuUI.SetActive(false); // Pausenmenü ausblenden
hudUI.SetActive(true); // Lebens- & Munitionsanzeige wieder anzeigen
Time.timeScale = 1f; // Spielzeit weiterlaufen lassen
isPaused = false;
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
}
}
+6
View File
@@ -16,6 +16,12 @@ public class PlayerController : MonoBehaviour
void Update()
{
if (PauseMenu.GameIsPaused)
{
position = Vector3.zero;
return;
}
position = Vector3.zero;
if (Input.GetKey(KeyCode.W))
{
+11 -2
View File
@@ -6,19 +6,26 @@ public class Shoot : MonoBehaviour
[SerializeField] GameObject bulletPrefab;
[SerializeField] Transform spawnPointAR;
[SerializeField] Transform spawnPointPistol;
[SerializeField] WeaponReload weapon;
[SerializeField] float fireRate = 0.15f;
[SerializeField] bool AR = true;
[SerializeField] bool Pistole = true;
private float nextShotTime;
void Start()
{
if (weapon == null)
weapon = FindFirstObjectByType<WeaponReload>();
}
void Update()
{
if (PauseMenu.GameIsPaused) return;
if ( AR == true && Input.GetKey(KeyCode.Mouse0))
if (AR == true && Input.GetKey(KeyCode.Mouse0) && Time.time >= nextShotTime)
{
Shot(spawnPointAR);
nextShotTime = Time.time + fireRate;
}
else if (Pistole == true && Input.GetKeyDown(KeyCode.Mouse0))
{
@@ -27,6 +34,8 @@ public class Shoot : MonoBehaviour
}
public void Shot(Transform spawnPoint)
{
if (spawnPoint == null || weapon == null || !weapon.UseAmmo()) return;
GameObject bullet = Instantiate(bulletPrefab, spawnPoint.position, spawnPoint.rotation);
bullet.transform.Rotate(90,0,0);
Destroy(bullet, 2);
+12 -19
View File
@@ -17,6 +17,8 @@ public class WeaponReload : MonoBehaviour
void Update()
{
if (PauseMenu.GameIsPaused) return;
// Während nachgeladen wird, keine Aktionen zulassen
if (isReloading)
return;
@@ -29,30 +31,21 @@ public class WeaponReload : MonoBehaviour
return;
}
// 2. Automatisches Nachladen beim Schießen, wenn das Magazin leer (<= 0) ist
if (Input.GetButtonDown("Fire1"))
{
if (currentAmmo > 0)
{
Shoot();
}
else
{
// Magazin ist leer -> automatisch nachladen!
StartCoroutine(Reload());
}
}
}
void Shoot()
public bool UseAmmo()
{
// Nur schießen, wenn das Pausemenü NICHT offen ist
if (PausenManager.GameIsPaused) return;
if (PauseMenu.GameIsPaused || isReloading) return false;
if (currentAmmo <= 0)
{
StartCoroutine(Reload());
return false;
}
currentAmmo--;
Debug.Log("Schuss gefeuert! Verbleibende Munition: " + currentAmmo);
// Hier deinen normalen Schuss-Code einfügen (Raycast, Bullet-Prefab, Ton etc.)
return true;
}
// Coroutine für die Nachlade-Verzögerung
@@ -73,4 +66,4 @@ public class WeaponReload : MonoBehaviour
isReloading = false;
Debug.Log("Nachladen abgeschlossen! Munition wieder voll: " + currentAmmo);
}
}
}