UpdatedPauseMenu
This commit is contained in:
parent
0b8d48c207
commit
54bd358962
@ -8,16 +8,19 @@ public class Block2Script : MonoBehaviour
|
|||||||
public float deadZone = -15;
|
public float deadZone = -15;
|
||||||
public BlockScript player;
|
public BlockScript player;
|
||||||
|
|
||||||
|
public LogicScript logic;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
||||||
|
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (player.IsAlive) {
|
if (player.IsAlive||!logic.IsFreezed) {
|
||||||
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,8 @@ using UnityEngine.SceneManagement;
|
|||||||
|
|
||||||
public class LogicScript : MonoBehaviour
|
public class LogicScript : MonoBehaviour
|
||||||
{
|
{
|
||||||
private int playerScore;
|
|
||||||
public Text scoreText;
|
public bool IsFreezed = false;
|
||||||
public GameObject gameOverScreen;
|
public GameObject gameOverScreen;
|
||||||
public GameObject pauseMenu;
|
public GameObject pauseMenu;
|
||||||
public AudioSource BG_Music;
|
public AudioSource BG_Music;
|
||||||
@ -25,18 +25,13 @@ public class LogicScript : MonoBehaviour
|
|||||||
bgscript = GameObject.FindGameObjectWithTag("Background").GetComponent<BackgroundScroller>();
|
bgscript = GameObject.FindGameObjectWithTag("Background").GetComponent<BackgroundScroller>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addScore(int scoreToAdd){
|
|
||||||
playerScore += scoreToAdd;
|
|
||||||
scoreText.text = playerScore.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addJump() {
|
public void addJump() {
|
||||||
playerJumps += 1;
|
playerJumps += 1;
|
||||||
jumpsText.text = playerJumps.ToString() + " Jumps";
|
jumpsText.text = playerJumps.ToString() + " Jumps";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTime() {
|
public void addTime() {
|
||||||
playTime += Time;
|
//playTime += Time;
|
||||||
timeText.text = playTime.ToString() + " Seconds";
|
timeText.text = playTime.ToString() + " Seconds";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,10 +46,17 @@ public class LogicScript : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
if (Input.GetKeyDown(KeyCode.Escape)) {
|
if (Input.GetKeyDown(KeyCode.Escape)||!IsFreezed) {
|
||||||
|
IsFreezed = true;
|
||||||
pauseMenu.SetActive(true);
|
pauseMenu.SetActive(true);
|
||||||
BG_Music.Stop();
|
BG_Music.Stop();
|
||||||
bgscript.ScrollSpeed = 0f;
|
bgscript.ScrollSpeed = 0f;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
IsFreezed = false;
|
||||||
|
pauseMenu.SetActive(false);
|
||||||
|
BG_Music.Play();
|
||||||
|
bgscript.ScrollSpeed = 1f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,16 +8,19 @@ public class SmallSpikeScript : MonoBehaviour
|
|||||||
public float deadZone = -15;
|
public float deadZone = -15;
|
||||||
public BlockScript player;
|
public BlockScript player;
|
||||||
|
|
||||||
|
public LogicScript logic;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
||||||
|
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (player.IsAlive) {
|
if (player.IsAlive||!logic.IsFreezed) {
|
||||||
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,16 +8,19 @@ public class SpikeScript : MonoBehaviour
|
|||||||
public float deadZone = -15;
|
public float deadZone = -15;
|
||||||
public BlockScript player;
|
public BlockScript player;
|
||||||
|
|
||||||
|
public LogicScript logic;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
||||||
|
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (player.IsAlive) {
|
if (player.IsAlive||!logic.IsFreezed) {
|
||||||
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public class TopPartScript : MonoBehaviour
|
|||||||
|
|
||||||
private void OnTriggerEnter2D(Collider2D collision) {
|
private void OnTriggerEnter2D(Collider2D collision) {
|
||||||
if (collision.gameObject.layer == 3){
|
if (collision.gameObject.layer == 3){
|
||||||
logic.addScore(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,17 +13,20 @@ public class jumppad_script : MonoBehaviour
|
|||||||
public float duration;
|
public float duration;
|
||||||
public SpriteRenderer m_SR;
|
public SpriteRenderer m_SR;
|
||||||
|
|
||||||
|
public LogicScript logic;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
player = GameObject.FindGameObjectWithTag("Player").GetComponent<BlockScript>();
|
||||||
m_SR = GetComponent<SpriteRenderer>();
|
m_SR = GetComponent<SpriteRenderer>();
|
||||||
|
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (player.IsAlive) {
|
if (player.IsAlive||!logic.IsFreezed) {
|
||||||
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user