Миксер
Почини интерфейс
This commit is contained in:
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;
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace Code.Example.Platformer.Entity.Enemies
|
||||
[SerializeField] private EntityHealth health;
|
||||
|
||||
[Inject] private IAudioService _audioService;
|
||||
|
||||
private Transform _target;
|
||||
private float _attackThreshold = 0.5f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
health.OnEntityDamage = OnEntityDamage;
|
||||
@@ -34,12 +38,12 @@ namespace Code.Example.Platformer.Entity.Enemies
|
||||
private async UniTaskVoid Die()
|
||||
{
|
||||
await UniTask.WaitForSeconds(1);
|
||||
_audioService.PlayOneShot(AudioNames.Platformer, 3 );
|
||||
_audioService.PlayOneShot(AudioNames.Platformer, 3 , AudioGroupType.SFX);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
private void OnEntityDamage(int obj)
|
||||
{
|
||||
_audioService.PlayOneShot(AudioNames.Platformer, 2);
|
||||
_audioService.PlayOneShot(AudioNames.Platformer, 2, AudioGroupType.SFX);
|
||||
UnityEngine.Debug.Log(gameObject.name + " damaged");
|
||||
animator.SetTrigger(OnHit);
|
||||
}
|
||||
@@ -83,11 +87,9 @@ namespace Code.Example.Platformer.Entity.Enemies
|
||||
|
||||
private void TryAttack()
|
||||
{
|
||||
if ((transform.position - _target.position).magnitude < attackThreshold) _target.GetComponent<EntityHealth>().GiveDamage(1);
|
||||
if ((transform.position - _target.position).magnitude < _attackThreshold) _target.GetComponent<EntityHealth>().GiveDamage(1);
|
||||
}
|
||||
|
||||
private Transform _target;
|
||||
private float attackThreshold = 0.5f;
|
||||
|
||||
public void GotTarget(Transform target)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Platformer.Entity.Enemies
|
||||
{
|
||||
public class PlayerCollisionDamager : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
other.GetComponent<EntityHealth>().GiveDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55c5190afe54409f89d7a16c315e48f9
|
||||
timeCreated: 1774276433
|
||||
@@ -1,4 +1,7 @@
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Configs;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Platformer.Entity.Enemies
|
||||
@@ -9,6 +12,35 @@ namespace Code.Example.Platformer.Entity.Enemies
|
||||
[SerializeField] private Vector2 groundRight;
|
||||
[SerializeField] private bool _directionRight;
|
||||
|
||||
[SerializeField] private EntityHealth health;
|
||||
[Inject] private IAudioService _audioService;
|
||||
|
||||
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()
|
||||
{
|
||||
CheckupDirection();
|
||||
|
||||
Reference in new issue
Block a user