Skip to content
Snippets Groups Projects
Commit a4b00882 authored by GoDillonAudris512's avatar GoDillonAudris512
Browse files

feat: able to pause the game

parent c0ce22a1
Branches
Tags
No related merge requests found
This diff is collapsed.
......@@ -2,9 +2,7 @@
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Audio;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.SceneManagement;
public class PauseManager : MonoBehaviour {
......@@ -12,7 +10,7 @@ public class PauseManager : MonoBehaviour {
public AudioMixerSnapshot unpaused;
Canvas canvas;
//
void Start()
{
canvas = GetComponent<Canvas>();
......@@ -50,10 +48,6 @@ public class PauseManager : MonoBehaviour {
public void Quit()
{
#if UNITY_EDITOR
EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
SceneManager.LoadScene("MainMenu");
}
}
......@@ -19,6 +19,9 @@ namespace Nightmare
// Update is called once per frame
void Update()
{
if (Time.timeScale == 0)
return;
// Listen for number key
for (int i = 0; i < weapons.Length; i++)
{
......
......@@ -3,7 +3,7 @@ using UnitySampleAssets.CrossPlatformInput;
namespace Nightmare
{
public class PlayerMovement : PausibleObject
public class PlayerMovement : MonoBehaviour
{
public float speed = 6f; // The speed that the player will move at.
......@@ -27,19 +27,14 @@ namespace Nightmare
// Set up references.
anim = GetComponent <Animator> ();
playerRigidbody = GetComponent <Rigidbody> ();
StartPausible();
}
void OnDestroy()
{
StopPausible();
}
void FixedUpdate ()
{
if (isPaused)
if (Time.timeScale == 0)
{
return;
}
// Store the input axes.
float h = CrossPlatformInputManager.GetAxisRaw("Horizontal");
......
......@@ -5,12 +5,11 @@ using UnitySampleAssets.CrossPlatformInput;
namespace Nightmare
{
public class GunAttack : PausibleObject
public class GunAttack : MonoBehaviour
{
public int damagePerShot = 20;
public float timeBetweenBullets = 0.15f;
public float range = 100f;
public bool isOneHitKill = false;
float timer;
Ray shootRay = new Ray();
......@@ -30,18 +29,10 @@ namespace Nightmare
gunLine = GetComponent <LineRenderer> ();
gunAudio = GetComponent<AudioSource> ();
gunLight = GetComponent<Light> ();
StartPausible();
}
void OnDestroy()
{
StopPausible();
}
void Update ()
{
if (isPaused)
if (Time.timeScale == 0)
return;
timer += Time.deltaTime;
......@@ -67,9 +58,6 @@ namespace Nightmare
void Shoot ()
{
if (isPaused)
return;
timer = 0f;
gunAudio.Play ();
......@@ -98,32 +86,5 @@ namespace Nightmare
gunLine.SetPosition (1, shootRay.origin + shootRay.direction * range);
}
}
public void CheatOneHitKill()
{
isOneHitKill = true;
damagePerShot = 9999;
}
public void CheatKillPet()
{
// Bunuh pet
// Misalnya:
// petHealth.TakeDamage(petHealth.CurrentHealth());
}
public void CheatOrb()
{
// Hasilkan orb
// Misalnya:
// orbSpawner.SpawnOrb();
}
public void CheatSkipLevel()
{
// Loncati level saat ini
// Misalnya:
// levelManager.LoadNextLevel();
}
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ using UnityEngine.UI;
namespace Nightmare
{
public class ShotgunAttack : PausibleObject
public class ShotgunAttack : MonoBehaviour
{
public int damagePerBullet = 5;
public float timeBetweenBullets = 0.25f;
......@@ -41,18 +41,11 @@ namespace Nightmare
}
gunAudio = GetComponent<AudioSource>();
gunLight = GetComponent<Light>();
StartPausible();
}
void OnDestroy()
{
StopPausible();
}
void Update()
{
if (isPaused)
if (Time.timeScale == 0)
return;
timer += Time.deltaTime;
......@@ -81,9 +74,6 @@ namespace Nightmare
void Shoot()
{
if (isPaused)
return;
timer = 0f;
gunAudio.Play();
......
......@@ -4,7 +4,7 @@ using UnityEngine;
namespace Nightmare
{
public class SwordAttack : PausibleObject
public class SwordAttack : MonoBehaviour
{
// Variables
Animator anim;
......@@ -20,18 +20,12 @@ namespace Nightmare
{
anim = GetComponent<Animator>();
boxCollider = GetComponent<BoxCollider>();
StartPausible();
}
void OnDestroy()
{
StopPausible();
}
// Update is called once per frame
void Update()
{
if (isPaused)
if (Time.timeScale == 0)
return;
if (Input.GetButton("Fire1") && CanAttack)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment