using UnityEngine; public class EffectManager : MonoBehaviour { public static EffectManager Instance; [Header("Text Effects")] public GameObject[] hitTextEffects; // Надписи при попадании public GameObject[] missTextEffects; // Надписи при промахе public GameObject[] shotTextEffects; // Надписи при выстреле private void Awake() { if (Instance == null) Instance = this; else Destroy(gameObject); } // Надпись попадания public GameObject PlayHitText(Vector3 position) { return SpawnRandomEffect(hitTextEffects, position); } // Надпись промаха public GameObject PlayMissText(Vector3 position) { return SpawnRandomEffect(missTextEffects, position); } // Надпись выстрела public void PlayShotText(Vector3 position) { SpawnRandomEffect(shotTextEffects, position); } private GameObject SpawnRandomEffect(GameObject[] prefabs, Vector3 position) { if (prefabs == null || prefabs.Length == 0) return null; int index = Random.Range(0, prefabs.Length); GameObject prefab = prefabs[index]; if (prefab == null) return null; GameObject effect = Instantiate(prefab, position, Quaternion.identity); Destroy(effect, 2f); return effect; } }