initial upload
This commit is contained in:
@ -0,0 +1,63 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.Assertions;
|
||||
using static OVRFaceExpressions;
|
||||
|
||||
public class CharadeWord : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private AudioSource audioSource;
|
||||
[SerializeField]
|
||||
private AudioClip audioClipCorrect;
|
||||
[SerializeField]
|
||||
private AudioClip audioClipWrong;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Text text;
|
||||
public string currentWord = null;
|
||||
public int playSound = -1;
|
||||
|
||||
public float remainingTime = 0.0f;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
private void Start()
|
||||
{
|
||||
text.text = "";
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
if (currentWord != null && remainingTime < Time.deltaTime)
|
||||
{
|
||||
currentWord = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
remainingTime -= Time.deltaTime;
|
||||
}
|
||||
|
||||
switch (playSound)
|
||||
{
|
||||
case 0:
|
||||
audioSource.PlayOneShot(audioClipWrong);
|
||||
break;
|
||||
case 1:
|
||||
audioSource.PlayOneShot(audioClipCorrect);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
playSound = -1;
|
||||
|
||||
if (currentWord == null)
|
||||
{
|
||||
text.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
text.gameObject.SetActive(true);
|
||||
text.text = $"{currentWord}\n{Mathf.Round(remainingTime)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user