多轮审查和修复

This commit is contained in:
2026-05-12 15:34:08 +08:00
parent f55d2a57c3
commit ebbbb7332e
805 changed files with 838724 additions and 1905 deletions

View File

@@ -0,0 +1,53 @@
using UnityEngine;
using BaseGames.Core;
using BaseGames.Player;
using BaseGames.Localization;
namespace BaseGames.Tutorial
{
/// <summary>
/// 情境化教程触发器(架构 21_LiquidPuzzleModule §18
/// 当玩家进入 Trigger 碰撞体范围时,向 TutorialManager 请求显示提示。
/// 若 _requiresAbility = true只在玩家拥有 _requiredAbility 后才触发。
/// 每个触发器只触发一次(触发后禁用自身)。
/// </summary>
[RequireComponent(typeof(Collider2D))]
public class ContextualHintTrigger : MonoBehaviour
{
[Header("提示配置")]
[SerializeField] private string _hintId = "";
[SerializeField] private string _hintLocKey = ""; // 本地化 KeyTable_UI
[SerializeField] private float _displayDuration = 4f;
[Header("能力门控")]
[SerializeField] private bool _requiresAbility = false;
[SerializeField] private AbilityType _requiredAbility = AbilityType.None;
private void Awake()
{
var col = GetComponent<Collider2D>();
col.isTrigger = true;
}
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag("Player")) return;
var tm = ServiceLocator.GetOrDefault<ITutorialService>();
if (tm == null) return;
// 能力门控检查
if (_requiresAbility)
{
var stats = other.GetComponent<PlayerStats>();
if (stats == null || !stats.HasAbility(_requiredAbility)) return;
}
string text = LocalizationManager.Get(_hintLocKey, "UI");
tm.ShowHint(_hintId, text, _displayDuration);
tm.CompleteHint(_hintId); // 写入 SaveData防止场景重载后重复触发
// 单次触发后禁用(避免重复弹出)
gameObject.SetActive(false);
}
}
}