多轮审查评估

This commit is contained in:
2026-05-13 09:19:54 +08:00
parent 458f344e83
commit 1b37297585
57 changed files with 3019 additions and 218 deletions

View File

@@ -13,6 +13,7 @@
"BaseGames.Core.Save",
"BaseGames.Input",
"BaseGames.Combat",
"BaseGames.Localization",
"Unity.TextMeshPro",
"Unity.InputSystem",
"BaseGames.Equipment"

View File

@@ -55,8 +55,8 @@ namespace BaseGames.UI
? _parentCanvas.worldCamera
: UnityEngine.Camera.main;
var screenPoint = UnityEngine.Camera.main != null
? (Vector2)UnityEngine.Camera.main.WorldToScreenPoint(worldPosition)
var screenPoint = cam != null
? (Vector2)cam.WorldToScreenPoint(worldPosition)
: Vector2.zero;
var canvasRect = _parentCanvas != null

View File

@@ -29,8 +29,8 @@ namespace BaseGames.UI
private void SwitchIconSet(bool isGamepad)
{
Current = isGamepad ? _padIconSet : _kbIconSet;
// 通知所有图标 Image 刷新
foreach (var img in GetComponentsInChildren<InputIconImage>(includeInactive: true))
// 通知场景内所有图标 Image 刷新(包括非本对象子节点的其他 Canvas 区域)
foreach (var img in FindObjectsByType<InputIconImage>(FindObjectsInactive.Include, FindObjectsSortMode.None))
img.Refresh();
}
}

View File

@@ -3,12 +3,12 @@ using UnityEngine;
using UnityEngine.UI;
using TMPro;
using BaseGames.Core.Events;
using BaseGames.Localization;
namespace BaseGames.UI
{
/// <summary>
/// 全屏加载界面:进度条 + 提示文字 + 随机背景图(架构 10_UIModule §7.7)。
/// 注:提示文字直接使用字符串 keyP4-5 本地化模块完成后替换为 LocalizationManager.Get
/// </summary>
public class LoadingScreenManager : MonoBehaviour
{
@@ -16,7 +16,7 @@ namespace BaseGames.UI
[SerializeField] private Image _progressFill;
[SerializeField] private TMP_Text _tipText;
[SerializeField] private Image[] _backgroundArts;
[SerializeField] private string[] _tipMessages; // 直接文字(非本地化 key
[SerializeField] private string[] _tipMessages; // 本地化 key(对应 "UI" 表中的条目,如 "tip_explore"
[SerializeField] private float _minDisplayTime = 0.5f;
[Header("Event Channels")]
@@ -25,18 +25,17 @@ namespace BaseGames.UI
[SerializeField] private FloatEventChannelSO _onLoadingProgressUpdated;
private float _shownAt;
private readonly CompositeDisposable _subs = new();
private void OnEnable()
{
if (_onLoadingStarted != null) _onLoadingStarted.OnEventRaised += Show;
if (_onLoadingComplete != null) _onLoadingComplete.OnEventRaised += Hide;
if (_onLoadingProgressUpdated != null) _onLoadingProgressUpdated.OnEventRaised += SetProgress;
_onLoadingStarted?.Subscribe(Show).AddTo(_subs);
_onLoadingComplete?.Subscribe(Hide).AddTo(_subs);
_onLoadingProgressUpdated?.Subscribe(SetProgress).AddTo(_subs);
}
private void OnDisable()
{
if (_onLoadingStarted != null) _onLoadingStarted.OnEventRaised -= Show;
if (_onLoadingComplete != null) _onLoadingComplete.OnEventRaised -= Hide;
if (_onLoadingProgressUpdated != null) _onLoadingProgressUpdated.OnEventRaised -= SetProgress;
_subs.Clear();
}
// ── 公开 APISceneLoader 可直接调用)────────────────────────────────
@@ -54,9 +53,9 @@ namespace BaseGames.UI
_backgroundArts[Random.Range(0, _backgroundArts.Length)].enabled = true;
}
// 随机提示
// 随机提示(通过 LocalizationManager 解析 key
if (_tipText != null && _tipMessages != null && _tipMessages.Length > 0)
_tipText.text = _tipMessages[Random.Range(0, _tipMessages.Length)];
_tipText.text = LocalizationManager.Get(_tipMessages[Random.Range(0, _tipMessages.Length)], "UI");
}
public void Hide() => StartCoroutine(HideAfterMinTime());

View File

@@ -13,15 +13,21 @@ namespace BaseGames.UI.Menus
/// </summary>
public class SaveSlotController : MonoBehaviour
{
[SerializeField] private SaveSlotUI[] _slotUIs; // 3 个存档槽 UI
[SerializeField] private SaveSlotUI[] _slotUIs; // 存档槽 UI(数量由 Inspector 决定)
[SerializeField] private SaveManager _saveManager;
[Header("Event Channels")]
[SerializeField] private IntEventChannelSO _onSlotConfirmed; // 携带槽索引,供 GameManager 监听
private async void OnEnable()
private void OnEnable()
{
await RefreshAsync();
var task = RefreshAsync();
// 捕获 async Task 异常,避免 async void 吞掉未处理异常
task.ContinueWith(t =>
{
if (t.IsFaulted)
Debug.LogException(t.Exception?.InnerException ?? t.Exception, this);
}, TaskScheduler.FromCurrentSynchronizationContext());
}
private async Task RefreshAsync()
@@ -38,7 +44,7 @@ namespace BaseGames.UI.Menus
/// <summary>选中指定槽位(新局或继续)。由 SaveSlotUI 内部按钮调用。</summary>
public void OnSlotSelected(int slotIndex)
{
if (slotIndex < 0 || slotIndex >= 3 || _saveManager == null) return;
if (slotIndex < 0 || slotIndex >= _slotUIs.Length || _saveManager == null) return;
_ = SelectSlotAsync(slotIndex);
}
@@ -55,7 +61,7 @@ namespace BaseGames.UI.Menus
/// <summary>删除指定槽位存档并刷新 UI。由 SaveSlotUI 内部按钮调用。</summary>
public void OnSlotDeleteRequested(int slotIndex)
{
if (slotIndex < 0 || slotIndex >= 3 || _saveManager == null) return;
if (slotIndex < 0 || slotIndex >= _slotUIs.Length || _saveManager == null) return;
_ = DeleteAndRefreshAsync(slotIndex);
}

View File

@@ -50,9 +50,13 @@ namespace BaseGames.UI
{
if (_deathScreenRoot != null) _deathScreenRoot.SetActive(true);
}
else if (state == GameStates.Cutscene)
else
{
if (_hudRoot != null) _hudRoot.SetActive(false);
// 离开 Dead 状态时(复活/重生)隐藏死亡界面
if (_deathScreenRoot != null) _deathScreenRoot.SetActive(false);
if (state == GameStates.Cutscene)
if (_hudRoot != null) _hudRoot.SetActive(false);
}
}