-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.cs
More file actions
42 lines (38 loc) · 1.16 KB
/
Timer.cs
File metadata and controls
42 lines (38 loc) · 1.16 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Timer : MonoBehaviour
{
float currentTime = 0f;
[SerializeField] float startingTime = 10f;
public GameManager gameManager;
public float overdelay = 1f;
[SerializeField] Text countdown;
// Start is called before the first frame update
void Start()
{
currentTime = startingTime;
}
// Update is called once per frame
void Update()
{
currentTime -= Time.deltaTime;
countdown.text = currentTime.ToString("0");
if(currentTime <= 0)
{
currentTime = 0;
Invoke("gameoverscreen", overdelay);
FindObjectOfType<DialogueNPC>().OutOfRange();
FindObjectOfType<DialogueSystem>().OutOfRange();
FindObjectOfType<PlayerController>().stop();
FindObjectOfType<fracture>().outofrange();
//FindObjectOfType<fracture>().stopliatin();
}
}
public void gameoverscreen()
{
gameManager.Setup();
FindObjectOfType<PlayerController>().unlock();
}
}