bars work dgaf

This commit is contained in:
ntr committed 2023-08-22 19:53:03 +10:00
1 parent 56ed2a4e89
commit a065c09e47
3 files changed
+108 -20

No files matched your search

+12 -12
View File
@@ -37,30 +37,30 @@ public class PowerUnit {
public float Shield => shieldCurrent;
public float ShieldMax => shieldMax;
public string ShieldPct => $"{((shieldCurrent / shieldMax) * 100f):0}";
float ShieldRegen => boostActive.Count switch {
float ShieldRegen => BoostActive.Count switch {
0 => (shieldMax / 5f) * Time.fixedDeltaTime,
_ => 0f,
};
// Boost
List<(Output output, double expiresAt)> boostActive = new();
static double boostFullChargeSeconds = 10f;
static double boostDurationSeconds = 2f;
public static double boostDurationSeconds = 2f;
double boostMax = 2f * boostDurationSeconds;
double boostProgress = 0f;
double boostAvailable = 0f;
public List<(Output output, double expiresAt)> BoostActive = new();
public double BoostProgress => boostProgress / boostMax;
public int BoostCharges => (int)(boostMax / boostDurationSeconds);
public float Acceleration =>
acceleration + boostActive.Count(b => b.output == Output.Acceleration) * baseOutput;
acceleration + BoostActive.Count(b => b.output == Output.Acceleration) * baseOutput;
public float Deceleration =>
deceleration + boostActive.Count(b => b.output == Output.Deceleration) * baseOutput;
deceleration + BoostActive.Count(b => b.output == Output.Deceleration) * baseOutput;
public float Strafing =>
strafing + boostActive.Count(b => b.output == Output.Strafing) * baseOutput;
strafing + BoostActive.Count(b => b.output == Output.Strafing) * baseOutput;
double BoostRegen => (boostMax / boostFullChargeSeconds) * Time.fixedDeltaTime;
@@ -69,7 +69,7 @@ public class PowerUnit {
deceleration = initialDeceleration;
strafing = initialStrafing;
boostActive = new();
BoostActive = new();
boostProgress = 0f;
shieldMax = initialShieldMax;
@@ -78,17 +78,17 @@ public class PowerUnit {
public void Deploy(Output output) {
if (boostAvailable < boostDurationSeconds) return;
boostActive.Add((output, Time.timeAsDouble + boostDurationSeconds));
BoostActive.Add((output, Time.timeAsDouble + boostDurationSeconds));
boostAvailable -= boostDurationSeconds;
}
public void Tick() {
if (boostProgress <= 0f) boostActive.Clear();
if (boostProgress <= 0f) BoostActive.Clear();
// remove expired boosts
boostActive = boostActive.Where(b => b.expiresAt > Time.timeAsDouble).ToList();
BoostActive = BoostActive.Where(b => b.expiresAt > Time.timeAsDouble).ToList();
double delta = boostActive.Count switch {
double delta = BoostActive.Count switch {
// if there are no boosts active we can increase the store
0 => BoostRegen,
// if there are active boosts we deplete it
@@ -104,7 +104,7 @@ public class PowerUnit {
boostProgress = Math.Max(0f, next);
if (delta > 0f) boostAvailable = boostProgress;
shieldMax = initialShieldMax + boostActive.Count(b => b.output == Output.Shield) * 1000f;
shieldMax = initialShieldMax + BoostActive.Count(b => b.output == Output.Shield) * 1000f;
shieldCurrent = Math.Min(shieldCurrent + ShieldRegen, shieldMax);
}