-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoundManager.cs
52 lines (43 loc) · 1.08 KB
/
RoundManager.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
/* Manage the timer.
*/
using UnityEngine;
public class RoundManager : MonoBehaviour
{
public static RoundManager Timer;
public UnityEngine.UI.Text btnText;
public UnityEngine.UI.Text timerText;
private bool _counting = false;
private float _startTime = 0.0f;
private float _curTime = 0.0f;
void Awake()
{
Timer = this;
}
void Update()
{
if (!_counting)
return;
_curTime = Time.fixedTime - _startTime;
timerText.text = _curTime.ToString("F1") + " sec";
}
public void triggerRound()
{
if (_counting) {
btnText.text = "Start Round";
BRCServerManager.Server.stopRound();
} else {
// Send the round starting message and begin timing
BRCServerManager.Server.startRound();
btnText.text = "Stop Round";
_startTime = Time.fixedTime;
}
_counting = !_counting;
}
/* Stop the round not trigger.
*/
public void stop()
{
if (_counting)
triggerRound();
}
}