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:
@@ -1,14 +1,35 @@
|
||||
using System.Security;
|
||||
using UnityEngine;
|
||||
|
||||
public class KeyChest : MonoBehaviour
|
||||
{
|
||||
private bool _isOpened = false;
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collider)
|
||||
{
|
||||
if (_isOpened)
|
||||
return;
|
||||
|
||||
var playerState = collider.GetComponent<PlayerState>();
|
||||
if (playerState != null)
|
||||
{
|
||||
_isOpened = true;
|
||||
|
||||
// Update player state
|
||||
playerState.SetKey();
|
||||
|
||||
// Notify GameManager of key collection
|
||||
if (GameManager.Instance != null)
|
||||
{
|
||||
GameManager.Instance.SetKeyState(true);
|
||||
}
|
||||
|
||||
// Notify LevelManager of key collection
|
||||
if (LevelManager.Instance != null)
|
||||
{
|
||||
LevelManager.Instance.NotifyKeyCollected();
|
||||
}
|
||||
|
||||
// Destroy the chest
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user