boost bar and cds
This commit is contained in:
1 parent
0e8a7a65ad
commit
3aacbed784
7 files changed
+141
-18
No files matched your search
+19
-9
@@ -46,11 +46,12 @@ public class PowerUnit {
|
||||
List<(Output output, double expiresAt)> boostActive = new();
|
||||
static double boostFullChargeSeconds = 10f;
|
||||
static double boostDurationSeconds = 2f;
|
||||
double boostMax = 2f * boostDurationSeconds;
|
||||
double boostAvailable = 0f; // in seconds
|
||||
double boostMax = 2f * boostDurationSeconds;
|
||||
double boostProgress = 0f;
|
||||
double boostAvailable = 0f;
|
||||
|
||||
public string BoostAvailable => $"{boostAvailable / 2f:0.0}";
|
||||
// public string BoostAvailable => $"{((boostAvailable / boostMax) * 100f):0}";
|
||||
public double BoostProgress => boostProgress / boostMax;
|
||||
public int BoostCharges => (int)(boostMax / boostDurationSeconds);
|
||||
|
||||
public float Acceleration =>
|
||||
acceleration + boostActive.Count(b => b.output == Output.Acceleration) * baseOutput;
|
||||
@@ -69,18 +70,21 @@ public class PowerUnit {
|
||||
strafing = initialStrafing;
|
||||
|
||||
boostActive = new();
|
||||
boostAvailable = 0f;
|
||||
boostProgress = 0f;
|
||||
|
||||
shieldMax = initialShieldMax ;
|
||||
shieldMax = initialShieldMax;
|
||||
shieldCurrent = initialShieldMax;
|
||||
}
|
||||
|
||||
public void Deploy(Output output) {
|
||||
if (boostAvailable < boostDurationSeconds * (boostActive.Count + 1)) return;
|
||||
if (boostAvailable < boostDurationSeconds) return;
|
||||
boostActive.Add((output, Time.timeAsDouble + boostDurationSeconds));
|
||||
boostAvailable -= boostDurationSeconds;
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
if (boostProgress <= 0f) boostActive.Clear();
|
||||
|
||||
// remove expired boosts
|
||||
boostActive = boostActive.Where(b => b.expiresAt > Time.timeAsDouble).ToList();
|
||||
|
||||
@@ -91,8 +95,14 @@ public class PowerUnit {
|
||||
int count => count * Time.fixedDeltaTime * -1f,
|
||||
};
|
||||
|
||||
double next = Math.Min(boostAvailable + delta, boostMax);
|
||||
boostAvailable = Math.Max(0f, next);
|
||||
// boost available gets dragged up by the clock
|
||||
// when the delta is positive
|
||||
// which can only happen when there are no active boosts
|
||||
// check it vvvv
|
||||
// Debug.Log($"Progress={boostProgress} actualAvailability={boostAvailable}");
|
||||
double next = Math.Min(boostProgress + delta, boostMax);
|
||||
boostProgress = Math.Max(0f, next);
|
||||
if (delta > 0f) boostAvailable = boostProgress;
|
||||
|
||||
shieldMax = initialShieldMax + boostActive.Count(b => b.output == Output.Shield) * 1000f;
|
||||
shieldCurrent = Math.Min(shieldCurrent + ShieldRegen, shieldMax);
|
||||
|
||||
Reference in new issue
Block a user