-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pause.cs
126 lines (124 loc) · 3.59 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
123
124
125
126
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Pause : MonoBehaviour {
public static bool GameEnd = false;
public GameObject pause, gameEnd, stageEnd, exit;
public static bool paused = false;
public static bool stageClear = false;
public static bool explode = false;
public Image black;
private bool first = true;
private bool firstP = true;
Color color = new Color32(0, 0, 0, 0);
private bool timer = true;
void Start()
{
pause.SetActive(false);
gameEnd.SetActive(false);
stageEnd.SetActive(false);
exit.SetActive(false);
paused = false;
explode = false;
GameEnd = false;
stageClear = false;
}
void Update()
{
if (paused && Input.GetKeyDown(KeyCode.P) && !firstP || paused && Input.GetButtonDown("Back_1") && !firstP || paused && Input.GetKeyDown(KeyCode.Escape) && !firstP || paused && Input.GetButtonDown("Start_1") && !firstP)
{
firstPress();
paused = false;
Time.timeScale = 1;
pause.SetActive(false);
exit.SetActive(false);
print(firstP);
StartCoroutine("wTime");
}
if (!paused && Input.GetKeyDown(KeyCode.P) && firstP && timer || !paused && Input.GetButtonDown("Back_1") && firstP && timer)
{
firstPress();
paused = true;
pause.SetActive(true);
Time.timeScale = 0;
print(firstP);
timer = false;
}
if (!paused && Input.GetKeyDown(KeyCode.Escape) && firstP && timer || !paused && Input.GetButtonDown("Start_1") && firstP && timer)
{
firstPress();
paused = true;
Time.timeScale = 0;
exit.SetActive(true);
print(firstP);
timer = false;
}
if (GameEnd)
{
Time.timeScale = 0;
gameEnd.SetActive(true);
if (Input.anyKey)
{
Time.timeScale = 1;
GameEnd = false;
Application.LoadLevel(1);
Destroy(gameObject);
PlayerMov.canMove = true;
PlayerShoot.canShoot = true;
if (MainMenu.player2)
{
PlayerMov.canMove2 = true;
PlayerShoot2.canShoot2 = true;
}
}
}
if(explode)
{
StartCoroutine("explosion");
}
if (stageClear)
{
Invoke("Dim",0f);
if(color.a >= 3)
{
stageEnd.SetActive(true);
Time.timeScale = 0;
}
if (color.a >= 6)
{
CancelInvoke("Dim");
Time.timeScale = 1;
Application.LoadLevel(1);
stageClear = false;
Destroy(gameObject,0.1f);
MoveForward.stop = false;
}
}
}
void Dim()
{
color.a += 0.05f;
black.color = color;
}
IEnumerator explosion()
{
yield return new WaitForSeconds(BossScript.explodeTime);
stageClear = true;
}
void firstPress()
{
if(!firstP)
{
firstP = true;
}
else
{
firstP = false;
}
}
IEnumerator wTime()
{
yield return new WaitForSeconds(0.1f);
timer = true;
}
}