chore: initial commit

This commit is contained in:
2026-05-08 11:04:00 +08:00
commit f55d2a57c3
6278 changed files with 866081 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
using System.Collections;
using UnityEngine;
using BaseGames.Core.Events;
namespace BaseGames.Core
{
/// <summary>
/// 死亡/复活流程服务接口。
/// </summary>
public interface IDeathRespawnService
{
/// <summary>玩家死亡时由 GameManager 调用,启动死亡演出流程。</summary>
IEnumerator StartDeathSequenceCoroutine();
/// <summary>DeathScreen 确认按钮点击后调用,执行复活流程。</summary>
IEnumerator StartRespawnCoroutine();
/// <summary>SteelSoul 模式HP 归零后直接清档并返回主菜单。</summary>
IEnumerator StartGameOverCoroutine();
}
/// <summary>
/// 死亡/复活流程独立服务Phase 0 骨架Phase 1 完整实现)。
/// </summary>
public class DeathRespawnService : MonoBehaviour, IDeathRespawnService
{
[Header("Config")]
[SerializeField] private float _deathAnimDuration = 1.2f;
[SerializeField] private float _deathScreenDelay = 0.5f;
[SerializeField] private float _respawnFadeDuration = 0.4f;
[Header("Event Channels - Raise")]
[SerializeField] private VoidEventChannelSO _onRespawnStarted;
[SerializeField] private VoidEventChannelSO _onRespawnCompleted;
[Header("Event Channels - Listen")]
[SerializeField] private VoidEventChannelSO _onDeathScreenConfirmed;
private bool _deathConfirmed;
private void OnEnable()
{
if (_onDeathScreenConfirmed != null)
_onDeathScreenConfirmed.OnEventRaised += HandleDeathScreenConfirmed;
}
private void OnDisable()
{
if (_onDeathScreenConfirmed != null)
_onDeathScreenConfirmed.OnEventRaised -= HandleDeathScreenConfirmed;
}
private void HandleDeathScreenConfirmed() => _deathConfirmed = true;
public IEnumerator StartDeathSequenceCoroutine()
{
yield return new WaitForSeconds(_deathAnimDuration);
yield return new WaitForSeconds(_deathScreenDelay);
_deathConfirmed = false;
yield return new WaitUntil(() => _deathConfirmed);
}
public IEnumerator StartRespawnCoroutine()
{
_onRespawnStarted?.Raise();
yield return new WaitForSeconds(_respawnFadeDuration);
// Phase 1加载存档场景TODO
yield return new WaitForSeconds(_respawnFadeDuration);
_onRespawnCompleted?.Raise();
}
public IEnumerator StartGameOverCoroutine()
{
// Phase 1SteelSoul 清档并返回主菜单TODO
yield return null;
}
}
}