using UnityEngine; using RR.Game2D.Behaviour; using RR.Game2D.Behaviour.ScriptableObjects; using RR.Game2D.Core.Managers; namespace RR.Game2D.Animations { public class EnemyAnimationEvents : MonoBehaviour { private SFXAsset _stepSounds; private SFXAsset _hurtSounds; private void Awake() { EnemyController controller = GetComponent(); _stepSounds = controller.sfxAsset.stepSounds; _hurtSounds = controller.sfxAsset.hurtSounds; } public void OnDeathBegin() { // Проигрывание SFX для получения урона if (_hurtSounds && _hurtSounds.soundEffects.Length > 0) GameManager.Instance.Audio.PlayRandomSfxAt(_hurtSounds.soundEffects, transform.position); gameObject.layer = LayerMask.NameToLayer("No Collision"); Rigidbody2D rb = GetComponent(); Collider2D col = GetComponent(); EnemyController controller = GetComponent(); EnemyFireScript fireScript = GetComponent(); if (controller) controller.enabled = false; if (fireScript) fireScript.enabled = false; if (col) col.enabled = false; if (!rb) return; rb.linearVelocity = Vector2.zero; rb.bodyType = RigidbodyType2D.Kinematic; } public void OnDeathEnd() { Destroy(gameObject); } public void Step() { // Проигрывание SFX для шага if (_stepSounds && _stepSounds.soundEffects.Length > 0) GameManager.Instance.Audio.PlayRandomSfxAt(_stepSounds.soundEffects, transform.position); } } }