跳转到内容

SusUnitCard

SusUnitCard

花名册 / 商店单位摘要 — 头像、名称 / 类型、HP · AP · 等级、可选徽章及 actions 插槽。

SusGame · 分子(商业)

在 Playground 中打开

SusGame · Molecules

属性

名称类型默认值
UnitNameProp<string>""
UnitTypeProp<string>""
ImageProp<string>""
IconProp<string>""
ImageSizeProp<int>160
IconSizeProp<int>32
HpProp<int>100
MaxHpProp<int>100
ApProp<int>0
LevelProp<int>1
SelectedProp<bool>false
DisabledProp<bool>false
HighlightProp<bool>false
BadgeTextProp<string>""

插槽

名称
actions

事件

名称字段载荷
ClickedOnClickedSusUnitCard

样式钩子

USS 类契约 — 无需改 C# 即可覆盖外观。状态通过这些类切换:

  • sus-slot
  • sus-unit-card
  • sus-unit-card__badge
  • sus-unit-card__body
  • sus-unit-card__footer
  • sus-unit-card__header
  • sus-unit-card__header-info
  • sus-unit-card__icon
  • sus-unit-card__image
  • sus-unit-card__name
  • sus-unit-card__stat
  • sus-unit-card__stat-label
  • sus-unit-card__stat-value
  • sus-unit-card__subtitle
  • sus-unit-card--disabled
  • sus-unit-card--highlight
  • sus-unit-card--selected

用法

Props 驱动外观;媒体通过 SusGameMedia。点击会触发 OnClicked,除非 Disabled

csharp
var card = new SusUnitCard();
card.UnitName.Value = "Mara";
card.UnitType.Value = "Sergeant";
card.Image.Value = "portraits/mara";
card.Icon.Value = "";
card.Hp.Value = 42;
card.MaxHp.Value = 50;
card.Ap.Value = 4;
card.Level.Value = 3;
card.Selected.Value = true;
card.BadgeText.Value = "Turn";
card.OnClicked += c => { /* select unit */ };
// Optional: card.RefreshMedia();
xml
<template>
  <sus:SusUnitCard :UnitName="Name.Value"
                   :UnitType="Type.Value"
                   :Image="Img.Value"
                   :Icon="Icon.Value"
                   :IconSize="IcoSize.Value"
                   :Hp="Hp.Value"
                   :MaxHp="MaxHp.Value"
                   :Ap="Ap.Value"
                   :Level="Level.Value"
                   :Selected="Sel.Value"
                   :Disabled="Dis.Value"
                   :Highlight="Hi.Value"
                   :BadgeText="Badge.Value"
                   @clicked="OnClicked">
    <!-- slot actions: e.g. SusButton row -->
  </sus:SusUnitCard>
</template>

<script>
public Prop<string> Name = new("Mara");
public Prop<string> Type = new("Sergeant");
public Prop<string> Img = new("portraits/mara");
public Prop<string> Icon = new("");
public Prop<int> IcoSize = new(32);
public Prop<int> Hp = new(42);
public Prop<int> MaxHp = new(50);
public Prop<int> Ap = new(4);
public Prop<int> Level = new(3);
public Prop<bool> Sel = new(true);
public Prop<bool> Dis = new(false);
public Prop<bool> Hi = new(false);
public Prop<string> Badge = new("Turn");
void OnClicked(SusUnitCard card) { /* … */ }
</script>
Prop / API作用
UnitName · UnitType标题 + 副标题(UnitType → 副标题标签)
Image · Icon头像目录 key / 图标回退(优先使用 Image
ImageSize已声明(默认 160);头像外观是 USS 3:4 — 绘制不会通过该 prop 被压扁
IconSize元信息图标尺寸(默认 32
Hp · MaxHpHP 行显示为 Hp / MaxHp
Ap · Level属性行
Selected · Disabled · HighlightBEM 状态类;Disabled 会阻止 OnClicked
BadgeText非空时显示的角标
actions slot底部操作行
RefreshMedia()延迟绑定后重新应用图片 / 图标
OnClicked负载 = 该卡片本身

备注