-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameStatus.cs
52 lines (46 loc) · 1.25 KB
/
GameStatus.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class GameStatus : MonoBehaviour
{
[Range(0.01f, 1f)] [SerializeField] float speedAcceleration = 0.1f; // sets rate of increase over time
[Range(10f, 100f)] [SerializeField] float initialSpeed = 10; // determines inital speed
[SerializeField] int pointsPerBlock = 100;
[SerializeField] int currentScore = 0;
[SerializeField] TextMeshProUGUI scoreText; //display score
[SerializeField] bool autoPlayEnabled;
private void Awake()
{
int gameStatusCounts = FindObjectsOfType<GameStatus>().Length;
if (gameStatusCounts > 1)
{
Destroy(gameObject);
}
else
{
DontDestroyOnLoad(gameObject);
}
}
public void Start()
{
scoreText.text = currentScore.ToString();
}
void Update()
{
Time.timeScale = speedAcceleration * (Time.fixedTime + initialSpeed);
}
public void AddToScore()
{
currentScore += pointsPerBlock;
scoreText.text = currentScore.ToString();
}
public void ResetGame()
{
Destroy(gameObject);
}
public bool AutoPlayEnabled()
{
return autoPlayEnabled;
}
}