39e4e51866
- 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.
64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
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; }
|
|
}
|