UI 系统
This commit is contained in:
@@ -14,8 +14,9 @@ namespace BaseGames.UI
|
||||
/// 只读面板:按形态展示各技能槽的技能资料(名称、描述、消耗、冷却),不含任何解锁/技能点交互。
|
||||
/// 支持左右翻页浏览各形态,并高亮当前实际使用的形态。
|
||||
///
|
||||
/// 数据驱动:技能数据读 <see cref="FormSkillDatabaseSO"/>(与 SkillManager 共享的权威源),不再复制配置。
|
||||
/// Inspector 必填:
|
||||
/// _formSkillSets — 每个形态对应一条配置(soulSkill + spirit1 + spirit2)
|
||||
/// _database — FormSkillDatabaseSO(与玩家 SkillManager 同一资产)
|
||||
/// _formTitleText — 显示当前形态标签名的文本
|
||||
/// _prevFormBtn / _nextFormBtn — 翻页按钮
|
||||
/// _activeFormIndicator — 高亮"当前形态"的标志(可选,如小圆点)
|
||||
@@ -26,19 +27,6 @@ namespace BaseGames.UI
|
||||
{
|
||||
// ── 子数据结构 ────────────────────────────────────────────────────────
|
||||
|
||||
[System.Serializable]
|
||||
public struct FormSkillConfig
|
||||
{
|
||||
[Tooltip("形态标题的本地化 Key,格式如 \"Form_SkyWarden_Label\",由 LocalizationManager.Get(…, LocalizationTable.UI) 查找。")]
|
||||
public string formLabelKey;
|
||||
[Tooltip("天魂/地魂/命魂的「魂技」")]
|
||||
public FormSkillSO soulSkill;
|
||||
[Tooltip("灵技 1(Y / Triangle / 手柄按钮)")]
|
||||
public FormSkillSO spiritSkill1;
|
||||
[Tooltip("灵技 2(Shift+Y / L2+Triangle 等)")]
|
||||
public FormSkillSO spiritSkill2;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SkillSlotView
|
||||
{
|
||||
@@ -58,9 +46,8 @@ namespace BaseGames.UI
|
||||
|
||||
// ── Inspector 字段 ────────────────────────────────────────────────────
|
||||
|
||||
[Header("形态技能配置")]
|
||||
[Tooltip("每个元素对应一种形态的三项技能,顺序应与 FormType 枚举序号一致。")]
|
||||
[SerializeField] private FormSkillConfig[] _formSkillSets;
|
||||
[Header("形态技能数据库(权威源,与玩家 SkillManager 共享同一资产)")]
|
||||
[SerializeField] private FormSkillDatabaseSO _database;
|
||||
|
||||
[Header("UI 导航")]
|
||||
[SerializeField] private TMP_Text _formTitleText;
|
||||
@@ -87,6 +74,8 @@ namespace BaseGames.UI
|
||||
private int _activeIndex = 0; // 玩家当前实际使用的形态
|
||||
private readonly CompositeDisposable _subs = new();
|
||||
|
||||
private FormSkillDatabaseSO.Entry[] Entries => _database != null ? _database.Entries : null;
|
||||
|
||||
// ── 生命周期 ──────────────────────────────────────────────────────────
|
||||
|
||||
private void Awake()
|
||||
@@ -122,15 +111,17 @@ namespace BaseGames.UI
|
||||
|
||||
private void PrevForm()
|
||||
{
|
||||
if (_formSkillSets == null || _formSkillSets.Length == 0) return;
|
||||
_viewIndex = (_viewIndex - 1 + _formSkillSets.Length) % _formSkillSets.Length;
|
||||
var entries = Entries;
|
||||
if (entries == null || entries.Length == 0) return;
|
||||
_viewIndex = (_viewIndex - 1 + entries.Length) % entries.Length;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void NextForm()
|
||||
{
|
||||
if (_formSkillSets == null || _formSkillSets.Length == 0) return;
|
||||
_viewIndex = (_viewIndex + 1) % _formSkillSets.Length;
|
||||
var entries = Entries;
|
||||
if (entries == null || entries.Length == 0) return;
|
||||
_viewIndex = (_viewIndex + 1) % entries.Length;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -138,10 +129,11 @@ namespace BaseGames.UI
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
if (_formSkillSets == null || _formSkillSets.Length == 0) return;
|
||||
_viewIndex = Mathf.Clamp(_viewIndex, 0, _formSkillSets.Length - 1);
|
||||
var entries = Entries;
|
||||
if (entries == null || entries.Length == 0) return;
|
||||
_viewIndex = Mathf.Clamp(_viewIndex, 0, entries.Length - 1);
|
||||
|
||||
var cfg = _formSkillSets[_viewIndex];
|
||||
var cfg = entries[_viewIndex];
|
||||
|
||||
// 标题(走本地化管道,fallback 为 key 本身)
|
||||
if (_formTitleText != null)
|
||||
@@ -159,7 +151,7 @@ namespace BaseGames.UI
|
||||
_activeFormIndicator.SetActive(_viewIndex == _activeIndex);
|
||||
|
||||
// 翻页按钮可见性(只有一种形态时隐藏)
|
||||
bool multiForm = _formSkillSets.Length > 1;
|
||||
bool multiForm = entries.Length > 1;
|
||||
if (_prevFormBtn != null) _prevFormBtn.gameObject.SetActive(multiForm);
|
||||
if (_nextFormBtn != null) _nextFormBtn.gameObject.SetActive(multiForm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user