錯誤球倒數,數比較快摸到會扣分
unknown
c_cpp
4 years ago
1.1 kB
13
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Errorcountdown : MonoBehaviour
{
public timer timer;
public TextMesh countdown_text;
float sec = 3;
public getscore getscore;
public bool IsTouch = false;
public playsound playsound;
// Start is called before the first frame update
void Start()
{
getscore = GameObject.Find("Score").GetComponent<getscore>();
playsound = gameObject.GetComponentInParent<playsound>();
timer = GameObject.Find("Time").GetComponent<timer>();
}
// Update is called once per frame
void Update()
{
countdown_text.text = ((int)(sec)).ToString();
sec -= Time.deltaTime;
if (sec <= 1)
{
Destroy(gameObject);
}
if (timer.IsGameOver)
{
Destroy(gameObject);
}
}
private void OnTriggerEnter(Collider other)
{
playsound.ErrorSoundPlay();
getscore.Getscore(-3);
Destroy(gameObject);
}
}Editor is loading...