-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pause.cs
122 lines (105 loc) · 3.38 KB
/
Pause.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System.Collections;
using UnityEngine;
public class Pause : MonoBehaviour
{
public Texture PauseBTN;
public Texture PlayBTN;
Texture btnToShow;
public Texture soundOn;
public Texture soundOff;
Texture currentSound;
float pauseBtnPosX = (Screen.width) - 60;
float pauseBtnPosY = 10;
public bool showPause = false;
bool showTutorial = false;
float boxWidth = 200;
float boxHeight = 250;
float btnWidth = 180;
float btnHeight = 35;
int clicks = 0;
void Start()
{
btnToShow = PauseBTN;
if (GUI_Interface.soundPlay == true)
{
currentSound = soundOn;
}
else
{
currentSound = soundOff;
}
}
void OnGUI()
{
if (GUI.Button(new Rect(pauseBtnPosX, pauseBtnPosY, 50, 50), btnToShow, GUIStyle.none))
{
if(!showPause)
{
showPause = true;
Time.timeScale = Time.timeScale == 1 ? 0 : 1;
clicks++;
btnToShow = PlayBTN;
}
else
{
showPause = false;
clicks = 0;
Time.timeScale = Time.timeScale == 1 ? 1 : 1;
btnToShow = PauseBTN;
}
}
if (showPause == true)//Martin was here!
{
if(GUI.Button(new Rect(pauseBtnPosX - 50,pauseBtnPosY,50,50),currentSound,GUIStyle.none))
{
if (currentSound == soundOn)
{
currentSound = soundOff;//hihihihi
audio.Pause();
GUI_Interface.soundPlay = false;
}//hihihihihihihi
else
{
currentSound = soundOn;
audio.Play();
GUI_Interface.soundPlay = true;
}
}
}
if (showPause == true & showTutorial == false)
{
float boxPosX = Screen.width / 2 -(boxWidth / 2);
float boxPosY = 40;
float btnPosX = Screen.width / 2 - (boxWidth / 2) + 10;
float btnPosY = boxPosY + btnHeight -10;
float btnPosYAdd = btnHeight + 5;
//Pause box
GUI.Box(new Rect(boxPosX,boxPosY, boxWidth, boxHeight), "Game Paused");
//Resume Button
if (GUI.Button(new Rect(btnPosX,btnPosY,btnWidth,btnHeight * 2), "Resume"))
{
showPause = false;
showTutorial = false;
Time.timeScale = Time.timeScale == 1 ? 1 : 1;
}
//Quick tutorial
if (GUI.Button(new Rect(btnPosX, btnPosY + (btnPosYAdd* 2) , btnWidth, btnHeight), "Quick tutorial"))
{
//showTutorial = true;
//showOptions = false
}
//Quit to menu
if (GUI.Button(new Rect(btnPosX, btnPosY + (btnPosYAdd * 3), btnWidth, btnHeight), "Quit to menu"))
{
Application.LoadLevel(0);
Time.timeScale = Time.timeScale == 1 ? 1 : 1;
}
//Quit Game
if (GUI.Button(new Rect(btnPosX, btnPosY + (btnPosYAdd * 4), btnWidth, btnHeight), "Exit the game"))
{
Application.Quit();
Time.timeScale = Time.timeScale == 1 ? 1 : 1;
}
}
}
}