boost
This commit is contained in:
1 parent
fddf8552c2
commit
0e8a7a65ad
2 files changed
+16
-6
No files matched your search
+13
-6
@@ -37,17 +37,20 @@ public class PowerUnit {
|
||||
public float Shield => shieldCurrent;
|
||||
public float ShieldMax => shieldMax;
|
||||
public string ShieldPct => $"{((shieldCurrent / shieldMax) * 100f):0}";
|
||||
float ShieldRegen => (shieldMax / 5f) * Time.fixedDeltaTime;
|
||||
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;
|
||||
double boostMax = 2f * boostDurationSeconds;
|
||||
double boostAvailable = 0f;
|
||||
double boostAvailable = 0f; // in seconds
|
||||
|
||||
// public string BoostAvailable => $"{boostAvailable}";
|
||||
public string BoostAvailable => $"{((boostAvailable / boostMax) * 100f):0}";
|
||||
public string BoostAvailable => $"{boostAvailable / 2f:0.0}";
|
||||
// public string BoostAvailable => $"{((boostAvailable / boostMax) * 100f):0}";
|
||||
|
||||
public float Acceleration =>
|
||||
acceleration + boostActive.Count(b => b.output == Output.Acceleration) * baseOutput;
|
||||
@@ -61,15 +64,19 @@ public class PowerUnit {
|
||||
double BoostRegen => (boostMax / boostFullChargeSeconds) * Time.fixedDeltaTime;
|
||||
|
||||
public void Reset() {
|
||||
shieldCurrent = initialShieldMax;
|
||||
acceleration = initialAcceleration;
|
||||
deceleration = initialDeceleration;
|
||||
strafing = initialStrafing;
|
||||
|
||||
boostActive = new();
|
||||
boostAvailable = 0f;
|
||||
|
||||
shieldMax = initialShieldMax ;
|
||||
shieldCurrent = initialShieldMax;
|
||||
}
|
||||
|
||||
public void Deploy(Output output) {
|
||||
if (boostAvailable < boostDurationSeconds * (boostActive.Count + 1)) return;
|
||||
boostActive.Add((output, Time.timeAsDouble + boostDurationSeconds));
|
||||
}
|
||||
|
||||
@@ -81,7 +88,7 @@ public class PowerUnit {
|
||||
// if there are no boosts active we can increase the store
|
||||
0 => BoostRegen,
|
||||
// if there are active boosts we deplete it
|
||||
int count => count * Time.fixedDeltaTime,
|
||||
int count => count * Time.fixedDeltaTime * -1f,
|
||||
};
|
||||
|
||||
double next = Math.Min(boostAvailable + delta, boostMax);
|
||||
|
||||
Reference in new issue
Block a user