Add player controller, state management, and input handling

- Implemented PlayerController.cs to manage player movement and actions.
- Created PlayerState.cs to track player lives, coins, and key status.
- Added CameraFollow.cs for smooth camera movement following the player.
- Developed Character.cs as an abstract class for character behavior.
- Introduced Enums.cs for defining TreasureType and MapElementType.
- Added IDoor interface for door interactions.
- Created InputActions.cs for handling player input actions.
- Implemented MainMenu.cs for basic menu functionality including play and exit options.
This commit is contained in:
2026-06-17 22:43:59 +03:00
parent dabd056e8b
commit 39e4e51866
70 changed files with 1807 additions and 99 deletions
+63
View File
@@ -0,0 +1,63 @@
using System;
using UnityEngine;
public class NoiseSystem : MonoBehaviour
{
public static NoiseSystem Instance { get; private set; }
[SerializeField] private bool _debugMode = false;
[SerializeField] private LayerMask _enemyLayer = LayerMask.GetMask("Enemy");
public event EventHandler<NoiseEventArgs> OnNoiseEmitted;
private void Awake()
{
// Singleton pattern
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
}
public void Emit(Vector3 position, float radius)
{
if (_debugMode)
Debug.Log($"[NoiseSystem] Noise emitted at {position} with radius {radius}");
OnNoiseEmitted?.Invoke(this, new NoiseEventArgs { Position = position, Radius = radius });
// Find all enemies in range and notify them
Collider2D[] hitColliders = Physics2D.OverlapCircleAll(position, radius, _enemyLayer);
foreach (Collider2D collider in hitColliders)
{
var enemy = collider.GetComponent<EnemyAI>();
if (enemy != null)
{
enemy.OnNoise(position);
if (_debugMode)
Debug.Log($"[NoiseSystem] Notified enemy at {collider.transform.position}");
}
}
}
private void OnDrawGizmosSelected()
{
// Debug visualization in editor
if (!_debugMode)
return;
Gizmos.color = Color.yellow;
// This would need to be called from a debug script to visualize noise spheres
}
}
public class NoiseEventArgs : EventArgs
{
public Vector3 Position { get; set; }
public float Radius { get; set; }
}