Files
Gnome-s-Bounty/Assets/Scripts/PlayerState.cs
T

27 lines
620 B
C#

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;
}
}