# Conflicts:
#	Assets/Scenes/Story1.unity
#	Assets/Scenes/Story1.unity.rej
#	Assets/Scripts/Bullet.cs
#	Assets/Scripts/EnemyHealth.cs
#	Assets/Scripts/Shoot.cs
This commit is contained in:
2026-08-20 11:44:36 +02:00
23 changed files with 464 additions and 187 deletions
+13 -4
View File
@@ -1,35 +1,39 @@
//Oliver
using UnityEngine;
public class Bullet : MonoBehaviour
public class ARBullet : MonoBehaviour
{
public float speed;
public int damage;
public int damage = 20;
private Vector3 position = Vector3.forward;
private Rigidbody rb;
void Start()
{
GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
transform.Translate(position.normalized * speed * Time.deltaTime);
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Enemy")
{
<<<<<<< HEAD
<<<<<<< HEAD
Destroy(collision.gameObject);
=======
=======
>>>>>>> 392d23632b62942df19732b9e125c98967abd9e4
EnemyHealth enemy = collision.gameObject.GetComponent<EnemyHealth>();
if (enemy != null)
{
enemy.TakeDamage(damage);
<<<<<<< HEAD
Destroy(gameObject);
}
@@ -37,10 +41,15 @@ public class Bullet : MonoBehaviour
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
=======
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
=======
}
Destroy(gameObject);
>>>>>>> 392d23632b62942df19732b9e125c98967abd9e4
}
else if(collision.gameObject.tag == "Wall")
{
Destroy(this);
Destroy(gameObject);
}
}
+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();
+4
View File
@@ -1,3 +1,7 @@
<<<<<<< HEAD
=======
//Oliver
>>>>>>> 392d23632b62942df19732b9e125c98967abd9e4
using UnityEngine;
public class EnemyHealth : MonoBehaviour
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e2665e725aa6c7642bb84ea1a671970a
+46
View File
@@ -0,0 +1,46 @@
using UnityEngine;
public class EnemyShooter : MonoBehaviour
{
public float shootRange = 25f;
public float shootDelay = 1f;
public int damage = 10;
private PlayerHealth player;
private float nextShotTime;
void Start()
{
player = FindFirstObjectByType<PlayerHealth>();
}
void Update()
{
if (PauseMenu.GameIsPaused || player == null) return;
Vector3 direction = player.transform.position - transform.position;
if (direction.magnitude > shootRange) return;
direction.y = 0f;
if (direction != Vector3.zero)
transform.rotation = Quaternion.LookRotation(direction);
if (Time.time >= nextShotTime && CanSeePlayer())
{
player.TakeDamage(damage);
nextShotTime = Time.time + shootDelay;
}
}
bool CanSeePlayer()
{
Vector3 start = transform.position + Vector3.up;
Vector3 target = player.transform.position + Vector3.up;
Vector3 direction = target - start;
if (Physics.Raycast(start, direction.normalized, out RaycastHit hit, shootRange))
return hit.collider.GetComponentInParent<PlayerHealth>() != null;
return false;
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 29f907e38ca44e3495ce692733ada681
+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);
+49
View File
@@ -0,0 +1,49 @@
using UnityEngine;
public class HostageRescue : MonoBehaviour
{
public float rescueDistance = 3f;
public float escapeDistance = 15f;
public float runSpeed = 5f;
private Transform player;
private bool rescued;
private Vector3 escapeDirection;
private Vector3 startPosition;
void Start()
{
PlayerHealth playerHealth = FindFirstObjectByType<PlayerHealth>();
if (playerHealth != null) player = playerHealth.transform;
startPosition = transform.position;
}
void Update()
{
if (PauseMenu.GameIsPaused || player == null) return;
if (rescued)
{
transform.position += escapeDirection * runSpeed * Time.deltaTime;
if (Vector3.Distance(startPosition, transform.position) >= escapeDistance)
enabled = false;
return;
}
if (Vector3.Distance(transform.position, player.position) <= rescueDistance &&
Input.GetKeyDown(KeyCode.E))
{
RunAway();
}
}
void RunAway()
{
rescued = true;
startPosition = transform.position;
escapeDirection = (transform.position - player.position).normalized;
escapeDirection.y = 0f;
transform.rotation = Quaternion.LookRotation(escapeDirection);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 62ea7866e4d846e2b5d207c6a3ec8afa
+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))
{
+26 -2
View File
@@ -6,12 +6,17 @@ 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
<<<<<<< HEAD
<<<<<<< HEAD
=======
if (weapon == null)
@@ -21,11 +26,19 @@ public class Shoot : MonoBehaviour
if (weapon == null)
weapon = FindFirstObjectByType<WeaponReload>();
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
=======
=======
if (weapon == null)
weapon = FindFirstObjectByType<WeaponReload>();
>>>>>>> 85ece045864c59c50ed55097c35e2c15b9051a0f
>>>>>>> 392d23632b62942df19732b9e125c98967abd9e4
}
void Update()
{
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
if ( AR == true && Input.GetKey(KeyCode.Mouse0))
@@ -39,8 +52,18 @@ public class Shoot : MonoBehaviour
if (AR == true && Input.GetKey(KeyCode.Mouse0) && Time.time >= nextShotTime)
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
=======
if (AR == true && Input.GetKey(KeyCode.Mouse0))
=======
if (PauseMenu.GameIsPaused) return;
if (AR == true && Input.GetKey(KeyCode.Mouse0) && Time.time >= nextShotTime)
>>>>>>> 85ece045864c59c50ed55097c35e2c15b9051a0f
>>>>>>> 392d23632b62942df19732b9e125c98967abd9e4
{
Shot(spawnPointAR);
nextShotTime = Time.time + fireRate;
}
else if (Pistole == true && Input.GetKeyDown(KeyCode.Mouse0))
{
@@ -49,8 +72,9 @@ 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);
bullet.transform.Rotate(90, 0, 0);
}
}
+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);
}
}
}