Миксер

Почини интерфейс
This commit is contained in:
ThomasCharester committed 2026-03-23 23:59:32 +03:00
1 parent 1aceea1b79
commit 60c28f54f2
74 files changed
+8060 -1059

No files matched your search

@@ -1,5 +1,8 @@
using System.Collections.Generic;
using Code.Infrastructure.Audio;
using Cysharp.Threading.Tasks;
using PrimeTween;
using Reflex.Attributes;
using UnityEngine;
namespace Code.Example.Platformer.Entity.Enemies
@@ -14,7 +17,36 @@ namespace Code.Example.Platformer.Entity.Enemies
[SerializeField] private Transform _currentTarget;
private Tween _patrolAction;
private float _attackThreshold = 0.5f;
[Inject] private IAudioService _audioService;
[SerializeField] private EntityHealth health;
private void Start()
{
health.OnEntityDamage = OnEntityDamage;
health.OnEntityDeath = OnEntityDeath;
}
private void OnEntityDeath()
{
animator.SetBool(Died, true);
animator.SetTrigger(OnDeath);
Die().Forget();
}
private async UniTaskVoid Die()
{
await UniTask.WaitForSeconds(1);
_audioService.PlayOneShot(AudioNames.Platformer, 3 , AudioGroupType.SFX);
Destroy(gameObject);
}
private void OnEntityDamage(int obj)
{
_audioService.PlayOneShot(AudioNames.Platformer, 2, AudioGroupType.SFX);
UnityEngine.Debug.Log(gameObject.name + " damaged");
animator.SetTrigger(OnHit);
}
protected override void Move()
{
if (onPatrol && !_patrolAction.isAlive)
@@ -25,6 +57,7 @@ namespace Code.Example.Platformer.Entity.Enemies
}
else if(_currentTarget)
{
TryAttack();
var direction = _currentTarget.position - transform.position;
direction.Normalize();
@@ -39,6 +72,11 @@ namespace Code.Example.Platformer.Entity.Enemies
}
}
private void TryAttack()
{
if ((transform.position - _currentTarget.position).magnitude < _attackThreshold) _currentTarget.GetComponent<EntityHealth>().GiveDamage(1);
}
private void OnControlPointReached()
{
if (++_currentPatrolPoint >= partolPoints.Count) _currentPatrolPoint = 0;