счетчик оставшихся патронов, который
уменьшается при каждом выстреле.
This commit is contained in:
1 parent
c9085558cd
commit
87aaf3139a
1 file changed
+7
-4
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
// ИЗМЕНЕНО: Используем пространство имен для TextMeshPro
|
||||
using TMPro;
|
||||
|
||||
public class PlayerShooting : MonoBehaviour
|
||||
{
|
||||
@@ -18,7 +19,8 @@ public class PlayerShooting : MonoBehaviour
|
||||
|
||||
// --- Ссылки на компоненты и объекты ---
|
||||
public GameObject muzzleFlashSprite;
|
||||
public Text ammoText;
|
||||
// ИЗМЕНЕНО: Тип переменной заменен на TextMeshProUGUI
|
||||
public TextMeshProUGUI ammoText;
|
||||
public AudioClip reloadSound;
|
||||
|
||||
private float timer;
|
||||
@@ -80,7 +82,7 @@ public class PlayerShooting : MonoBehaviour
|
||||
currentAmmo--;
|
||||
UpdateAmmoText();
|
||||
|
||||
gunAudio.Play();
|
||||
gunAudio.Play();
|
||||
|
||||
gunParticles.Stop();
|
||||
gunParticles.Play();
|
||||
@@ -130,7 +132,7 @@ public class PlayerShooting : MonoBehaviour
|
||||
IEnumerator Reload()
|
||||
{
|
||||
isReloading = true;
|
||||
|
||||
|
||||
if (reloadSound != null)
|
||||
{
|
||||
gunAudio.PlayOneShot(reloadSound);
|
||||
@@ -149,6 +151,7 @@ public class PlayerShooting : MonoBehaviour
|
||||
{
|
||||
if (ammoText != null)
|
||||
{
|
||||
// Для TextMeshPro синтаксис точно такой же, так что здесь ничего менять не нужно
|
||||
ammoText.text = "Патроны: " + currentAmmo + " / " + maxAmmo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user