UI and enemy movement
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
|
||||
|
||||
public class Player : Character
|
||||
{
|
||||
[SerializeField]
|
||||
@@ -18,6 +22,9 @@ public class Player : Character
|
||||
|
||||
private int _totalCoins = 0;
|
||||
private bool _hasKey = false;
|
||||
|
||||
public int TotalCoins => _totalCoins;
|
||||
|
||||
public static Player Instance { get; private set; }
|
||||
|
||||
private GameObject _hammer;
|
||||
@@ -25,6 +32,8 @@ public class Player : Character
|
||||
private bool _isHoldingHammer = true;
|
||||
private SpriteRenderer _spriteRenderer;
|
||||
|
||||
public event EventHandler<TreasureType> OnPlayerTakeItem;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null)
|
||||
@@ -44,11 +53,13 @@ public class Player : Character
|
||||
public void AddCoin()
|
||||
{
|
||||
_totalCoins++;
|
||||
OnPlayerTakeItem?.Invoke(this,TreasureType.Coin);
|
||||
print($"player have {_totalCoins} coins");
|
||||
}
|
||||
|
||||
public void SetKey()
|
||||
{
|
||||
OnPlayerTakeItem?.Invoke(this, TreasureType.Key);
|
||||
print($"player have key");
|
||||
_hasKey = true;
|
||||
}
|
||||
@@ -121,3 +132,4 @@ public class Player : Character
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user