diff --git a/Assets/Scripts/Cheat/DebugController.cs b/Assets/Scripts/Cheat/DebugController.cs index 2405c3d42df731c2a8a2ffa3f8c33e74a61c9208..3ea0a7d1394d3d863c1b0be1c1ae37e8594b70fe 100644 --- a/Assets/Scripts/Cheat/DebugController.cs +++ b/Assets/Scripts/Cheat/DebugController.cs @@ -1,115 +1,115 @@ -//using System.Collections.Generic; -//using Unity.VisualScripting; -//using UnityEngine; -//using UnityEngine.InputSystem; - -//public class DebugController : MonoBehaviour -//{ -// bool showConsole; - -// public static DebugCommand NO_DAMAGE; -// public static DebugCommand ONE_HIT_KILL; -// public static DebugCommand MOTHERLODE; -// public static DebugCommand DOUBLE_SPEED; -// public static DebugCommand PET_FULL_HP; -// public static DebugCommand KILL_PET; -// public static DebugCommand ORB; -// public static DebugCommand SKIP_LEVEL; - -// public List<object> commandList; - -// public void OnToggleDebug(InputValue value) -// { -// showConsole = !showConsole; -// } - -// public void OnReturn(InputValue value) -// { -// if (showConsole) -// { -// HandleInput(); -// input = ""; -// } -// } - -// private void Awake() -// { -// NO_DAMAGE = new DebugCommand("no_damage", "Player Has No Damage.", "no_damage", () => -// { - -// }); - -// ONE_HIT_KILL = new DebugCommand("one_hit_kill", "Player Can Kill Enemy with One Hit.", "one_hit_kill", () => -// { - -// }); - -// MOTHERLODE = new DebugCommand("motherlode", "Gain Resources.", "motherlode", () => -// { - -// }); - -// DOUBLE_SPEED = new DebugCommand("double_speed", "Double Player Speed.", "double_speed", () => -// { - -// }); - -// PET_FULL_HP = new DebugCommand("pet_full_hp", "Restore Pet's Health to Full.", "pet_full_hp", () => -// { - -// }); - -// KILL_PET = new DebugCommand("kill_pet", "Kill Pet.", "kill_pet", () => -// { - -// }); - -// ORB = new DebugCommand("orb", "Spawn Orb.", "orb", () => -// { - -// }); - -// SKIP_LEVEL = new DebugCommand("skip_level", "Skip Current Level.", "skip_level", () => -// { - -// }); - - -// commandList = new List<object> -// { -// NO_DAMAGE, -// ONE_HIT_KILL, -// MOTHERLODE, -// DOUBLE_SPEED, -// PET_FULL_HP, -// KILL_PET, -// ORB, -// SKIP_LEVEL -// }; -// } - - -// private void OnGUI() -// { -// if (!showConsole) { return; } - -// float y = 0f; - -// GUI.Box(new Rect(0, y, Screen.width, 30), ""); -// GUI.backgroundColor = new Color(0, 0, 0, 0); -// input = GUI.TextField(new Rect(10f, y + 5f, Screen.width - 20f, 20f), input); -// } - -// private void HandleInput() -// { -// for (int i = 0; i < commandList.Count; i++) -// { -// DebugCommandBase commandBase = commandList[i] as DebugCommandBase; - -// if (input.Contains(commandBase.commandId)) -// { -// (commandList[i] as DebugCommand).Invoke(); -// } -// } -// } -//} \ No newline at end of file +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; +using UnityEngine.InputSystem; + +public class DebugController : MonoBehaviour +{ + bool showConsole; + + public static DebugCommand NO_DAMAGE; + public static DebugCommand ONE_HIT_KILL; + public static DebugCommand MOTHERLODE; + public static DebugCommand DOUBLE_SPEED; + public static DebugCommand PET_FULL_HP; + public static DebugCommand KILL_PET; + public static DebugCommand ORB; + public static DebugCommand SKIP_LEVEL; + + public List<object> commandList; + + public void OnToggleDebug(InputValue value) + { + showConsole = !showConsole; + } + + public void OnReturn(InputValue value) + { + if (showConsole) + { + HandleInput(); + input = ""; + } + } + + private void Awake() + { + NO_DAMAGE = new DebugCommand("no_damage", "Player Has No Damage.", "no_damage", () => + { + + }); + + ONE_HIT_KILL = new DebugCommand("one_hit_kill", "Player Can Kill Enemy with One Hit.", "one_hit_kill", () => + { + + }); + + MOTHERLODE = new DebugCommand("motherlode", "Gain Resources.", "motherlode", () => + { + + }); + + DOUBLE_SPEED = new DebugCommand("double_speed", "Double Player Speed.", "double_speed", () => + { + + }); + + PET_FULL_HP = new DebugCommand("pet_full_hp", "Restore Pet's Health to Full.", "pet_full_hp", () => + { + + }); + + KILL_PET = new DebugCommand("kill_pet", "Kill Pet.", "kill_pet", () => + { + + }); + + ORB = new DebugCommand("orb", "Spawn Orb.", "orb", () => + { + + }); + + SKIP_LEVEL = new DebugCommand("skip_level", "Skip Current Level.", "skip_level", () => + { + + }); + + + commandList = new List<object> + { + NO_DAMAGE, + ONE_HIT_KILL, + MOTHERLODE, + DOUBLE_SPEED, + PET_FULL_HP, + KILL_PET, + ORB, + SKIP_LEVEL + }; + } + + + private void OnGUI() + { + if (!showConsole) { return; } + + float y = 0f; + + GUI.Box(new Rect(0, y, Screen.width, 30), ""); + GUI.backgroundColor = new Color(0, 0, 0, 0); + input = GUI.TextField(new Rect(10f, y + 5f, Screen.width - 20f, 20f), input); + } + + private void HandleInput() + { + for (int i = 0; i < commandList.Count; i++) + { + DebugCommandBase commandBase = commandList[i] as DebugCommandBase; + + if (input.Contains(commandBase.commandId)) + { + (commandList[i] as DebugCommand).Invoke(); + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerHealth.cs b/Assets/Scripts/Player/PlayerHealth.cs index 497dbddf1cbaef488a185f36942225b4bd3187d8..3eb82ac101f2b731d46fba0f6ad1ebb4020abf96 100644 --- a/Assets/Scripts/Player/PlayerHealth.cs +++ b/Assets/Scripts/Player/PlayerHealth.cs @@ -115,5 +115,11 @@ namespace Nightmare { EventManager.TriggerEvent("GameOver"); } + + private void CheatNoDamage() + { + godMode = true; + currentHealth = int.MaxValue; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 7407c3ba72625b86b6f6bd339c1a38960f0b9244..30e91f45e1688d68735cb12ec94ac1cdbfec6877 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -14,6 +14,7 @@ namespace Nightmare #if !MOBILE_INPUT int floorMask; // A layer mask so that a ray can be cast just at gameobjects on the floor layer. float camRayLength = 100f; // The length of the ray from the camera into the scene. + bool isDoubleSpeed = false; #endif void Awake () @@ -122,5 +123,11 @@ namespace Nightmare // Tell the animator whether or not the player is walking. anim.SetBool ("IsWalking", walking); } + + private void CheatDoubleSpeed() + { + isDoubleSpeed = true; + speed = speed * 2; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerShooting.cs b/Assets/Scripts/Player/PlayerShooting.cs index 644f10594337f2dc191fbb635cb236f65882a699..d5ddc786140c0a15018619355241c3af8af32083 100644 --- a/Assets/Scripts/Player/PlayerShooting.cs +++ b/Assets/Scripts/Player/PlayerShooting.cs @@ -14,6 +14,8 @@ namespace Nightmare public float grenadeSpeed = 200f; public float grenadeFireDelay = 0.5f; + bool isOneHitKill = false; + float timer; Ray shootRay = new Ray(); RaycastHit shootHit; @@ -187,5 +189,40 @@ namespace Nightmare //Grenade grenadeClone = clone.GetComponent<Grenade>(); //grenadeClone.Shoot(grenadeSpeed * transform.forward); } + + private void CheatOneHitKill() + { + isOneHitKill = true; + damagePerShot = 9999; + } + + + private void CheatPetFullHP() + { + // Pulihkan kesehatan pet ke penuh + // Misalnya: + // petHealth.RestoreHealth(); + } + + private void CheatKillPet() + { + // Bunuh pet + // Misalnya: + // petHealth.TakeDamage(petHealth.CurrentHealth()); + } + + private void CheatOrb() + { + // Hasilkan orb + // Misalnya: + // orbSpawner.SpawnOrb(); + } + + private void CheatSkipLevel() + { + // Loncati level saat ini + // Misalnya: + // levelManager.LoadNextLevel(); + } } } \ No newline at end of file