摄像机区域的架构改动
This commit is contained in:
53
Assets/_Game/Scripts/Tutorial/ContextualHintTrigger.cs
Normal file
53
Assets/_Game/Scripts/Tutorial/ContextualHintTrigger.cs
Normal 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 = ""; // 本地化 Key(Table_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user