錯誤球倒數,數比較快摸到會扣分
unknown
c_cpp
2 years ago
1.1 kB
2
Indexable
Never
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); } }