From 54bd358962f56a28b07f09aec0e84281bf61f4c4 Mon Sep 17 00:00:00 2001 From: kingjuulian06 <128752981+kingjuulian06@users.noreply.github.com> Date: Wed, 22 Nov 2023 00:21:37 +0100 Subject: [PATCH] UpdatedPauseMenu --- Assets/Scripts/Block2Script.cs | 5 ++++- Assets/Scripts/LogicScript.cs | 20 +++++++++++--------- Assets/Scripts/SmallSpikeScript.cs | 5 ++++- Assets/Scripts/SpikeScript.cs | 5 ++++- Assets/Scripts/TopPartScript.cs | 2 +- Assets/Scripts/jumppad_script.cs | 5 ++++- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/Block2Script.cs b/Assets/Scripts/Block2Script.cs index 9a94c3a5..f2da1dd8 100644 --- a/Assets/Scripts/Block2Script.cs +++ b/Assets/Scripts/Block2Script.cs @@ -8,16 +8,19 @@ public class Block2Script : MonoBehaviour public float deadZone = -15; public BlockScript player; + public LogicScript logic; + // Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + logic = GameObject.FindGameObjectWithTag("Logic").GetComponent(); } // Update is called once per frame void Update() { - if (player.IsAlive) { + if (player.IsAlive||!logic.IsFreezed) { transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime; } diff --git a/Assets/Scripts/LogicScript.cs b/Assets/Scripts/LogicScript.cs index 4f2c1f99..3ce4ffc3 100644 --- a/Assets/Scripts/LogicScript.cs +++ b/Assets/Scripts/LogicScript.cs @@ -6,8 +6,8 @@ using UnityEngine.SceneManagement; public class LogicScript : MonoBehaviour { - private int playerScore; - public Text scoreText; + + public bool IsFreezed = false; public GameObject gameOverScreen; public GameObject pauseMenu; public AudioSource BG_Music; @@ -25,18 +25,13 @@ public class LogicScript : MonoBehaviour bgscript = GameObject.FindGameObjectWithTag("Background").GetComponent(); } - public void addScore(int scoreToAdd){ - playerScore += scoreToAdd; - scoreText.text = playerScore.ToString(); - } - public void addJump() { playerJumps += 1; jumpsText.text = playerJumps.ToString() + " Jumps"; } public void addTime() { - playTime += Time; + //playTime += Time; timeText.text = playTime.ToString() + " Seconds"; } @@ -51,10 +46,17 @@ public class LogicScript : MonoBehaviour } void Update() { - if (Input.GetKeyDown(KeyCode.Escape)) { + if (Input.GetKeyDown(KeyCode.Escape)||!IsFreezed) { + IsFreezed = true; pauseMenu.SetActive(true); BG_Music.Stop(); bgscript.ScrollSpeed = 0f; } + else { + IsFreezed = false; + pauseMenu.SetActive(false); + BG_Music.Play(); + bgscript.ScrollSpeed = 1f; + } } } diff --git a/Assets/Scripts/SmallSpikeScript.cs b/Assets/Scripts/SmallSpikeScript.cs index a5e6395c..807acdef 100644 --- a/Assets/Scripts/SmallSpikeScript.cs +++ b/Assets/Scripts/SmallSpikeScript.cs @@ -8,16 +8,19 @@ public class SmallSpikeScript : MonoBehaviour public float deadZone = -15; public BlockScript player; + public LogicScript logic; + // Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + logic = GameObject.FindGameObjectWithTag("Logic").GetComponent(); } // Update is called once per frame void Update() { - if (player.IsAlive) { + if (player.IsAlive||!logic.IsFreezed) { transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime; } diff --git a/Assets/Scripts/SpikeScript.cs b/Assets/Scripts/SpikeScript.cs index a3bccea7..8f9649f3 100644 --- a/Assets/Scripts/SpikeScript.cs +++ b/Assets/Scripts/SpikeScript.cs @@ -8,16 +8,19 @@ public class SpikeScript : MonoBehaviour public float deadZone = -15; public BlockScript player; + public LogicScript logic; + // Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + logic = GameObject.FindGameObjectWithTag("Logic").GetComponent(); } // Update is called once per frame void Update() { - if (player.IsAlive) { + if (player.IsAlive||!logic.IsFreezed) { transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime; } diff --git a/Assets/Scripts/TopPartScript.cs b/Assets/Scripts/TopPartScript.cs index e422369c..e79b1126 100644 --- a/Assets/Scripts/TopPartScript.cs +++ b/Assets/Scripts/TopPartScript.cs @@ -20,7 +20,7 @@ public class TopPartScript : MonoBehaviour private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.layer == 3){ - logic.addScore(1); + } } } diff --git a/Assets/Scripts/jumppad_script.cs b/Assets/Scripts/jumppad_script.cs index a973938b..2eea589b 100644 --- a/Assets/Scripts/jumppad_script.cs +++ b/Assets/Scripts/jumppad_script.cs @@ -13,17 +13,20 @@ public class jumppad_script : MonoBehaviour public float duration; public SpriteRenderer m_SR; + public LogicScript logic; + // Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent(); m_SR = GetComponent(); + logic = GameObject.FindGameObjectWithTag("Logic").GetComponent(); } // Update is called once per frame void Update() { - if (player.IsAlive) { + if (player.IsAlive||!logic.IsFreezed) { transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime; }