摄像机区域的架构改动

This commit is contained in:
2026-05-15 14:47:24 +08:00
parent 1b37297585
commit f264329751
3591 changed files with 1687228 additions and 446503 deletions

View File

@@ -0,0 +1,50 @@
using System.Collections;
using UnityEngine;
using BaseGames.Feedback;
using BaseGames.Player;
namespace BaseGames.World
{
/// <summary>
/// 能力解锁触发物Prefab
/// 玩家进入触发区后播放解锁演出,然后调用 PlayerStats.UnlockAbility()。
/// </summary>
[RequireComponent(typeof(Collider2D))]
public class AbilityUnlock : MonoBehaviour
{
[Header("解锁配置")]
[SerializeField] private AbilityType _abilityToUnlock;
[SerializeField] private bool _destroyAfterUnlock = true;
[Header("演出配置")]
[SerializeField] private SceneFeedback _unlockFeedback;
[SerializeField] private float _cutsceneDuration = 1.5f;
[Header("Event Channel")]
[SerializeField] private AbilityTypeEventChannelSO _onAbilityUnlocked; // EVT_AbilityUnlocked
private bool _used;
private void OnTriggerEnter2D(Collider2D other)
{
if (_used || !other.CompareTag("Player")) return;
var stats = other.GetComponentInParent<PlayerStats>();
if (stats == null || stats.HasAbility(_abilityToUnlock)) return;
StartCoroutine(UnlockSequence(stats));
}
private IEnumerator UnlockSequence(PlayerStats stats)
{
_used = true;
_unlockFeedback?.Play();
yield return new WaitForSeconds(_cutsceneDuration);
stats.UnlockAbility(_abilityToUnlock);
_onAbilityUnlocked?.Raise(_abilityToUnlock);
if (_destroyAfterUnlock)
Destroy(gameObject);
}
}
}