2020-01-18 12:23:59 -05:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
2020-01-18 23:10:16 -05:00
|
|
|
using TMPro;
|
2020-01-27 21:34:58 -05:00
|
|
|
using UnityEngine.EventSystems;
|
2020-01-18 12:23:59 -05:00
|
|
|
|
|
|
|
|
public class PauseMenu : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static bool GameIsPaused = false;
|
2020-01-18 23:10:16 -05:00
|
|
|
public static bool GameIsOver = false;
|
2020-01-18 12:23:59 -05:00
|
|
|
|
|
|
|
|
public GameObject pauseMenuUI;
|
2020-01-18 23:10:16 -05:00
|
|
|
public GameObject gameOverUI;
|
|
|
|
|
|
|
|
|
|
public TextMeshProUGUI ScoreText;
|
|
|
|
|
public TextMeshProUGUI TimeText;
|
2020-01-19 20:59:20 -05:00
|
|
|
public TextMeshProUGUI LivesText;
|
2020-01-18 12:23:59 -05:00
|
|
|
|
2020-02-03 21:36:56 -05:00
|
|
|
public TextMeshProUGUI HighScoreText;
|
|
|
|
|
public TextMeshProUGUI HighTimeText;
|
|
|
|
|
public TextMeshProUGUI CongratsText;
|
|
|
|
|
|
2020-01-27 21:34:58 -05:00
|
|
|
public GameObject pauseFirstButton;
|
|
|
|
|
public GameObject gameOverFirstButton;
|
|
|
|
|
|
2020-02-03 21:36:56 -05:00
|
|
|
private bool highscore = false;
|
2020-01-27 23:32:13 -05:00
|
|
|
private int gameOver = 0;
|
|
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
2020-01-19 20:59:20 -05:00
|
|
|
|
2020-01-27 23:32:13 -05:00
|
|
|
if(SceneManager.GetActiveScene().name == "Floor Level")
|
|
|
|
|
{
|
|
|
|
|
ScoreText.text = "LEVEL: " + FloorLevel.escalation + "-" + FloorLevel.level;
|
|
|
|
|
LivesText.text = "LIVES: " + PlayerController.shownLives;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(SceneManager.GetActiveScene().name == "Waypoint Race")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ScoreText.text = "LEVEL: " + (WaypointRace.size - 1) + "-" + WaypointRace.level;
|
|
|
|
|
TimeText.text = "TIME: " + Mathf.Round((WaypointRace.countdown + WaypointRace.completionTime) - Time.time);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 22:59:06 -05:00
|
|
|
if(SceneManager.GetActiveScene().name == "Infinity Runner")
|
|
|
|
|
{
|
|
|
|
|
ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level;
|
|
|
|
|
LivesText.text = "LIVES: " + PlayerController.shownLives;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
if(Input.GetButtonDown("Pause"))
|
|
|
|
|
{
|
|
|
|
|
if(GameIsPaused)
|
|
|
|
|
{
|
|
|
|
|
Resume();
|
2020-01-26 23:03:41 -05:00
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
} else {
|
2020-01-26 23:03:41 -05:00
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
Pause();
|
2020-01-26 23:03:41 -05:00
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-18 23:10:16 -05:00
|
|
|
if(GameIsOver)
|
|
|
|
|
{
|
|
|
|
|
GameOver();
|
2020-01-27 23:32:13 -05:00
|
|
|
|
|
|
|
|
if(gameOver == 0)
|
|
|
|
|
{
|
|
|
|
|
EventSystem.current.SetSelectedGameObject(null);
|
|
|
|
|
EventSystem.current.SetSelectedGameObject(gameOverFirstButton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gameOver++;
|
|
|
|
|
|
2020-01-18 23:10:16 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Resume()
|
|
|
|
|
{
|
2020-01-26 23:03:41 -05:00
|
|
|
Cursor.visible = false;
|
|
|
|
|
Cursor.lockState = CursorLockMode.Locked;
|
2020-01-18 12:23:59 -05:00
|
|
|
pauseMenuUI.SetActive(false);
|
2020-01-26 23:03:41 -05:00
|
|
|
gameOverUI.SetActive(false);
|
2020-01-18 12:23:59 -05:00
|
|
|
Time.timeScale = 1f;
|
|
|
|
|
GameIsPaused = false;
|
2020-01-18 23:10:16 -05:00
|
|
|
GameIsOver = false;
|
2020-01-18 12:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Pause()
|
|
|
|
|
{
|
2020-01-26 23:03:41 -05:00
|
|
|
Cursor.visible = true;
|
|
|
|
|
Cursor.lockState = CursorLockMode.None;
|
2020-01-18 12:23:59 -05:00
|
|
|
pauseMenuUI.SetActive(true);
|
|
|
|
|
Time.timeScale = 0f;
|
|
|
|
|
GameIsPaused = true;
|
2020-01-27 21:34:58 -05:00
|
|
|
EventSystem.current.SetSelectedGameObject(null);
|
|
|
|
|
EventSystem.current.SetSelectedGameObject(pauseFirstButton);
|
2020-01-18 12:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-18 23:10:16 -05:00
|
|
|
void GameOver()
|
|
|
|
|
{
|
2020-01-26 23:03:41 -05:00
|
|
|
|
|
|
|
|
Cursor.visible = true;
|
|
|
|
|
Cursor.lockState = CursorLockMode.None;
|
|
|
|
|
gameOverUI.SetActive(true);
|
|
|
|
|
Time.timeScale = 0f;
|
|
|
|
|
GameIsPaused = true;
|
|
|
|
|
|
2020-01-18 23:10:16 -05:00
|
|
|
if(FloorLevel.gameOver == true)
|
|
|
|
|
{
|
|
|
|
|
ScoreText.text = "LEVEL: " + FloorLevel.escalation + "-" + FloorLevel.level;
|
2020-01-19 20:59:20 -05:00
|
|
|
TimeText.text = "TIME: " + Mathf.Round(FloorLevel.fullTime);
|
2020-02-03 21:36:56 -05:00
|
|
|
|
|
|
|
|
if(FloorLevel.escalation > PlayerPrefs.GetInt("ObstacleHighFloor") ||
|
|
|
|
|
(FloorLevel.escalation == PlayerPrefs.GetInt("ObstacleHighFloor") &&
|
|
|
|
|
FloorLevel.level >= PlayerPrefs.GetInt("ObstacleHighLevel")))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(FloorLevel.escalation > PlayerPrefs.GetInt("ObstacleHighFloor") ||
|
|
|
|
|
FloorLevel.level > PlayerPrefs.GetInt("ObstacleHighLevel") ||
|
|
|
|
|
(FloorLevel.level == PlayerPrefs.GetInt("ObstacleHighLevel") &&
|
|
|
|
|
Mathf.Round(FloorLevel.fullTime) < PlayerPrefs.GetFloat("ObstacleHighTime")))
|
|
|
|
|
{
|
|
|
|
|
PlayerPrefs.SetInt("ObstacleHighFloor", FloorLevel.escalation);
|
|
|
|
|
PlayerPrefs.SetInt("ObstacleHighLevel", FloorLevel.level);
|
|
|
|
|
PlayerPrefs.SetFloat("ObstacleHighTime", Mathf.Round(FloorLevel.fullTime));
|
|
|
|
|
|
|
|
|
|
highscore = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(highscore)
|
|
|
|
|
{
|
|
|
|
|
CongratsText.text = "NEW" + "\n" + "HIGH SCORE!" + "\n" + "CONGRATS!";
|
|
|
|
|
} else {
|
|
|
|
|
CongratsText.text = "TRY AGAIN!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("ObstacleHighFloor")
|
|
|
|
|
+ "-" + PlayerPrefs.GetInt("ObstacleHighLevel");
|
|
|
|
|
HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("ObstacleHighTime"));
|
2020-02-08 20:06:38 -05:00
|
|
|
} else if(WaypointRace.gameOver == true)
|
2020-01-18 23:10:16 -05:00
|
|
|
{
|
2020-01-19 20:59:20 -05:00
|
|
|
ScoreText.text = "LEVEL: " + (WaypointRace.size - 1) + "-" + WaypointRace.level;
|
|
|
|
|
TimeText.text = "TIME: " + Mathf.Round(WaypointRace.fullTime);
|
2020-02-03 21:36:56 -05:00
|
|
|
|
|
|
|
|
if((WaypointRace.size - 1) > PlayerPrefs.GetInt("WaypointHighSize") ||
|
|
|
|
|
((WaypointRace.size - 1) == PlayerPrefs.GetInt("WaypointHighSize") &&
|
|
|
|
|
WaypointRace.level >= PlayerPrefs.GetInt("WaypointHighFloor")))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if((WaypointRace.size - 1) > PlayerPrefs.GetInt("WaypointHighSize") ||
|
|
|
|
|
WaypointRace.level > PlayerPrefs.GetInt("WaypointHighFloor") ||
|
|
|
|
|
(WaypointRace.level == PlayerPrefs.GetInt("WaypointHighFloor") &&
|
|
|
|
|
Mathf.Round(WaypointRace.fullTime) < PlayerPrefs.GetFloat("WaypointHighTime")))
|
|
|
|
|
{
|
|
|
|
|
PlayerPrefs.SetInt("WaypointHighSize", (WaypointRace.size - 1));
|
|
|
|
|
PlayerPrefs.SetInt("WaypointHighFloor", WaypointRace.level);
|
|
|
|
|
PlayerPrefs.SetFloat("WaypointHighTime", Mathf.Round(WaypointRace.fullTime));
|
|
|
|
|
|
|
|
|
|
highscore = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(highscore)
|
|
|
|
|
{
|
|
|
|
|
CongratsText.text = "NEW" + "\n" + "HIGH SCORE!" + "\n" + "CONGRATS!";
|
|
|
|
|
} else {
|
|
|
|
|
CongratsText.text = "TRY AGAIN!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("WaypointHighSize")
|
|
|
|
|
+ "-" + PlayerPrefs.GetInt("WaypointHighFloor");
|
|
|
|
|
HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("WaypointHighTime"));
|
|
|
|
|
|
2020-02-08 20:06:38 -05:00
|
|
|
} else if(InfinityRunner.gameOver == true)
|
2020-01-29 22:59:06 -05:00
|
|
|
{
|
|
|
|
|
ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level;
|
2020-02-08 20:06:38 -05:00
|
|
|
TimeText.text = "TIME: " + Mathf.Round(InfinityRunner.fullTime);
|
2020-02-03 21:36:56 -05:00
|
|
|
|
|
|
|
|
if(InfinityRunner.escalation > PlayerPrefs.GetInt("RunnerHighFloor") ||
|
|
|
|
|
(InfinityRunner.escalation == PlayerPrefs.GetInt("RunnerHighFloor") &&
|
2020-02-08 20:06:38 -05:00
|
|
|
InfinityRunner.level >= PlayerPrefs.GetInt("RunnerHighTime")))
|
2020-02-03 21:36:56 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(InfinityRunner.escalation > PlayerPrefs.GetInt("RunnerHighFloor") ||
|
|
|
|
|
InfinityRunner.level > PlayerPrefs.GetInt("RunnerHighLevel") ||
|
|
|
|
|
(InfinityRunner.level == PlayerPrefs.GetInt("RunnerHighLevel") &&
|
2020-02-08 20:06:38 -05:00
|
|
|
Mathf.Round(InfinityRunner.fullTime) < PlayerPrefs.GetFloat("RunnerHighTime")))
|
2020-02-03 21:36:56 -05:00
|
|
|
{
|
|
|
|
|
PlayerPrefs.SetInt("RunnerHighFloor", InfinityRunner.escalation);
|
|
|
|
|
PlayerPrefs.SetInt("RunnerHighLevel", InfinityRunner.level);
|
2020-02-08 20:06:38 -05:00
|
|
|
PlayerPrefs.SetFloat("RunnerHighTime", Mathf.Round(InfinityRunner.fullTime));
|
2020-02-03 21:36:56 -05:00
|
|
|
|
|
|
|
|
highscore = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(highscore)
|
|
|
|
|
{
|
|
|
|
|
CongratsText.text = "NEW" + "\n" + "HIGH SCORE!" + "\n" + "CONGRATS!";
|
|
|
|
|
} else {
|
|
|
|
|
CongratsText.text = "TRY AGAIN!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("RunnerHighFloor")
|
|
|
|
|
+ "-" + PlayerPrefs.GetInt("RunnerHighLevel");
|
2020-02-08 20:06:38 -05:00
|
|
|
HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("RunnerHighTime"));
|
2020-01-29 22:59:06 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-18 23:10:16 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
public void LoadHubWorld()
|
|
|
|
|
{
|
|
|
|
|
Time.timeScale = 1f;
|
|
|
|
|
GameIsPaused = false;
|
|
|
|
|
SceneManager.LoadScene("Hub World", LoadSceneMode.Single);
|
2020-01-26 23:03:41 -05:00
|
|
|
Cursor.visible = false;
|
2020-01-18 12:23:59 -05:00
|
|
|
Cursor.lockState = CursorLockMode.Locked;
|
2020-02-08 20:06:38 -05:00
|
|
|
FloorLevel.gameOver = false;
|
|
|
|
|
WaypointRace.gameOver = false;
|
|
|
|
|
InfinityRunner.gameOver = false;
|
2020-01-18 12:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadMenu()
|
|
|
|
|
{
|
|
|
|
|
Time.timeScale = 1f;
|
|
|
|
|
GameIsPaused = false;
|
|
|
|
|
SceneManager.LoadScene("Main Menu", LoadSceneMode.Single);
|
2020-01-26 23:03:41 -05:00
|
|
|
Cursor.visible = true;
|
|
|
|
|
Cursor.lockState = CursorLockMode.None;
|
2020-01-18 12:23:59 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-27 23:32:13 -05:00
|
|
|
public void Retry()
|
|
|
|
|
{
|
|
|
|
|
Time.timeScale = 1f;
|
|
|
|
|
GameIsPaused = false;
|
|
|
|
|
Cursor.visible = false;
|
|
|
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
|
|
|
|
|
|
|
|
if(FloorLevel.gameOver == true)
|
|
|
|
|
{
|
2020-02-04 22:33:20 -05:00
|
|
|
FloorLevel.gameOver = false;
|
2020-02-08 20:06:38 -05:00
|
|
|
WaypointRace.gameOver = false;
|
|
|
|
|
InfinityRunner.gameOver = false;
|
2020-01-27 23:32:13 -05:00
|
|
|
SceneManager.LoadScene("Floor Level", LoadSceneMode.Single);
|
2020-02-08 20:06:38 -05:00
|
|
|
} else if(WaypointRace.gameOver == true)
|
2020-01-27 23:32:13 -05:00
|
|
|
{
|
2020-02-08 20:06:38 -05:00
|
|
|
FloorLevel.gameOver = false;
|
2020-02-04 22:33:20 -05:00
|
|
|
WaypointRace.gameOver = false;
|
2020-02-08 20:06:38 -05:00
|
|
|
InfinityRunner.gameOver = false;
|
2020-01-27 23:32:13 -05:00
|
|
|
SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single);
|
2020-02-08 20:06:38 -05:00
|
|
|
} else if(InfinityRunner.gameOver == true)
|
2020-01-29 22:59:06 -05:00
|
|
|
{
|
2020-02-08 20:06:38 -05:00
|
|
|
FloorLevel.gameOver = false;
|
|
|
|
|
WaypointRace.gameOver = false;
|
2020-02-04 22:33:20 -05:00
|
|
|
InfinityRunner.gameOver = false;
|
2020-01-29 22:59:06 -05:00
|
|
|
SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 23:32:13 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:23:59 -05:00
|
|
|
public void Quit()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Application.Quit();
|
|
|
|
|
Debug.Log("QUIT");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|