-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFinish.cs
61 lines (50 loc) · 1.55 KB
/
Finish.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
53
54
55
56
57
58
59
60
61
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Finish : MonoBehaviour
{
[Header("Finish UI Var")]
public GameObject finishUI;
public GameObject playerUI;
public GameObject playerCar;
public GameObject Speedometer;
[Header("Win/Lose Status")]
public Text status;
private void Start()
{
StartCoroutine(waitforthefinishUI());
}
private void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
StartCoroutine(finishZoneTimer());
gameObject.GetComponent<BoxCollider>().enabled = false;
status.text = "You Win";
status.color = Color.black;
}
else if(other.gameObject.tag == "OpponentCar")
{
StartCoroutine(finishZoneTimer());
gameObject.GetComponent<BoxCollider>().enabled = false;
status.text = "You Loss";
status.color = Color.red;
}
}
IEnumerator waitforthefinishUI()
{
gameObject.GetComponent<BoxCollider>().enabled = false;
yield return new WaitForSeconds(25f);
gameObject.GetComponent<BoxCollider>().enabled = true;
}
IEnumerator finishZoneTimer()
{
finishUI.SetActive(true);
playerUI.SetActive(false);
playerCar.SetActive(false);
Speedometer.SetActive(false);
yield return new WaitForSeconds(5f);
Time.timeScale = 0f;
}
}