Platformer level management

This commit is contained in:
ThomasCharester committed 2026-03-23 12:01:33 +03:00
1 parent 72070901ec
commit 1aceea1b79
94 files changed
+3656 -197

No files matched your search

@@ -1,3 +1,4 @@
using System;
using Code.Infrastructure.Audio;
using Code.Infrastructure.Camera;
using Code.Infrastructure.Configs;
@@ -32,6 +33,11 @@ namespace Code.Example.Platformer.Entity
}
private void OnDestroy()
{
if(!health.IsDead) UnbindControls();
}
private void UnbindControls()
{
_inputService.UnbindActionPerformed((int)ActionMappings.Platformer, (int)PlatformerActions.Move,
MovementPerformed);
@@ -65,6 +71,8 @@ namespace Code.Example.Platformer.Entity
rigidbody2D.AddForceY(100f);
_acceleration = 1f;
_audioService.PlayOneShot(AudioNames.Platformer, 6);
}
[SerializeField] private Vector2 attackOffset;
@@ -75,7 +83,7 @@ namespace Code.Example.Platformer.Entity
//
//
_audioService.PlayOneShot(AudioNames.UISounds, 1);
_audioService.PlayOneShot(AudioNames.Platformer, 1);
animator.SetBool(OnAttack, true);
}
@@ -89,7 +97,6 @@ namespace Code.Example.Platformer.Entity
foreach (var damaged in damagedOnes)
{
damaged.gameObject.GetComponent<EntityHealth>().GiveDamage(1);
_audioService.PlayOneShot(AudioNames.UISounds, 2);
}
}
@@ -105,5 +112,28 @@ namespace Code.Example.Platformer.Entity
}
public void AttackEnd() => animator.SetBool(OnAttack, false);
[SerializeField] private EntityHealth health;
private void Start()
{
health.OnEntityDeath = OnEntityDeath;
health.OnEntityDamage = OnEntityDamage;
}
private void OnEntityDamage(int obj)
{
UnityEngine.Debug.Log("Player damaged");
}
private void OnEntityDeath()
{
_moveDirection = Vector2.zero;
animator.SetBool(Died, true);
UnbindControls();
// Destroy(gameObject, 1f);
}
}
}