Merge branch 'server' of ssh://mnml-studios/~/SpaceRace
This commit is contained in:
commit
cc0a86820d
21 files changed
+488
-17
No files matched your search
+19
-6
@@ -32,14 +32,16 @@ public class PowerUnit {
|
||||
static float initialShieldMax = 5000f;
|
||||
float shieldCurrent = 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 ShieldMax => shieldMax;
|
||||
public string ShieldPct => $"{((shieldCurrent / shieldMax) * 100f):0}";
|
||||
float ShieldRegen => BoostActive.Count switch {
|
||||
0 => (shieldMax / 5f) * Time.fixedDeltaTime,
|
||||
_ => 0f,
|
||||
|
||||
bool UsingMovementBoost => BoostActive.Any(b => b.output != Output.Shield);
|
||||
float ShieldRegen => UsingMovementBoost switch {
|
||||
false => (shieldMax / 5f) * Time.fixedDeltaTime,
|
||||
true => 0f,
|
||||
};
|
||||
|
||||
// Boost
|
||||
@@ -80,6 +82,8 @@ public class PowerUnit {
|
||||
if (boostAvailable < boostDurationSeconds) return;
|
||||
BoostActive.Add((output, Time.timeAsDouble + boostDurationSeconds));
|
||||
boostAvailable -= boostDurationSeconds;
|
||||
|
||||
if (output == Output.Shield) ShieldsBoost();
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
@@ -104,7 +108,7 @@ public class PowerUnit {
|
||||
boostProgress = Math.Max(0f, next);
|
||||
if (delta > 0f) boostAvailable = boostProgress;
|
||||
|
||||
shieldMax = initialShieldMax + BoostActive.Count(b => b.output == Output.Shield) * 1000f;
|
||||
ShieldsSetMax();
|
||||
shieldCurrent = Math.Min(shieldCurrent + ShieldRegen, shieldMax);
|
||||
}
|
||||
|
||||
@@ -113,4 +117,13 @@ public class PowerUnit {
|
||||
shieldCurrent = shieldCurrent - amt;
|
||||
return shieldCurrent < 0f;
|
||||
}
|
||||
|
||||
void ShieldsBoost() {
|
||||
ShieldsSetMax();
|
||||
shieldCurrent = Math.Min(shieldCurrent + shieldBoostIncrease, shieldMax);
|
||||
}
|
||||
|
||||
void ShieldsSetMax() {
|
||||
shieldMax = initialShieldMax + BoostActive.Count(b => b.output == Output.Shield) * shieldBoostAmount;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ public class ShipControls : MonoBehaviour {
|
||||
|
||||
public PowerUnit powerUnit = new();
|
||||
|
||||
public float Speed => rigidBody.velocity.magnitude;
|
||||
|
||||
void Start() {
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
rigidBody = GetComponent<Rigidbody>();
|
||||
@@ -160,10 +162,6 @@ public class ShipControls : MonoBehaviour {
|
||||
timing.StartTimer();
|
||||
}
|
||||
|
||||
public float Speed() {
|
||||
return rigidBody.velocity.magnitude;
|
||||
}
|
||||
|
||||
public void Damage(float amt, string src) {
|
||||
Debug.Log($"Damage {amt} from {src}");
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ControlsUI : MonoBehaviour {
|
||||
return;
|
||||
}
|
||||
|
||||
speed.text = $"{ship.Speed():0}";
|
||||
speed.text = $"{ship.Speed:0}";
|
||||
shield.detail = ship.powerUnit.ShieldPct switch {
|
||||
"100" => "",
|
||||
string pct => pct,
|
||||
|
||||
Reference in new issue
Block a user