7579175d24
- Removed obsolete scripts: Chest, BreakableWall, Door, DoorInteract, and UiManager. - Moved Chest and BreakableWall scripts to EnvironmentObjects folder. - Introduced HammerThrower class to manage hammer throwing mechanics. - Updated PlayerController to utilize new InputManager and HammerThrower. - Refactored PlayerState to manage player state and item collection. - Enhanced UI management in UiManager to reflect player item collection. - Updated EnemyAI to remove unused movement logic. - Adjusted KeyChest to interact with PlayerState instead of Player. - Cleaned up code and improved event handling for item collection.
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;
|
|
}
|
|
} |