生命值
在本章中,您将会学习到:
- 生命值增长原型
- 连击生命值增长设置
- 次要指标 UI 设置
生命值增长原型
对于每一种原型,当玩家获得一种判定类型时,我们都可以奖励或惩罚玩家。
在我们的引擎中,我们将在玩家获得 Perfect 判定时奖励玩家 10
点生命值,并在玩家获得 Miss 判定时惩罚玩家 100
点生命值。
class Initialization: public Archetype {
// ...
SonolusApi preprocess() {
FUNCBEGIN
// ...
lifes[3].set(10, 0, 0, -100);
return VOID;
}
// ...
};
连击生命值增长
与分数类似,无论哪种原型,我们都可以当玩家获得了大于等于一定数量的目标判定后,奖励或惩罚玩家。
在我们的引擎中,当玩家获得了连续 10
个 Perfect 判定后,就奖励 50
点生命值。
class Initialization: public Archetype {
// ...
SonolusApi preprocess() {
FUNCBEGIN
// ...
LevelLife.set(0, 50);
LevelLife.set(1, 10);
return VOID;
}
// ...
};
次要指标 UI
与主要指标 UI 类似,Sonolus 提供了次要指标栏与次要指标值 UI,并通常用于显示生命值。
class Initialization: public Archetype {
// ...
SonolusApi preprocess() {
FUNCBEGIN
// ...
let secondaryMetricBarX = stage.r - 0.05;
let secondaryMetricBarY = stage.t - 0.05 - 0.15 * ui.secondaryMetricConfiguration.scale - 0.05;
let secondaryMetricBarWidth = 0.75 * ui.secondaryMetricConfiguration.scale;
let secondaryMetricBarHeight = 0.15 * ui.secondaryMetricConfiguration.scale;
let secondaryMetricValueX = stage.r - 0.05 - 0.035 * ui.secondaryMetricConfiguration.scale;
let secondaryMetricValueY = stage.t - 0.05 - 0.15 * ui.secondaryMetricConfiguration.scale - 0.05 - 0.035 * ui.secondaryMetricConfiguration.scale;
let secondaryMetricValueWidth = 0 * ui.secondaryMetricConfiguration.scale;
let secondaryMetricValueHeight = 0.08 * ui.secondaryMetricConfiguration.scale;
ui.secondaryMetricBar.set(
secondaryMetricBarX, secondaryMetricBarY,
1, 1,
secondaryMetricBarWidth, secondaryMetricBarHeight,
0,
ui.secondaryMetricConfiguration.alpha,
HorizontalAlign.Left,
true
);
ui.secondaryMetricValue.set(
secondaryMetricValueX, secondaryMetricValueY,
1, 1,
secondaryMetricValueWidth, secondaryMetricValueHeight,
0,
ui.secondaryMetricConfiguration.alpha,
HorizontalAlign.Right,
false
);
// ...
return VOID;
}
// ...
};