From 4a23cacf12277ec01fbf2c25efc5b06309b3eecd Mon Sep 17 00:00:00 2001 From: "NBTEMP\\bib" Date: Thu, 20 Aug 2026 10:43:24 +0200 Subject: [PATCH] waffen realoden reapriert --- Assets/Scenes/Menue.unity | 20 +++++------ Assets/Scenes/Story1.unity | 54 ++++++++++++------------------ Assets/Scripts/Door_Rotate.cs | 2 ++ Assets/Scripts/EquipmentManager.cs | 2 ++ Assets/Scripts/PauseMenu.cs | 25 +++++++++++--- Assets/Scripts/PlayerController.cs | 6 ++++ Assets/Scripts/Shoot.cs | 13 +++++-- Assets/Scripts/WeaponReload.cs | 31 +++++++---------- 8 files changed, 84 insertions(+), 69 deletions(-) diff --git a/Assets/Scenes/Menue.unity b/Assets/Scenes/Menue.unity index ed0fbec..e8bfd47 100644 --- a/Assets/Scenes/Menue.unity +++ b/Assets/Scenes/Menue.unity @@ -1206,16 +1206,16 @@ MonoBehaviour: m_MoveRepeatRate: 0.1 m_XRTrackingOrigin: {fileID: 0} m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_PointAction: {fileID: 1054132383583890850, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_MoveAction: {fileID: 3710738434707379630, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_SubmitAction: {fileID: 2064916234097673511, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_CancelAction: {fileID: -1967631576421560919, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_LeftClickAction: {fileID: 8056856818456041789, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_MiddleClickAction: {fileID: 3279352641294131588, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_RightClickAction: {fileID: 3837173908680883260, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_ScrollWheelAction: {fileID: 4502412055082496612, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_TrackedDevicePositionAction: {fileID: 4754684134866288074, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_TrackedDeviceOrientationAction: {fileID: 1025543830046995696, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} m_DeselectOnBackgroundClick: 1 m_PointerBehavior: 0 m_CursorLockBehavior: 0 diff --git a/Assets/Scenes/Story1.unity b/Assets/Scenes/Story1.unity index c790c6b..b3eec6d 100644 --- a/Assets/Scenes/Story1.unity +++ b/Assets/Scenes/Story1.unity @@ -170,7 +170,7 @@ MonoBehaviour: m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 0.392} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -214,6 +214,8 @@ MonoBehaviour: bulletPrefab: {fileID: 4474395191186681843, guid: afa71643f370d394e8dd19e0ab40ab57, type: 3} spawnPointAR: {fileID: 2136079773} spawnPointPistol: {fileID: 0} + weapon: {fileID: 1546402530} + fireRate: 0.15 AR: 1 Pistole: 1 --- !u!114 &50826114 @@ -486,10 +488,10 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1985753437} - m_TargetAssemblyTypeName: PausenManager, Assembly-CSharp - m_MethodName: lobby - m_Mode: 5 + - m_Target: {fileID: 535044339} + m_TargetAssemblyTypeName: PauseMenu, Assembly-CSharp + m_MethodName: ResumeGame + m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine @@ -847,16 +849,16 @@ MonoBehaviour: m_MoveRepeatRate: 0.1 m_XRTrackingOrigin: {fileID: 0} m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_PointAction: {fileID: 1054132383583890850, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_MoveAction: {fileID: 3710738434707379630, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_SubmitAction: {fileID: 2064916234097673511, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_CancelAction: {fileID: -1967631576421560919, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_LeftClickAction: {fileID: 8056856818456041789, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_MiddleClickAction: {fileID: 3279352641294131588, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_RightClickAction: {fileID: 3837173908680883260, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_ScrollWheelAction: {fileID: 4502412055082496612, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_TrackedDevicePositionAction: {fileID: 4754684134866288074, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} + m_TrackedDeviceOrientationAction: {fileID: 1025543830046995696, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} m_DeselectOnBackgroundClick: 1 m_PointerBehavior: 0 m_CursorLockBehavior: 0 @@ -974,9 +976,9 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 1985753437} - m_TargetAssemblyTypeName: PausenManager, Assembly-CSharp - m_MethodName: Quit + - m_Target: {fileID: 535044339} + m_TargetAssemblyTypeName: PauseMenu, Assembly-CSharp + m_MethodName: QuitGame m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -1573,7 +1575,7 @@ RectTransform: m_GameObject: {fileID: 1597635426} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1783601023} @@ -1850,7 +1852,6 @@ GameObject: - component: {fileID: 1985753435} - component: {fileID: 1985753434} - component: {fileID: 1985753433} - - component: {fileID: 1985753437} m_Layer: 5 m_Name: "pausenmen\xFC" m_TagString: Untagged @@ -1944,19 +1945,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} ---- !u!114 &1985753437 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1985753432} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 33345f0f372370e4d903e361cc6ec87c, type: 3} - m_Name: - m_EditorClassIdentifier: Assembly-CSharp::PausenManager - pauseMenuUI: {fileID: 0} --- !u!1 &2041741097 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Door_Rotate.cs b/Assets/Scripts/Door_Rotate.cs index 6ae7d62..9221a94 100644 --- a/Assets/Scripts/Door_Rotate.cs +++ b/Assets/Scripts/Door_Rotate.cs @@ -26,6 +26,8 @@ public class Door_Rotate : MonoBehaviour void Update() { + if (PauseMenu.GameIsPaused) return; + if (Input.GetKeyDown(KeyCode.E) && IsPlayerLooking()) { ToggleDoor(); diff --git a/Assets/Scripts/EquipmentManager.cs b/Assets/Scripts/EquipmentManager.cs index 5e3ddcb..e2dc8a7 100644 --- a/Assets/Scripts/EquipmentManager.cs +++ b/Assets/Scripts/EquipmentManager.cs @@ -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); diff --git a/Assets/Scripts/PauseMenu.cs b/Assets/Scripts/PauseMenu.cs index 55757e9..0d966f2 100644 --- a/Assets/Scripts/PauseMenu.cs +++ b/Assets/Scripts/PauseMenu.cs @@ -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; } -} \ No newline at end of file + + public void QuitGame() + { + Time.timeScale = 1f; +#if UNITY_EDITOR + UnityEditor.EditorApplication.isPlaying = false; +#else + Application.Quit(); +#endif + } +} diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index ff50609..1a602d8 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -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)) { diff --git a/Assets/Scripts/Shoot.cs b/Assets/Scripts/Shoot.cs index c7107ac..aeb04e9 100644 --- a/Assets/Scripts/Shoot.cs +++ b/Assets/Scripts/Shoot.cs @@ -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(); } 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); diff --git a/Assets/Scripts/WeaponReload.cs b/Assets/Scripts/WeaponReload.cs index 0e3db16..74031d2 100644 --- a/Assets/Scripts/WeaponReload.cs +++ b/Assets/Scripts/WeaponReload.cs @@ -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); } -} \ No newline at end of file +}