From 5e473c3e53cac52097c1659f2a33c2e99b588c61 Mon Sep 17 00:00:00 2001 From: Zeus-s <kristabdixx@gmail.com> Date: Fri, 14 Apr 2023 15:29:02 +0700 Subject: [PATCH] feat: add cheat script --- Assets/Scripts/Menu/CheatMenu.cs | 67 +++++++++++++++++++++++++++ Assets/Scripts/Menu/CheatMenu.cs.meta | 11 +++++ 2 files changed, 78 insertions(+) create mode 100644 Assets/Scripts/Menu/CheatMenu.cs create mode 100644 Assets/Scripts/Menu/CheatMenu.cs.meta diff --git a/Assets/Scripts/Menu/CheatMenu.cs b/Assets/Scripts/Menu/CheatMenu.cs new file mode 100644 index 00000000..47600828 --- /dev/null +++ b/Assets/Scripts/Menu/CheatMenu.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.SceneManagement; + +public class CheatMenu : MonoBehaviour +{ + public GameObject cheatMenu; + public Button btn; + public InputField inputText; + public static bool isCheatOpened; + public static bool nodamage = false; + public static bool hitkill = false; + public static bool speed2x = false; + public static bool fullhppet = false; + public static bool motherlode = false; + public static bool killpet = false; + // Start is called before the first frame update + void Start() + { + btn.onClick.AddListener(GetInputOnClickHandler); + cheatMenu.SetActive(false); + isCheatOpened = false; + } + + // Update is called once per frame + void Update() + { + if (Input.GetKeyDown(KeyCode.L)) { + if (isCheatOpened) { + ResumeGame(); + } else { + OpenCheatMenu(); + } + } + } + + public void GetInputOnClickHandler() { + string cheatInput = inputText.text; + if (cheatInput == "1hitkill") { + hitkill = true; + } else if (cheatInput == "immortal") { + nodamage = true; + } else if (cheatInput == "kecepatanusainbolt") { + speed2x = true; + } else if (cheatInput == "fullhppet") { + fullhppet = true; + } else if (cheatInput == "motherlode") { + motherlode = true; + } else if (cheatInput == "killpet") { + killpet = true; + } + } + + public void OpenCheatMenu() { + cheatMenu.SetActive(true); + Time.timeScale = 0f; + isCheatOpened = true; + } + + public void ResumeGame() { + cheatMenu.SetActive(false); + Time.timeScale = 1f; + isCheatOpened = false; + } +} diff --git a/Assets/Scripts/Menu/CheatMenu.cs.meta b/Assets/Scripts/Menu/CheatMenu.cs.meta new file mode 100644 index 00000000..ef11d2dd --- /dev/null +++ b/Assets/Scripts/Menu/CheatMenu.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ffb016fd68072834bae3e00097d49897 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- GitLab