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.
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using Assets.Scripts;
|
|
using UnityEngine;
|
|
|
|
public class DoorInteract : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject _doorGameObject;
|
|
[SerializeField] private bool _debugMode = false;
|
|
|
|
private IDoor _door;
|
|
private bool _hasTriggered = false;
|
|
|
|
private void Awake()
|
|
{
|
|
_door = _doorGameObject.GetComponent<IDoor>();
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D collider)
|
|
{
|
|
if (_hasTriggered)
|
|
return;
|
|
|
|
var playerState = collider.GetComponent<PlayerState>();
|
|
if (playerState != null)
|
|
{
|
|
// Check if player has key through GameManager
|
|
if (GameManager.Instance != null && GameManager.Instance.HasKey)
|
|
{
|
|
_hasTriggered = true;
|
|
|
|
if (_debugMode)
|
|
Debug.Log("[DoorInteract] Player exiting with key!");
|
|
|
|
// Notify LevelManager that level is complete
|
|
if (LevelManager.Instance != null)
|
|
{
|
|
LevelManager.Instance.NotifyLevelComplete();
|
|
}
|
|
}
|
|
else if (_debugMode)
|
|
{
|
|
Debug.Log("[DoorInteract] Player reached door but does not have key!");
|
|
}
|
|
}
|
|
}
|
|
}
|