fix power unit shield bug
This commit is contained in:
1 parent
e3d19955f1
commit
13c0aca9ee
3 files changed
+27
-11
No files matched your search
+19
-6
@@ -32,14 +32,16 @@ public class PowerUnit {
|
|||||||
static float initialShieldMax = 5000f;
|
static float initialShieldMax = 5000f;
|
||||||
float shieldCurrent = initialShieldMax;
|
float shieldCurrent = initialShieldMax;
|
||||||
float shieldMax = initialShieldMax;
|
float shieldMax = initialShieldMax;
|
||||||
float shieldRegen = 10f; // * 100 ticks per second = 5s fully recharge
|
static float shieldBoostIncrease = 1000f;
|
||||||
|
static float shieldBoostAmount = 1000f;
|
||||||
|
|
||||||
public float Shield => shieldCurrent;
|
public float Shield => shieldCurrent;
|
||||||
public float ShieldMax => shieldMax;
|
|
||||||
public string ShieldPct => $"{((shieldCurrent / shieldMax) * 100f):0}";
|
public string ShieldPct => $"{((shieldCurrent / shieldMax) * 100f):0}";
|
||||||
float ShieldRegen => BoostActive.Count switch {
|
|
||||||
0 => (shieldMax / 5f) * Time.fixedDeltaTime,
|
bool UsingMovementBoost => BoostActive.Any(b => b.output != Output.Shield);
|
||||||
_ => 0f,
|
float ShieldRegen => UsingMovementBoost switch {
|
||||||
|
false => (shieldMax / 5f) * Time.fixedDeltaTime,
|
||||||
|
true => 0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Boost
|
// Boost
|
||||||
@@ -80,6 +82,8 @@ public class PowerUnit {
|
|||||||
if (boostAvailable < boostDurationSeconds) return;
|
if (boostAvailable < boostDurationSeconds) return;
|
||||||
BoostActive.Add((output, Time.timeAsDouble + boostDurationSeconds));
|
BoostActive.Add((output, Time.timeAsDouble + boostDurationSeconds));
|
||||||
boostAvailable -= boostDurationSeconds;
|
boostAvailable -= boostDurationSeconds;
|
||||||
|
|
||||||
|
if (output == Output.Shield) ShieldsBoost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick() {
|
public void Tick() {
|
||||||
@@ -104,7 +108,7 @@ public class PowerUnit {
|
|||||||
boostProgress = Math.Max(0f, next);
|
boostProgress = Math.Max(0f, next);
|
||||||
if (delta > 0f) boostAvailable = boostProgress;
|
if (delta > 0f) boostAvailable = boostProgress;
|
||||||
|
|
||||||
shieldMax = initialShieldMax + BoostActive.Count(b => b.output == Output.Shield) * 1000f;
|
ShieldsSetMax();
|
||||||
shieldCurrent = Math.Min(shieldCurrent + ShieldRegen, shieldMax);
|
shieldCurrent = Math.Min(shieldCurrent + ShieldRegen, shieldMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,4 +117,13 @@ public class PowerUnit {
|
|||||||
shieldCurrent = shieldCurrent - amt;
|
shieldCurrent = shieldCurrent - amt;
|
||||||
return shieldCurrent < 0f;
|
return shieldCurrent < 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShieldsBoost() {
|
||||||
|
ShieldsSetMax();
|
||||||
|
shieldCurrent = Math.Min(shieldCurrent + shieldBoostIncrease, shieldMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShieldsSetMax() {
|
||||||
|
shieldMax = initialShieldMax + BoostActive.Count(b => b.output == Output.Shield) * shieldBoostAmount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,8 @@ PlayerSettings:
|
|||||||
vulkanEnableCommandBufferRecycling: 1
|
vulkanEnableCommandBufferRecycling: 1
|
||||||
loadStoreDebugModeEnabled: 0
|
loadStoreDebugModeEnabled: 0
|
||||||
bundleVersion: 0.1
|
bundleVersion: 0.1
|
||||||
preloadedAssets: []
|
preloadedAssets:
|
||||||
|
- {fileID: 11400000, guid: 020903acd8b50dd45a683fb9312ba7af, type: 2}
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
m_HolographicPauseOnTrackingLoss: 1
|
m_HolographicPauseOnTrackingLoss: 1
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
# SpaceRace!
|
# SpaceRace!
|
||||||
|
|
||||||
- controls diagram
|
- post times to server
|
||||||
|
- in theory yes
|
||||||
|
- rename completions to laps with migration
|
||||||
|
|
||||||
- shield regen bug
|
- controls diagram
|
||||||
|
- mouse / controller sens
|
||||||
|
- invert y
|
||||||
|
|
||||||
- git lfs
|
- git lfs
|
||||||
|
|
||||||
- post times to server
|
|
||||||
|
|
||||||
- models
|
- models
|
||||||
- liquidator
|
- liquidator
|
||||||
- cruise craft racing
|
- cruise craft racing
|
||||||
|
|||||||
Reference in new issue
Block a user