Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone
# Conflicts: # Assets/Scenes/Story1.unity # Assets/Scripts/Shoot.cs
This commit is contained in:
@@ -26,6 +26,8 @@ public class Door_Rotate : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PauseMenu.GameIsPaused) return;
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.E) && IsPlayerLooking())
|
||||
{
|
||||
ToggleDoor();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -6,19 +6,35 @@ 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()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
if (weapon == null)
|
||||
weapon = FindFirstObjectByType<WeaponReload>();
|
||||
>>>>>>> 85ece045864c59c50ed55097c35e2c15b9051a0f
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
if (AR == true && Input.GetKey(KeyCode.Mouse0))
|
||||
=======
|
||||
if (PauseMenu.GameIsPaused) return;
|
||||
|
||||
if (AR == true && Input.GetKey(KeyCode.Mouse0) && Time.time >= nextShotTime)
|
||||
>>>>>>> 85ece045864c59c50ed55097c35e2c15b9051a0f
|
||||
{
|
||||
Shot(spawnPointAR);
|
||||
nextShotTime = Time.time + fireRate;
|
||||
}
|
||||
else if (Pistole == true && Input.GetKeyDown(KeyCode.Mouse0))
|
||||
{
|
||||
@@ -27,6 +43,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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user