chore():整理了一下文件夹和玩家的血量逻辑

This commit is contained in:
2025-10-18 15:41:43 +08:00
parent ab403fac4b
commit b709d1219f
17 changed files with 214 additions and 33 deletions

View File

@@ -5,43 +5,54 @@ using Gameplay;
using Interface;
using UnityEngine;
using Core;
using Script.Gameplay.Global;
namespace Gameplay.Player
{
public class PlayerController : MonoBehaviour
public class PlayerController : MonoBehaviour, IDamageable
{
public int MaxHealth { get; set; } = 100;
public int CurrentHealth { get; private set; }
private int currentCardIndex = 0;
public bool IsFlight { get; private set; }
public bool IsDead { get; private set; }
[SerializeField] private int MaxHealth = 100;
private int currentHealth;
public int CurrentHealth
{
get => currentHealth;
private set
{
currentHealth = value;
OnHealthChanged?.Invoke(currentHealth);
}
}
public event Action<int> OnHealthChanged;
public event Action OnDeath;
private PlayerMoveController playerMoveController;
private PlayerCameraController playerCameraController;
private void Awake()
{
playerMoveController = GetComponent<PlayerMoveController>();
playerCameraController = GetComponent<PlayerCameraController>();
CurrentHealth = MaxHealth;
ControllerLocator.Instance.Register(this);
}
private void Start()
{
OnDeath += GameFlowManager.Instance.RestartGame;
}
public void TakeDamage(int damage)
{
CurrentHealth -= damage;
if (CurrentHealth <= 0)
{
CurrentHealth = 0;
OnDeath?.Invoke();
}
}
public void Heal(int heal)