Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Added Win Menu and fixed restarting more than one time
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonymendez committed Jul 6, 2017
1 parent 8fa922f commit 16ebafc
Show file tree
Hide file tree
Showing 7 changed files with 1,678 additions and 139 deletions.
10 changes: 2 additions & 8 deletions Assets/Scripts/DeadMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@

public class DeadMenu : MonoBehaviour {

Button restart, options, exit, exitOptions;
public Button restart, options, exit, exitOptions;


public OptMenu optMenu;

void Start() {
restart = GameObject.FindWithTag("Restart").GetComponent<Button>();
restart.onClick.AddListener(RestartGame);

options = GameObject.FindWithTag("Options").GetComponent<Button>();
options.onClick.AddListener(OptionsMenu);

exit = GameObject.FindWithTag("Exit").GetComponent<Button>();


options.onClick.AddListener(OptionsMenu);
}

//Restart Method
Expand Down
5 changes: 4 additions & 1 deletion Assets/Scripts/Key.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class Key : MonoBehaviour {

public GameObject[] ignoreCollisions;

public GameObject WinMenu;

GameObjectPool keyPool;

private void Start() {
Expand All @@ -23,7 +25,8 @@ void OnCollisionEnter2D(Collision2D collision) {
keyPool.AddGameObject(gameObject);

if(Variables.keysObtained == 8) {

WinMenu.SetActive(true);
Time.timeScale = 0;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/TimeUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

public class TimeUI : MonoBehaviour {

public float timeInSeconds;

Text text;
float timeInSeconds;
Cam mainCamera;
// Use this for initialization
void Start () {
Expand Down
57 changes: 57 additions & 0 deletions Assets/Scripts/WinMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class WinMenu : MonoBehaviour {

public Text TimeScore, GameScore, FinalScore, TimeUI;

public Button restart, options, exit;

public OptMenu optMenu;

int placeHolder;

float TS, GS, FS;

// Use this for initialization
void Start() {
restart.onClick.AddListener(RestartGame);

options.onClick.AddListener(OptionsMenu);

gameObject.SetActive(false);
}

// Update is called once per frame
void Update() {
//Calculate Timescore
placeHolder = int.Parse(TimeScore.text);
if(placeHolder >= 60) {
TimeScore.text = 60.ToString();
TS = 60;
} else {
TimeScore.text = (1000f / placeHolder).ToString();
TS = 1000f / placeHolder;
}
//Set GameScore
GameScore.text = Variables.score.ToString();
GS = Variables.score;
//Set FinalScore
FS = TS + GS;
FinalScore.text = FS.ToString();
}

void RestartGame() {
Variables.score = 0;
Variables.keysObtained = 0;
Time.timeScale = 1;
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

void OptionsMenu() {
optMenu.gameObject.SetActive(true);
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/WinMenu.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 16ebafc

Please sign in to comment.