多轮审查和修复
This commit is contained in:
@@ -52,14 +52,18 @@ public class RoomTransition : MonoBehaviour
|
||||
{
|
||||
[Header("Config")]
|
||||
[SerializeField] private string _transitionId; // 唯一 ID(目标出口用于匹配出生点)
|
||||
[SerializeField] private string _targetSceneName; // 目标场景(AddressKeys 常量)
|
||||
[SerializeField] private string _targetSceneAddress; // 目标场景 Addressable key(AddressKeys 常量)
|
||||
[SerializeField] private string _targetTransitionId; // 目标场景中对应出口的 ID
|
||||
[SerializeField] private bool _requiresKeyItem; // 是否需要持有钥匙物品
|
||||
[SerializeField] private string _requiredItemId; // 钥匙物品 ID
|
||||
[SerializeField] private bool _autoTrigger = true; // true = 进入触发器自动触发;false = 需交互
|
||||
[SerializeField] private bool _requiresKeyItem; // 是否需要持有鑰匙物品
|
||||
[SerializeField] private string _requiredItemId; // 鑰匙物品 ID
|
||||
|
||||
[Header("Event Channel")]
|
||||
[SerializeField] private SceneLoadRequestEventChannelSO _onSceneLoadRequest;
|
||||
|
||||
[Header("世界状态")]
|
||||
[SerializeField] private WorldStateRegistry _worldState; // 持有物品检查
|
||||
|
||||
// 玩家进入触发器
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
@@ -75,7 +79,12 @@ public class RoomTransition : MonoBehaviour
|
||||
});
|
||||
}
|
||||
|
||||
private bool HasItem(string itemId); // 查询 PlayerStats 或 Inventory
|
||||
private bool HasItem(string itemId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(itemId)) return true;
|
||||
if (_worldState == null) return false; // 未配置则拦截(警告日志)
|
||||
return _worldState.IsCollected(itemId);
|
||||
}
|
||||
|
||||
// Editor:在 Scene View 显示箭头 Gizmo
|
||||
private void OnDrawGizmos();
|
||||
@@ -222,8 +231,12 @@ public class Collectible : MonoBehaviour
|
||||
|
||||
private void Despawn(); // 归还对象池
|
||||
|
||||
// 敌人死亡时生成 Geo Collectible(由 EnemyBase 调用)
|
||||
public static void SpawnGeo(Vector2 position, int amount, ObjectPoolManager pool);
|
||||
// ―― 运行时配置(由 CollectibleSpawner 在实例化后调用)――――――――――――――――
|
||||
/// <summary>将此 Collectible 配置为 Geo 掉落。</summary>
|
||||
public void SetGeo(int amount);
|
||||
|
||||
/// <summary>将此 Collectible 配置为道具掉落。</summary>
|
||||
public void SetItem(string itemId);
|
||||
}
|
||||
|
||||
public enum CollectibleType { Geo, Item, HPOrb }
|
||||
@@ -231,6 +244,30 @@ public enum CollectibleType { Geo, Item, HPOrb }
|
||||
|
||||
---
|
||||
|
||||
## 5b. CollectibleSpawner
|
||||
|
||||
```csharp
|
||||
// 路径: Assets/Scripts/World/CollectibleSpawner.cs + CollectibleSpawnerConfig.cs
|
||||
// 封装 Collectible Prefab 实例化逻辑,供 LootResolver 等静态调用。
|
||||
// CollectibleSpawnerConfig 挂在 Persistent 场景 [World] GameObject 上持有 Prefab 引用,
|
||||
// Awake 调用 CollectibleSpawner.Register(this) 注入静态配置。
|
||||
public static class CollectibleSpawner
|
||||
{
|
||||
internal static void Register(CollectibleSpawnerConfig config);
|
||||
public static void SpawnGeo(Vector2 position, int amount); // 实例化 GeoPrefab 并调用 SetGeo(amount)
|
||||
public static void SpawnItem(Vector2 position, string itemId); // 实例化 ItemPrefab 并调用 SetItem(itemId)
|
||||
}
|
||||
|
||||
public class CollectibleSpawnerConfig : MonoBehaviour
|
||||
{
|
||||
[SerializeField] internal GameObject GeoPrefab;
|
||||
[SerializeField] internal GameObject ItemPrefab;
|
||||
private void Awake() => CollectibleSpawner.Register(this);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. AbilityUnlock
|
||||
|
||||
```csharp
|
||||
|
||||
Reference in New Issue
Block a user