重构随机角色卡交互并清理 SelectRoleForm 视图层
按 5 层 UI 规范的 §3.5(View 只消费 Context、不内嵌业务/数据筛选) 对 SelectRoleForm 视图侧做一轮收敛,顺带把"随机角色卡"与"角色槽"在结构层面分离,让 prefab 不再依赖 GetComponentsInChildren 顺序来跳过随机卡上的 RoleItem 占位。 RoleItem: - UpdateShowRole() → OnHoverEnter()。原方法名与 Form/Controller 上曾经存在的 UpdateShowRole 同名,但语义完全不同(后者是切换属性卡显示,这里是上报 hover 事件),改名消除歧义,与 prefab 上 PointerEnter 绑定的实际语义对齐。 - 补 _context == null 早退,不再把 RoleId = -1 的"伪 hover"上报到下游、依赖 UseCase 端的哨兵兜底。 SelectRoleForm: - 新增 OnRandomConfirmClick(),给随机角色卡的 CommonButton 提供独立的 Click 入口,直接发 SelectRoleConfirmEventArgs,不再借 RoleItem.OnConfirmRoleClick 这条路径。 - RefreshUI 由 while + 双下标(itemIndex / roleIndex 同步推进、itemIndex 起步为 1 跳过随机卡上的 RoleItem 占位)收成单下标 for,起步下标恢复 0;槽位不足时 OnReset 放在 SetActive(false) 之前,语义顺序更自然。 - 清掉未使用的 using System。
This commit is contained in:
@@ -27,10 +27,14 @@ namespace SepCore.UI
|
||||
_context = null;
|
||||
}
|
||||
|
||||
public void UpdateShowRole()
|
||||
public void OnHoverEnter()
|
||||
{
|
||||
int roleId = _context?.RoleId ?? -1;
|
||||
GameEntry.Event.Fire(this, SelectRoleHoverEventArgs.Create(roleId));
|
||||
if (_context == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Fire(this, SelectRoleHoverEventArgs.Create(_context.RoleId));
|
||||
}
|
||||
|
||||
public void OnConfirmRoleClick()
|
||||
|
||||
Reference in New Issue
Block a user