-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevelTimeScript.cs
More file actions
82 lines (71 loc) · 1.94 KB
/
Copy pathlevelTimeScript.cs
File metadata and controls
82 lines (71 loc) · 1.94 KB
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
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
public class levelTimeScript : MonoBehaviour {
public Text levelGUI;
public Text timeGUI;
public Text scoreGUI;
public moveScript moveScript;
public gameOverScript gameOverScript;
private int level = 1;
private float time = 30f;
private float score = 0f;
private int countBorder = 2000;
private int count = 0;
void Start()
{
levelGUI.text = "Level: " + level.ToString();
timeGUI.text = time.ToString();
scoreGUI.text = "Score: " + score.ToString();
Time.timeScale = 1;
}
void Update()
{
//タイム
time -= 1f * Time.deltaTime;
score += 1f * Time.deltaTime;
timeGUI.text = ((int)time).ToString();
scoreGUI.text = "Score: "+((int)score).ToString();
//レベル
if (transform.position.z >= countBorder)
{
countBorder += 2000;
count++;
if (count <= 8)
{
LevelUp();
}
AddTime();
}
if (time < 0.0f)
{
GameOver();
}
}
void LevelUp()
{
if (count == 1) { level = 2; }
if (count == 3) { level = 3; }
if (count == 5) { level = 4; }
if (count == 8) { level = 5; }
moveScript.level = level;
levelGUI.text = "Level: " + level.ToString();
}
void AddTime()
{
if (level == 2) { time += 20; }
if (level == 3) { time += 17; }
if (level == 4) { time += 15; }
if (level == 5) { time += 10; }
}
void GameOver()
{
gameOverScript.SendMessage("Lose");
Time.timeScale = 0;
if (Input.GetMouseButton(0))
{
SceneManager.LoadScene("title");
}
}
}