diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 6a28562ed9e11bd257893b35d599227e47e381a9..20cb0449ecb63b993dbec1bb11dad28eb211fa3d 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 8900000, guid: a7bed68887a07e34394d4191b3081359, type: 3} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.100039154, g: 0.11809585, b: 0.11640041, a: 1} + m_IndirectSpecularColor: {r: 0.10003871, g: 0.118095554, b: 0.11640027, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &4 LightmapSettings: @@ -2774,7 +2774,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1124016429} - - component: {fileID: 1074333545} - component: {fileID: 1124016430} - component: {fileID: 1124016431} - component: {fileID: 1124016432} @@ -2785,23 +2784,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &1074333545 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1074333544} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: aa10cc87aff30c04dbe0aa648f5b6adc, type: 3} - m_Name: - m_EditorClassIdentifier: - startingHealth: 100 - sinkSpeed: 2.5 - scoreValue: 10 - deathClip: {fileID: 0} - isCheatOneHitKill: 0 --- !u!4 &1124016429 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Enemy/EnemyHealth.cs b/Assets/Scripts/Enemy/EnemyHealth.cs index 4be00f9aa69918788253ccf1e45bc279e129f59b..378275d71306a885ef46c6619149022ca679d380 100644 --- a/Assets/Scripts/Enemy/EnemyHealth.cs +++ b/Assets/Scripts/Enemy/EnemyHealth.cs @@ -18,7 +18,6 @@ namespace Nightmare // Cheat One Hit Kill public bool isCheatOneHitKill = false; - public static bool IsActiveCheatOneHitKill = false; // For indicator to change isCheatOneHitKill void Awake () { @@ -43,8 +42,6 @@ namespace Nightmare void Update () { - SetCheatOneHitKill(IsActiveCheatOneHitKill); - if (IsDead()) { transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime); @@ -60,26 +57,10 @@ namespace Nightmare return (currentHealth <= 0f); } - // Activate or deactivate cheat one hit kill - public void SetCheatOneHitKill(bool isActive) - { - // Get an array of all EnemyHealth scripts - EnemyHealth[] allEnemies = FindObjectsOfType<EnemyHealth>(); - - // Loop and set isCheatOneHitKill to true on each enemy - foreach (EnemyHealth eHealth in allEnemies) - { - eHealth.isCheatOneHitKill = isActive; - } - - // Change indicator - IsActiveCheatOneHitKill = isActive; - } - public void TakeDamage (int amount, Vector3 hitPoint) { if (!IsDead()) - { + { // Cheat one hit kill if (isCheatOneHitKill) { diff --git a/Assets/Scripts/Managers/CheatManager.cs b/Assets/Scripts/Managers/CheatManager.cs index 0298eb2b438af595a02bbea36828e5f8517b1ebe..8553e6dc860c917b24e21c4768f562025b11942b 100644 --- a/Assets/Scripts/Managers/CheatManager.cs +++ b/Assets/Scripts/Managers/CheatManager.cs @@ -22,11 +22,10 @@ public class CheatManager : MonoBehaviour HUDisplay hud; PlayerHealth playerHealth; PlayerMovement playerMovement; - EnemyHealth enemyHealth; string textInput; public InputField inputField; - // Cheats + public static bool GlobalIsCheatOneHitKill = false; // Flag for One Hit Kill Cheat bool[] cheats = new bool[4]; private void Start() @@ -34,20 +33,19 @@ public class CheatManager : MonoBehaviour hud = GameObject.Find("HUDCanvas").GetComponent<HUDisplay>(); playerHealth = GameObject.Find("Player").GetComponent<PlayerHealth>(); playerMovement = GameObject.Find("Player").GetComponent<PlayerMovement>(); - enemyHealth = GameObject.Find("GameManager").GetComponent<EnemyHealth>(); } private void Update() { // Reason: the read string conditionals do not contain Y or Z character // Open input field by pressing Y key - if (UnityEngine.Input.GetKeyDown(KeyCode.Y)) + if (UnityEngine.Input.GetKeyDown(KeyCode.Y)) { hud.OpenInput(); } // Close input field by pressing Z key - if (UnityEngine.Input.GetKeyDown(KeyCode.Z)) + if (UnityEngine.Input.GetKeyDown(KeyCode.Z)) { hud.CloseInput(); } @@ -98,6 +96,7 @@ public class CheatManager : MonoBehaviour hud.CloseInput(); return; } + return; } private void ActivateNoDamage() @@ -109,7 +108,7 @@ public class CheatManager : MonoBehaviour private void ActivateOneHitKill() { - enemyHealth.SetCheatOneHitKill(true); + StartCoroutine(SetOneHitKill(true)); hud.OpenPanel("One Hit Kill Cheat Activated!"); cheats[(int)CheatsType.ONEHITKILL] = true; } @@ -125,24 +124,42 @@ public class CheatManager : MonoBehaviour { playerHealth.SetCheatNoDamage(false); playerMovement.ResetSpeed(); - enemyHealth.SetCheatOneHitKill(false); + StopCoroutine(SetOneHitKill(false)); + GlobalIsCheatOneHitKill = false; hud.OpenPanel("Successfully Reset Cheat(s)!"); } public void LoadCheat(bool[] gatheredCheats) { - if (gatheredCheats[(int) CheatsType.NODAMAGE]) + if (gatheredCheats[(int)CheatsType.NODAMAGE]) { ActivateNoDamage(); } - if (gatheredCheats[(int) CheatsType.ONEHITKILL]) + if (gatheredCheats[(int)CheatsType.ONEHITKILL]) { ActivateOneHitKill(); } - if (gatheredCheats[(int) CheatsType.XTWOSPEED]) + if (gatheredCheats[(int)CheatsType.XTWOSPEED]) { ActivateXTwoSpeed(); } } + private IEnumerator SetOneHitKill(bool isActive) + { + GlobalIsCheatOneHitKill = isActive; + while (true) { + // Get an array of all EnemyHealth scripts + EnemyHealth[] allEnemies = FindObjectsOfType<EnemyHealth>(); + + // Loop and set isCheatOneHitKill to true on each enemy + foreach (EnemyHealth eHealth in allEnemies) + { + eHealth.isCheatOneHitKill = GlobalIsCheatOneHitKill; + } + + yield return null; + } + + } }