UpdatedPauseMenu

This commit is contained in:
kingjuulian06 2023-11-22 00:21:37 +01:00
parent 0b8d48c207
commit 54bd358962
6 changed files with 28 additions and 14 deletions

View File

@ -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<BlockScript>();
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}
// 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;
}

View File

@ -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<BackgroundScroller>();
}
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;
}
}
}

View File

@ -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<BlockScript>();
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}
// 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;
}

View File

@ -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<BlockScript>();
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}
// 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;
}

View File

@ -20,7 +20,7 @@ public class TopPartScript : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision) {
if (collision.gameObject.layer == 3){
logic.addScore(1);
}
}
}

View File

@ -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<BlockScript>();
m_SR = GetComponent<SpriteRenderer>();
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
}
// 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;
}