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.
30 lines
654 B
C#
30 lines
654 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class PlayerState : MonoBehaviour
|
|
{
|
|
public int Lives = 3;
|
|
public int TotalCoins { get; private set; }
|
|
public bool HasKey { get; private set; }
|
|
|
|
public event EventHandler<TreasureType> OnPlayerTakeItem;
|
|
|
|
public void AddCoin()
|
|
{
|
|
TotalCoins++;
|
|
OnPlayerTakeItem?.Invoke(this, TreasureType.Coin);
|
|
Debug.Log($"Player has {TotalCoins} coins");
|
|
}
|
|
|
|
public void SetKey()
|
|
{
|
|
HasKey = true;
|
|
OnPlayerTakeItem?.Invoke(this, TreasureType.Key);
|
|
Debug.Log("Player has key");
|
|
}
|
|
|
|
public void RemoveKey()
|
|
{
|
|
HasKey = false;
|
|
}
|
|
} |