diff --git a/Assets/Scenes/TestPetLich.unity b/Assets/Scenes/TestPetLich.unity index f2e64d5ce4dcd06898ec1d6c3ca893f081eb9e71..a61212c2189f516b3e6bcbca3ff532005b82560a 100644 --- a/Assets/Scenes/TestPetLich.unity +++ b/Assets/Scenes/TestPetLich.unity @@ -213,6 +213,10 @@ PrefabInstance: propertyPath: weapon value: objectReference: {fileID: 1003343662} + - target: {fileID: 6649821425492048567, guid: 50754b1bd29cde544bf7b1e78400a3fd, type: 3} + propertyPath: player + value: + objectReference: {fileID: 624092162} - target: {fileID: 9140073484006322690, guid: 50754b1bd29cde544bf7b1e78400a3fd, type: 3} propertyPath: player value: @@ -800,6 +804,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: speed: 6 + pet: 0 + Pets: [] --- !u!82 &624092164 AudioSource: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Pet/PetHealth.cs b/Assets/Scripts/Pet/PetHealth.cs index 0a079a06ec79ec6ac75dc07e9edb7aae5ad3b43c..207128fb0fa3a6ea78c6f23751bfdf690f218e7f 100644 --- a/Assets/Scripts/Pet/PetHealth.cs +++ b/Assets/Scripts/Pet/PetHealth.cs @@ -16,6 +16,14 @@ public class PetHealth : MonoBehaviour, Attackable private Rigidbody rb; private AudioSource petAudio; + // For cheat + private bool isImmortal = false; + private bool isTyping = false; + private string CHEAT_CODE_KILL = "kill"; + private string CHEAT_CODE_IMMORTAL = "imt"; + private string cheat = ""; + private float timer = 0f; + // Start is called before the first frame update void Awake() { @@ -30,7 +38,37 @@ public class PetHealth : MonoBehaviour, Attackable // Update is called once per frame void Update() { - // Do something + if (isTyping) { + if (Input.anyKey) { + cheat += Input.inputString; + // Debug.Log(cheat); + + if (cheat == CHEAT_CODE_KILL) { + currentHealth = 0; + TakeDamage(1); + + isTyping = false; + // Debug.Log("Killed pet"); + } else if (cheat == CHEAT_CODE_IMMORTAL) { + isImmortal = !isImmortal; + + isTyping = false; + // Debug.Log("Immortal: " + isImmortal); + } + } + + timer += Time.deltaTime; + if (timer >= 3f) { + isTyping = false; + cheat = ""; + } + } else { + if (Input.GetKeyDown("k") || Input.GetKeyDown("i")) { + cheat += Input.inputString; + isTyping = true; + timer = 0f; + } + } } public void TakeDamage(int amount) @@ -38,6 +76,9 @@ public class PetHealth : MonoBehaviour, Attackable if (isDead) return; + if (isImmortal) + return; + currentHealth -= (amount - armor); petAudio.Play();