Countdown.cs
1.08 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Countdown : MonoBehaviour
{
float currentTime = 0f;
float startingTime = 10f;
public GameObject Target1;
public GameObject Target2;
[SerializeField] Text countdownText;
[SerializeField] Text resultText;
void Start()
{
currentTime = startingTime;
}
void Update()
{
currentTime -= 1 * Time.deltaTime;
countdownText.text = currentTime.ToString("0");
if(currentTime <= 0)
{
Target1.SetActive(true);
Target2.SetActive(true);
currentTime = 0;
resultText.text = (1000 * ScoreCount.fakeScore).ToString() + "포인트\n 적립되었습니다!\n3초후 집으로\n돌아갑니다...";
Invoke("exit_Game", 3);
Target1.SetActive(false);
Target2.SetActive(false);
}
}
public void exit_Game()
{
SceneManager.LoadScene(2);
ScoreCount.fakeScore = 0;
}
}