diff --git a/Assets/Scripts/Camera/CameraView.cs b/Assets/Scripts/Camera/CameraView.cs index 1e140553..aab5156a 100644 --- a/Assets/Scripts/Camera/CameraView.cs +++ b/Assets/Scripts/Camera/CameraView.cs @@ -14,13 +14,15 @@ public class CameraView : MonoBehaviour private void OnEnable() { EventService.Instance.OnLightsOffByGhostEvent.AddListener(Shake); - EventService.Instance.PlayerDeathEvent.AddListener(Shake); + EventService.Instance.OnPlayerDeathEvent.AddListener(Shake); + EventService.Instance.OnRatRush.AddListener(Shake); } private void OnDisable() { EventService.Instance.OnLightsOffByGhostEvent.RemoveListener(Shake); - EventService.Instance.PlayerDeathEvent.RemoveListener(Shake); + EventService.Instance.OnPlayerDeathEvent.RemoveListener(Shake); + EventService.Instance.OnRatRush.RemoveListener(Shake); } private void Start() diff --git a/Assets/Scripts/Events/PlayerEscapedEvent.cs b/Assets/Scripts/Events/PlayerEscapedEvent.cs index de7df07b..aa6384bf 100644 --- a/Assets/Scripts/Events/PlayerEscapedEvent.cs +++ b/Assets/Scripts/Events/PlayerEscapedEvent.cs @@ -9,7 +9,7 @@ private void OnTriggerEnter(Collider other) if (other.GetComponent() != null) { GameService.Instance.GetSoundView().PlaySoundEffects(soundToPlay); - EventService.Instance.PlayerEscapedEvent.InvokeEvent(); + EventService.Instance.OnPlayerEscapedEvent.InvokeEvent(); } } } diff --git a/Assets/Scripts/Events/RatRushEvent.cs b/Assets/Scripts/Events/RatRushEvent.cs index bb27fdc5..4836ecfc 100644 --- a/Assets/Scripts/Events/RatRushEvent.cs +++ b/Assets/Scripts/Events/RatRushEvent.cs @@ -14,6 +14,7 @@ private void OnTriggerEnter(Collider other) if (other.GetComponent() != null) { onRatRush(); + EventService.Instance.OnRatRush.InvokeEvent(); GameService.Instance.GetSoundView().PlaySoundEffects(soundToPlay); GetComponent().enabled = false; } diff --git a/Assets/Scripts/Player/PlayerController.cs b/Assets/Scripts/Player/PlayerController.cs index 709d4f7d..bc2e8478 100644 --- a/Assets/Scripts/Player/PlayerController.cs +++ b/Assets/Scripts/Player/PlayerController.cs @@ -24,14 +24,14 @@ public PlayerController(PlayerView playerView, PlayerScriptableObject playerScri EventService.Instance.OnLightsOffByGhostEvent.AddListener(onLightsOffByGhost); EventService.Instance.OnLightSwitchToggled.AddListener(onLightsToggled); EventService.Instance.OnKeyPickedUp.AddListener(OnKeyPickedUp); - EventService.Instance.PlayerEscapedEvent.AddListener(DisableControls); + EventService.Instance.OnPlayerEscapedEvent.AddListener(DisableControls); } ~PlayerController() { EventService.Instance.OnLightsOffByGhostEvent.RemoveListener(onLightsOffByGhost); EventService.Instance.OnLightSwitchToggled.RemoveListener(onLightsToggled); EventService.Instance.OnKeyPickedUp.RemoveListener(OnKeyPickedUp); - EventService.Instance.PlayerEscapedEvent.RemoveListener(DisableControls); + EventService.Instance.OnPlayerEscapedEvent.RemoveListener(DisableControls); } public void Interact() => IsInteracted = Input.GetKeyDown(KeyCode.E) ? true : (Input.GetKeyUp(KeyCode.E) ? false : IsInteracted); @@ -60,7 +60,7 @@ public void Move(Rigidbody playerRigidbody, Transform transform) public void KillPlayer() { PlayerState = PlayerState.Dead; - EventService.Instance.PlayerDeathEvent.InvokeEvent(); + EventService.Instance.OnPlayerDeathEvent.InvokeEvent(); } private void onLightsOffByGhost() => PlayerState = PlayerState.InDark; diff --git a/Assets/Scripts/Player/PlayerSanity.cs b/Assets/Scripts/Player/PlayerSanity.cs index 6eb89bef..2657ba95 100644 --- a/Assets/Scripts/Player/PlayerSanity.cs +++ b/Assets/Scripts/Player/PlayerSanity.cs @@ -8,6 +8,16 @@ public class PlayerSanity : MonoBehaviour private float maxSanity; private PlayerController playerController; + private void OnEnable() + { + EventService.Instance.OnRatRush.AddListener(OnSupernaturalEvent); + } + + private void OnDisable() + { + EventService.Instance.OnRatRush.RemoveListener(OnSupernaturalEvent); + } + private void Start() { maxSanity = sanityLevel; diff --git a/Assets/Scripts/Service/EventService.cs b/Assets/Scripts/Service/EventService.cs index fdb347e8..b2919c9a 100644 --- a/Assets/Scripts/Service/EventService.cs +++ b/Assets/Scripts/Service/EventService.cs @@ -17,16 +17,19 @@ public static EventService Instance public EventController OnKeyPickedUp { get; private set; } public EventController OnLightsOffByGhostEvent { get; private set; } - public EventController PlayerEscapedEvent { get; private set; } - public EventController PlayerDeathEvent { get; private set; } + public EventController OnPlayerEscapedEvent { get; private set; } + public EventController OnPlayerDeathEvent { get; private set; } + + public EventController OnRatRush { get; private set; } public EventService() { OnLightSwitchToggled = new EventController(); OnKeyPickedUp = new EventController(); OnLightsOffByGhostEvent = new EventController(); + OnRatRush = new EventController(); - PlayerEscapedEvent = new EventController(); - PlayerDeathEvent = new EventController(); + OnPlayerEscapedEvent = new EventController(); + OnPlayerDeathEvent = new EventController(); } } diff --git a/Assets/Scripts/UI/GameUIView.cs b/Assets/Scripts/UI/GameUIView.cs index 01c49482..a6083f19 100644 --- a/Assets/Scripts/UI/GameUIView.cs +++ b/Assets/Scripts/UI/GameUIView.cs @@ -23,9 +23,10 @@ private void OnEnable() { EventService.Instance.OnKeyPickedUp.AddListener(OnKeyEquipped); EventService.Instance.OnLightsOffByGhostEvent.AddListener(SetRedVignette); - EventService.Instance.PlayerEscapedEvent.AddListener(OnPlayerEscaped); - EventService.Instance.PlayerDeathEvent.AddListener(SetRedVignette); - EventService.Instance.PlayerDeathEvent.AddListener(OnPlayerDeath); + EventService.Instance.OnPlayerEscapedEvent.AddListener(OnPlayerEscaped); + EventService.Instance.OnPlayerDeathEvent.AddListener(SetRedVignette); + EventService.Instance.OnPlayerDeathEvent.AddListener(OnPlayerDeath); + EventService.Instance.OnRatRush.AddListener(SetRedVignette); tryAgainButton.onClick.AddListener(OnTryAgainButtonClicked); quitButton.onClick.AddListener(OnQuitButtonClicked); @@ -35,9 +36,10 @@ private void OnDisable() { EventService.Instance.OnKeyPickedUp.RemoveListener(OnKeyEquipped); EventService.Instance.OnLightsOffByGhostEvent.RemoveListener(SetRedVignette); - EventService.Instance.PlayerEscapedEvent.RemoveListener(OnPlayerEscaped); - EventService.Instance.PlayerDeathEvent.RemoveListener(SetRedVignette); - EventService.Instance.PlayerDeathEvent.RemoveListener(OnPlayerDeath); + EventService.Instance.OnPlayerEscapedEvent.RemoveListener(OnPlayerEscaped); + EventService.Instance.OnPlayerDeathEvent.RemoveListener(SetRedVignette); + EventService.Instance.OnPlayerDeathEvent.RemoveListener(OnPlayerDeath); + EventService.Instance.OnRatRush.RemoveListener(SetRedVignette); } public void UpdateInsanity(float playerSanity) => insanityImage.rectTransform.localScale = new Vector3(1, playerSanity, 1); diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 3d6c323f..a7a5887e 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -72,13 +72,13 @@ "depth": 0, "source": "builtin", "dependencies": { - "com.unity.ide.visualstudio": "2.0.17", - "com.unity.ide.rider": "3.0.18", + "com.unity.ide.visualstudio": "2.0.16", + "com.unity.ide.rider": "3.0.15", "com.unity.ide.vscode": "1.2.5", "com.unity.editorcoroutines": "1.0.0", - "com.unity.performance.profile-analyzer": "1.2.2", + "com.unity.performance.profile-analyzer": "1.1.1", "com.unity.test-framework": "1.1.31", - "com.unity.testtools.codecoverage": "1.2.2" + "com.unity.testtools.codecoverage": "1.0.1" } }, "com.unity.ide.rider": { @@ -114,7 +114,7 @@ "url": "https://packages.unity.com" }, "com.unity.performance.profile-analyzer": { - "version": "1.2.2", + "version": "1.1.1", "depth": 1, "source": "registry", "dependencies": {}, @@ -139,7 +139,7 @@ "url": "https://packages.unity.com" }, "com.unity.testtools.codecoverage": { - "version": "1.2.2", + "version": "1.0.1", "depth": 1, "source": "registry", "dependencies": {