-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameOver.cs
63 lines (47 loc) · 1.21 KB
/
GameOver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameOver : MonoBehaviour {
public Button newGame;
public Button mainMenu;
public Text score;
public Text record;
public AudioSource replaySFX;
public AudioSource mainMenuSFX;
void Awake()
{
newGame.GetComponent<Button> ().onClick.AddListener (StartNewGame);
mainMenu.GetComponent<Button> ().onClick.AddListener (GoToMainMenu);
}
void Start ()
{
AdController.ad.RequestBannerAd(0);
GameStatsController.data.Load ();
if (GameStatsController.data.numberOfObstacles > GameStatsController.data.record) {
Debug.Log (GameStatsController.data.record);
Debug.Log ("New Record!");
}
score.text = "Score: " + GameStatsController.data.numberOfObstacles;
record.text = "Record: " + GameStatsController.data.record;
}
void Update ()
{
if (Input.GetKey (KeyCode.Escape))
{
GoToMainMenu();
}
}
void StartNewGame()
{
GameStatsController.data.startTime = Time.time;
SceneManager.LoadScene ("Gameplay");
}
void GoToMainMenu() {
SceneManager.LoadScene ("MainMenu");
}
void OnDestroy() {
AdController.ad.HideBannerAd();
}
}